Error message when trying to create profile to extrude

Error message when trying to create profile to extrude

cstephens58F4Q
Contributor Contributor
202 Views
2 Replies
Message 1 of 3

Error message when trying to create profile to extrude

cstephens58F4Q
Contributor
Contributor

I am trying to create a profile using 4 sketch lines. The sketch it produces is an enclosed figure. The error im getting is "Incorrect parameter when setting the profile object. Any ideas? Attached is the section of code. Its a copy of a working section of code where a centerpoint rectangle is used to create the sketch.

        Dim partDef As PartComponentDefinition
        partDef = oDoc.ComponentDefinition

        ' Create a new sketch.
        Dim sketch As PlanarSketch
        sketch = partDef.Sketches.Add(partDef.WorkPlanes.Item(3))

        Dim oTG As TransientGeometry = oApp.TransientGeometry


        Call sketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(-A, 0), oTG.CreatePoint2d(A, 0))

        Call sketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(-A, 0), oTG.CreatePoint2d(-B, T))

        Call sketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(A, 0), oTG.CreatePoint2d(B, T))

        Call sketch.SketchLines.AddByTwoPoints(oTG.CreatePoint2d(-B, T), oTG.CreatePoint2d(B, T))



        Dim oProfile As Profile = sketch.Profiles.AddForSolid

        Dim oExtrudeDef As ExtrudeDefinition = partDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kJoinOperation)

        oExtrudeDef.SetDistanceExtent(z_length, PartFeatureExtentDirectionEnum.kNegativeExtentDirection)

        Dim oExtrude As ExtrudeFeature = partDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
0 Likes
Accepted solutions (1)
203 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor
Accepted solution

Hi @cstephens58F4Q.  It looks like you are drawing 4 individual sketch lines, whose endpoints may be overlapping each other.  This does not actually constrain the end points together, so it likely thinks the profile is open.  If you want to draw a centered rectangle, there are 2 methods for that under the SketchLines object.  One is called AddAsThreePointCenteredRectangle(), and the other is called AddAsTwoPointCenteredRectangle().  Or, if you prefer drawing the individual lines, you must capture the SketchLine objects as you create them, then use their EndSketchPoint or StartSketchPoint properties (represents a SketchPoint) as the input when creating the next SketchLine.  That automatically applies a coincident constraint between the end points of the sketch lines for you, resulting in a closed profile.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

cstephens58F4Q
Contributor
Contributor

Thanks that fixed it. I was using the line segments instead of the rectangle function because im creating trapazoid shopes within the program for use in assembly 

0 Likes