Reply

Lofted Protrusion

Hi guys,

 

I'm trying to make a lofted protrusion in asynchronous mode using the following code:

 

 

        objCSArray(0) = Perfil
        objCSArray(1) = Perfil4
        lngCSType(0) = SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection
        lngCSType(1) = SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection
        dblOrigin(0) = 0
        dblOrigin(1) = 0
        varOrigins(0) = dblOrigin

        varOrigins(1) = dblOrigin
        Modelo = Modelos.AddLoftedProtrusion(NumSections:=2, _
                                                         CrossSections:=objCSArray, CrossSectionTypes:=lngCSType, _
                                                         Origins:=varOrigins, SegmentMaps:=0, MaterialSide:=SolidEdgePart.FeaturePropertyConstants.igLeft, _
                                                         StartExtentType:=SolidEdgePart.FeaturePropertyConstants.igNone, StartExtentDistance:=0, _
                                                         StartSurfaceOrRefPlane:=Nothing, EndExtentType:=SolidEdgePart.FeaturePropertyConstants.igNone, _
                                                         EndExtentDistance:=0, EndSurfaceOrRefPlane:=Nothing, _
                                                         StartTangentType:=SolidEdgePart.FeaturePropertyConstants.igNone, StartTangentMagnitude:=0, _
                                                         EndTangentType:=SolidEdgePart.FeaturePropertyConstants.igNone, EndTangentMagnitude:=0)

 

Apparently I'm doing something wrong since I don't get an error but the protrusion is not created.

 

I hope somebody can help me with this.

 

Thanks.

 

Wilfredo

3 REPLIES

Re: Lofted Protrusion

I'll see if I can get it working. Quick question: Are you using Visual Basic 6 or Visual Basic .NET?

Jason Newell
Applications Architect
www.jasonnewell.net

Re: Lofted Protrusion

Hi,

thanks for your reply. I'm using Visual Basic.NET. 

 

Regards.

Wil.

Re: Lofted Protrusion

Hi, Did you get the correct form to do a Lofted Protusion?

 

Because I am also triying to develop a Lofted Protusion code and I get and error on the underlined lines,


wilfredo wrote:

Hi guys,

 

I'm trying to make a lofted protrusion in asynchronous mode using the following code:

 

 

        objCSArray(0) = Perfil
        objCSArray(1) = Perfil4
        lngCSType(0) = SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection
        lngCSType(1) = SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection
        dblOrigin(0) = 0
        dblOrigin(1) = 0
        varOrigins(0) = dblOrigin

        varOrigins(1) = dblOrigin
        Modelo = Modelos.AddLoftedProtrusion(NumSections:=2, _
                                                         CrossSections:=objCSArray, CrossSectionTypes:=lngCSType, _
                                                         Origins:=varOrigins, SegmentMaps:=0, MaterialSide:=SolidEdgePart.FeaturePropertyConstants.igLeft, _
                                                         StartExtentType:=SolidEdgePart.FeaturePropertyConstants.igNone, StartExtentDistance:=0, _
                                                         StartSurfaceOrRefPlane:=Nothing, EndExtentType:=SolidEdgePart.FeaturePropertyConstants.igNone, _
                                                         EndExtentDistance:=0, EndSurfaceOrRefPlane:=Nothing, _
                                                         StartTangentType:=SolidEdgePart.FeaturePropertyConstants.igNone, StartTangentMagnitude:=0, _
                                                         EndTangentType:=SolidEdgePart.FeaturePropertyConstants.igNone, EndTangentMagnitude:=0)

 

Apparently I'm doing something wrong since I don't get an error but the protrusion is not created.

 

I hope somebody can help me with this.

 

Thanks.

 

Wilfredo


Could someone help me?

 

Thanks!

im Nombre As String
Dim Ruta As String
Dim NombreNuevo As String = "NuevoDoc.par"
Dim SeccionNombre As String
Dim NumProtusiones As string
Dim Planos As Long
Dim Bocetos As String
Dim PN As String





objSEDocPart = objSEApp.ActiveDocument 'Se obtiene el documento activo en SE

'objSESketch = objSEPart.Sketches.Add

collSEPlanoS = objSEDocPart.RefPlanes 'Se obtienen los planos que existan en SE
objSEPlano = collSEPlanoS.Item(1) 'Seleccion del primer plano

'Planos = objcSEPlanoS.Count 'Se cuentan los planos
'PN = objSEPlano.Name 'Se obtiene el nombre del plano
'MsgBox(Planos)

collSketchs = objSEDocPart.Sketches 'Se obtienen la coleccion de sketchs
objSketch = collSketchs.Add 'Se añade un nuevo sketch

'Ahora se genera el sketch

collProfiles = objSketch.Profiles 'Se selecciona un sketch de tipo profile
objLoftProf(0) = collProfiles.Add(pRefPlaneDisp:=objSEPlano)

'Se comienza a seleccionar una linea para dibujar el sketch
lines2d = objLoftProf(0).Lines2d
relations2d = objLoftProf(0).Relations2d
dimensions = objLoftProf(0).Dimensions

'Se dan las coordenadas iniciales y finales para cada línea
lines2d.AddBy2Points(0, 0, 0.1, 0) 'Xinicial,Yinicial,Xfinal,Yfinal
lines2d.AddBy2Points(0.1, 0, 0.1, 0.1) 'Xinicial,Yinicial,Xfinal,Yfinal
lines2d.AddBy2Points(0.1, 0.1, 0, 0.1) 'Xinicial,Yinicial,Xfinal,Yfinal
lines2d.AddBy2Points(0, 0.1, 0, 0) 'Xinicial,Yinicial,Xfinal,Yfinal

''''''''''''''''''''''''''''''''''''''
objLoftProf(0).Convert3DCoordinate(x3d:=0.1, y3d:=0.1, z3d:=0, _
x2d:=xOrigin, y2d:=yOrigin)
' Save the coordinates to define the start point for this profile.
Origin(0) = xOrigin
Origin(1) = yOrigin
OriginArray(0) = Origin
''''''''''''''''''''''''''''''''''''''''

'Se crean las relaciones que unen los puntos finales de las líneas
relations2d.AddKeypoint(
lines2d.Item(1),
SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
lines2d.Item(2),
SolidEdgeConstants.KeypointIndexConstants.igLineStart
)

relations2d.AddKeypoint(
lines2d.Item(2),
SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
lines2d.Item(3),
SolidEdgeConstants.KeypointIndexConstants.igLineStart
)

relations2d.AddKeypoint(
lines2d.Item(3),
SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
lines2d.Item(4),
SolidEdgeConstants.KeypointIndexConstants.igLineStart
)

relations2d.AddKeypoint(
lines2d.Item(4),
SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
lines2d.Item(1),
SolidEdgeConstants.KeypointIndexConstants.igLineStart
)

'Relaciones Horizontales y verticales
relations2d.AddHorizontal(lines2d.Item(1))
relations2d.AddHorizontal(lines2d.Item(3))
relations2d.AddVertical(lines2d.Item(2))
relations2d.AddVertical(lines2d.Item(4))

'Crear dimensiones
dimensions.AddLength(lines2d.Item(1))
dimensions.AddLength(lines2d.Item(2))
'Restringir dimensiones
dimensions.Item(1).Constraint = True
dimensions.Item(2).Constraint = True

'Cerrar sketch
lngStatus = objLoftProf(0).End(ValidationCriteria:=SolidEdgePart.ProfileValidationType.igProfileClosed)
If lngStatus <> 0 Then
MsgBox("Invalid Profile")
End If

''''''''''''''''''''''''''''''''''''''''''''''''
'SEGUNDO SKETCH
'Se genera un plano paralelo para copiar y pegar el sketch
objSEPlanoPP = collSEPlanoS.AddParallelByDistance(
ParentPlane:=objSEPlano,
Distance:=0.1,
NormalSide:=SolidEdgePart.ReferenceElementConstants.igNormalSide,
Local:=False)

collSketchs = objSEDocPart.Sketches 'Se obtienen la coleccion de sketchs
objSketch = collSketchs.Add 'Se añade un nuevo sketch

'Ahora se genera el sketch

collProfiles = objSketch.Profiles 'Se selecciona un sketch de tipo profile
objLoftProf(1) = collProfiles.Add(pRefPlaneDisp:=objSEPlanoPP)

'Se comienza a seleccionar una linea para dibujar el sketch
lines2d = objLoftProf(1).Lines2d
relations2d = objLoftProf(1).Relations2d
dimensions = objLoftProf(1).Dimensions

'Se dan las coordenadas iniciales y finales para cada línea
lines2d.AddBy2Points(0, 0, 0.1, 0) 'Xinicial,Yinicial,Xfinal,Yfinal
lines2d.AddBy2Points(0.1, 0, 0.1, 0.1) 'Xinicial,Yinicial,Xfinal,Yfinal
lines2d.AddBy2Points(0.1, 0.1, 0, 0.1) 'Xinicial,Yinicial,Xfinal,Yfinal
lines2d.AddBy2Points(0, 0.1, 0, 0) 'Xinicial,Yinicial,Xfinal,Yfinal

''''''''''''''''''''''''''''''''''''''
objLoftProf(1).Convert3DCoordinate(x3d:=0.1, y3d:=0.1, z3d:=0.1, _
x2d:=xOrigin, y2d:=yOrigin)
' Save the coordinates to define the start point for this profile.
Origin(0) = xOrigin
Origin(1) = yOrigin
OriginArray(1) = Origin
''''''''''''''''''''''''''''''''''''''''

'Se crean las relaciones que unen los puntos finales de las líneas
relations2d.AddKeypoint(
lines2d.Item(1),
SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
lines2d.Item(2),
SolidEdgeConstants.KeypointIndexConstants.igLineStart
)

relations2d.AddKeypoint(
lines2d.Item(2),
SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
lines2d.Item(3),
SolidEdgeConstants.KeypointIndexConstants.igLineStart
)

relations2d.AddKeypoint(
lines2d.Item(3),
SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
lines2d.Item(4),
SolidEdgeConstants.KeypointIndexConstants.igLineStart
)

relations2d.AddKeypoint(
lines2d.Item(4),
SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
lines2d.Item(1),
SolidEdgeConstants.KeypointIndexConstants.igLineStart
)

'Relaciones Horizontales y verticales
relations2d.AddHorizontal(lines2d.Item(1))
relations2d.AddHorizontal(lines2d.Item(3))
relations2d.AddVertical(lines2d.Item(2))
relations2d.AddVertical(lines2d.Item(4))

'Crear dimensiones
dimensions.AddLength(lines2d.Item(1))
dimensions.AddLength(lines2d.Item(2))
'Restringir dimensiones
dimensions.Item(1).Constraint = True
dimensions.Item(2).Constraint = True

'Cerrar sketch
lngStatus = objLoftProf(1).End(ValidationCriteria:=SolidEdgePart.ProfileValidationType.igProfileClosed)
If lngStatus <> 0 Then
MsgBox("Invalid Profile")
End If

'LOFTED
For i = 0 To 1
SectionTypes(i) = SolidEdgePart.FeaturePropertyConstants.igContinuous
Next

objLoftProt = objModel.LoftedProtrusions.AddSimple(
NumSections:=2,
CrossSections:=objLoftProf,
CrossSectionTypes:=SectionTypes,
Origins:=OriginArray,
MaterialSide:=SolidEdgePart.FeaturePropertyConstants.igLeft,
StartTangentType:=SolidEdgePart.FeaturePropertyConstants.igNone,
EndTangentType:=SolidEdgePart.FeaturePropertyConstants.igNone)

' Check the Status of the Feature
If objLoftProt.Status <> SolidEdgePart.FeatureStatusConstants.igFeatureOK Then
MsgBox("AddSimple method of LoftedCutouts object failed")
End If
'objSketch = collSketchs.AddByTearOff(, objSEPlanoPP, False, True) 'TOMAR EN CUENTA PARA COPIAR SKETCH PARALELO