Create Contour Flange

Create Contour Flange

meck
Collaborator Collaborator
1,380 Views
3 Replies
Message 1 of 4

Create Contour Flange

meck
Collaborator
Collaborator

Hi all

I've been trying to create a contour flange from a profile I've created with code. The really sad part is I'm not sure if the profile is even valid.

oProfile = oSketch.Profiles.AddForSurface

Is AddForSurface the proper profile to use when creating a contour flange?

I'm not even sure how to get from the profile to the feature to create the contour flange.

 

Any help would be greatly appreciated!

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Accepted solutions (1)
1,381 Views
3 Replies
Replies (3)
Message 2 of 4

meck
Collaborator
Collaborator

Further explanation:

Using iLogic I create an open profile with code. It's the first sketch in the sheet metal part file. I wish to create a contour flange from that profile.

In the Inventor help, the examples of sheet metal flanges reference faces and edges. In my case I have neither the faces nor edges, unless it is considering the entities in the profile the edges. In a nut shell I cannot find any way to get from the sketch profile to the flange feature.

Here is all the code I have...

 

    Dim sheetMetalDoc As PartDocument
     sheetMetalDoc = ThisDoc.Document
 
    Dim smCompDef As SheetMetalComponentDefinition
    smCompDef = sheetMetalDoc.ComponentDefinition

    Dim profile As profile
    profile = oSketch.Profiles.AddForSolid

 

I hope this helps clarify my problem.

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes
Message 3 of 4

Vladimir.Ananyev
Alumni
Alumni
Accepted solution

Could you please try the following VBA code sample:

 

Sub Test()
    Dim oDoc As PartDocument
    Set oDoc = ThisApplication.ActiveDocument
    
    Dim oDef As SheetMetalComponentDefinition
    Set oDef = oDoc.ComponentDefinition
    
    Dim oSketch As PlanarSketch
    Set oSketch = oDef.Sketches.Item(1)
    
    ' Create a path.
    Dim oPath As Path
    Set oPath = oDef.Features.CreatePath(oSketch.SketchLines.Item(1))
    
    Dim oContourFlangeFeatures As ContourFlangeFeatures
    Set oContourFlangeFeatures = oDef.Features.ContourFlangeFeatures

    ' Create the flange definition.
    Dim cfDef As ContourFlangeDefinition
    Set cfDef = oContourFlangeFeatures.CreateContourFlangeDefinition(oPath)
    'set the distance extent
    Call cfDef.SetDistanceExtent(5, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection)
    
    Dim oCF As ContourFlangeFeature
    Set oCF = oContourFlangeFeatures.Add(cfDef)

End Sub

1.png2.png

 

Hope this helps.


Vladimir Ananyev
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 4 of 4

meck
Collaborator
Collaborator

Thanks Vladimir it worked great!

Mike Eck
Master Drafter/ CAD Programmer
Using Inventor 2018
0 Likes