Reply
Solved! Go to solution

LoftedProtusion

Hello guys, 

 

I am trying to develop a Lofted Solid with a degree of rotation (Like the picture). 

I have got the Solid without rotation, but when I try to rotate the second sketch and perform the Lofted-Protusion, the feature does not work.

 

I am not sure if the points "Origins" that have to be defined on the Add.LoftedProtusion are corrected defined in my code.

 

Does anybody please could be so kind to help me? 

 

Captura.PNG

 

Dim X1 As Double = -0.05
        Dim Y1 As Double = 0 - 0.05
        Dim X2 As Double = 0.05
        Dim Y2 As Double = -0.05
        Dim X3 As Double = 0.05
        Dim Y3 As Double = 0.05
        Dim X4 As Double = -0.05
        Dim Y4 As Double = 0.05

        ' Get a reference to the documents collection
        objDoc = objApp.Documents

        ' Create a new part document
        objPart = objDoc.Add("SolidEdge.partDocument")

        ' Get a reference to the sketches collection
        collSketches = objPart.Sketches

        ' Add a new sketch
        objSketch = collSketches.Add()

        ' Get a reference to the profiles collection
        collProfiles = objSketch.Profiles ' objProfileSet.Profiles

        ' Get a reference to the ref planes collection
        collRefplanes = objPart.RefPlanes

        ' Add a new profile
        objProfile1 = collProfiles.Add(collRefplanes.Item(3))

        ' Get a reference to the lines2d collection

        collLines2d = objProfile1.Lines2d

        collPoints2d = objProfile1.Points2d


        objLine2d = collLines2d.AddBy2Points(X1, Y1, X2, Y2)
        objPoint2d = collPoints2d.Add(X1, Y1)
        objLine2d = collLines2d.AddBy2Points(X2, Y2, X3, Y3)
        objLine2d = collLines2d.AddBy2Points(X3, Y3, X4, Y4)
        objLine2d = collLines2d.AddBy2Points(X4, Y4, X1, Y1)

        'Define Relations among the Line objects to make the Profile closed

        collRelations2d = objProfile1.Relations2d

        objRelation2d = collRelations2d.AddKeypoint(
        collLines2d.Item(1),
        SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
        collLines2d.Item(2),
        SolidEdgeConstants.KeypointIndexConstants.igLineStart)

        objRelation2d = collRelations2d.AddKeypoint(
        collLines2d.Item(2),
        SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
        collLines2d.Item(3),
        SolidEdgeConstants.KeypointIndexConstants.igLineStart)

        objRelation2d = collRelations2d.AddKeypoint(
        collLines2d.Item(3),
        SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
        collLines2d.Item(4),
        SolidEdgeConstants.KeypointIndexConstants.igLineStart)

        objRelation2d = collRelations2d.AddKeypoint(
        collLines2d.Item(4),
        SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
        collLines2d.Item(1),
        SolidEdgeConstants.KeypointIndexConstants.igLineStart)

        ' Close the profile

        objProfile1.End(SolidEdgePart.ProfileValidationType.igProfileClosed)

        ' Show the profile

        objProfile1.Visible = True

        'Add a new sketch

        objSketch = collSketches.Add()

        ' Get a reference to the profiles collection

        collProfiles = objSketch.Profiles ' objProfileSet.Profiles

        ' Add a new reference plane

        objRefplane5 = collRefplanes.AddParallelByDistance(collRefplanes.Item(3), 0.25, SolidEdgePart.ReferenceElementConstants.igNormalSide, , , False)

        ' Add a new profile

        objProfile2 = collProfiles.Add(objRefplane5)

        ' Get a reference to the lines2d collection

        collLines2d = objProfile2.Lines2d

        ' Draw the Profile

        Dim X1_2 As Double = 0
        Dim Y1_2 As Double = 0
        Dim X2_2 As Double = Sqrt(2) / 20
        Dim Y2_2 As Double = Sqrt(2) / 20
        Dim X3_2 As Double = 0
        Dim Y3_2 As Double = 0.1414213564
        Dim X4_2 As Double = -Sqrt(2) / 20
        Dim Y4_2 As Double = Sqrt(2) / 20

        'Dim X1_2 As Double = 0
        'Dim Y1_2 As Double = 0
        'Dim X2_2 As Double = 0.1
        'Dim Y2_2 As Double = 0
        'Dim X3_2 As Double = 0.1
        'Dim Y3_2 As Double = 0.1
        'Dim X4_2 As Double = 0
        'Dim Y4_2 As Double = 0.1


        objLine2d = collLines2d.AddBy2Points(X1_2, Y1_2, X2_2, Y2_2)
        objPoint2d_2 = collPoints2d.Add(X1_2, Y1_2)
        objLine2d = collLines2d.AddBy2Points(X2_2, Y2_2, X3_2, Y3_2)
        objLine2d = collLines2d.AddBy2Points(X3_2, Y3_2, X4_2, Y4_2)
        objLine2d = collLines2d.AddBy2Points(X4_2, Y4_2, X1_2, Y1_2)

        ' Define Relations among the Line objects to make the Profile closed

        collRelations2d = objProfile2.Relations2d


        objRelation2d = collRelations2d.AddKeypoint(
        collLines2d.Item(1),
        SolidEdgeConstants.KeypointIndexConstants.igLineEnd, _
        collLines2d.Item(2),
        SolidEdgeConstants.KeypointIndexConstants.igLineStart)



        objRelation2d = collRelations2d.AddKeypoint(
        collLines2d.Item(2),
        SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
        collLines2d.Item(3),
        SolidEdgeConstants.KeypointIndexConstants.igLineStart)



        objRelation2d = collRelations2d.AddKeypoint(
        collLines2d.Item(3),
        SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
        collLines2d.Item(4),
        SolidEdgeConstants.KeypointIndexConstants.igLineStart)


        objRelation2d = collRelations2d.AddKeypoint(
        collLines2d.Item(4),
        SolidEdgeConstants.KeypointIndexConstants.igLineEnd,
        collLines2d.Item(1),
        SolidEdgeConstants.KeypointIndexConstants.igLineStart)


        objProfile2.End(SolidEdgePart.ProfileValidationType.igProfileClosed)


        ' Show the profile
        objProfile2.Visible = True
        ' Get a reference to the models collection
        collModels = objPart.Models

        ' Create the lofted protrusion.


        dblOrigin(0) = X1
        dblOrigin(1) = Y1

        objOrigins(0) = objPoint2d


        dblOrigin(0) = X1_2
        dblOrigin(1) = Y1_2

        objOrigins(1) = objPoint2d_2


        objCSArray(0) = objProfile1
        objCSArray(1) = objProfile2


        lngCSTypeArray(0) = SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection
        lngCSTypeArray(1) = SolidEdgePart.FeaturePropertyConstants.igProfileBasedCrossSection


        objModel = collModels.AddLoftedProtrusion(
            NumSections:=2,
            CrossSections:=objCSArray,
            CrossSectionTypes:=lngCSTypeArray,
            Origins:=objOrigins,
            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)

 

2 REPLIES
Solution
Solution
Accepted by topic author OmarPreciado
a month ago

Re: LoftedProtusion

Indeed, you have incorrectly defined your origins.

You don't need to create an additional point for the origins on the sketch, but can simply define the Origins argument (based on the profile coordinates) in the following way. That should give you a valid feature.

...
    Dim dblOrigin1() = New Double() {X1, Y1}
    Dim dblOrigin2() = New Double() {X1_2, Y1_2}
    Dim objOrigins() = New Object() {dblOrigin1.Clone(), dblOrigin2.Clone()}
...

Re: LoftedProtusion

Thank you very much, I have solved the proble.