Loop select sketch to create boundry?

Loop select sketch to create boundry?

Anonymous
Not applicable
1,863 Views
6 Replies
Message 1 of 7

Loop select sketch to create boundry?

Anonymous
Not applicable

I am not sure exactly why this is a limited feature of Inventor 2011 but when you want to select a sketch to create a boundry patch you have to select each part of the sketch in sequence.  It's a pretty laborious task.  I am looking to a way to automate this using ilogic.  Does anybody have experience of this or able to point me to a good tutorial that may help me?

 

Thanks

 

Guy

0 Likes
1,864 Views
6 Replies
Replies (6)
Message 2 of 7

philippe.leefsma
Alumni
Alumni

Hi Guyh,

 

Not sure if you could do that using iLogic or if it is going to be easier, but you could use "CreatePath" API in order to easily retrieve the connected entities to the selected sketch curve.

 

Here is a VBA sample:

 

Public Sub GetPath()
    
    Dim doc As PartDocument
    Set doc = ThisApplication.ActiveDocument
    
    Dim sketchEnt As SketchEntity
    Set sketchEnt = ThisApplication.CommandManager.Pick(kSketchCurveFilter, "Select curve:")
    
    Dim path As path
    Set path = doc.ComponentDefinition.Features.CreatePath(sketchEnt)
    
    Dim pathEnt As PathEntity
    For Each pathEnt In path
    
        Call doc.SelectSet.Select(pathEnt.SketchEntity)
    
    Next

End Sub

 

Philippe Leefsma
Developer Consultant
Developer Technical Services
Global Subscription & Support
 

Autodesk EMEA

 

www.autodesk.com/joinadn

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hi Philippe,

 

Thanks for the code.  This works well in the sketch environment but to select a boundary loop it is only accessible when you are outside the sketch mode so I am not sure how useful this is?  To compound my situation I am using a series of blocks connected with basic sketch lines to make my profile shape.

 

I am limited to using a boundary patch as I can not extrude this shape easily on a repeatable basis.  I therefore thought creating a surface the best option as I can derive my part into a new file and just thicken each time I wish to make a new profile.

 

Pic attached to try and show what I am doing.

 

Cheers,

Guy

 

 

0 Likes
Message 4 of 7

Anonymous
Not applicable

May be this VBA code will help you.

If you get profile object you can use it for extrude feature.

 

Public Sub GetSingleSelection()
   ' Get a contour selection from the user
   Dim oObject As Object
   Set oObject = ThisApplication.CommandManager _
         .Pick(SelectionFilterEnum.kSketchProfileFilter, _
         "Pick an object")         
   Dim oP As Profile
   Set oP = oObject 
   MsgBox "Area (cm^2): " & oP.RegionProperties.Area
End Sub

 

Message 5 of 7

Anonymous
Not applicable

thanks but I cant seem to get that to work.

 

Cheers,

Guy

0 Likes
Message 6 of 7

Anonymous
Not applicable

This code produces BoundaryPatchFeature based on the picked sketch profile. 

Public Sub GetSingleSelection()

   Dim oPartDoc As PartDocument
   Set oPartDoc = ThisApplication.ActiveDocument
   Dim oCompDef As PartComponentDefinition
   Set oCompDef = oPartDoc.ComponentDefinition
    
   ' Get a profile selection from the user
   Dim oObject As Object
   Set oObject = ThisApplication.CommandManager _
         .Pick(SelectionFilterEnum.kSketchProfileFilter, _
         "Pick a Profile")
   Dim oP As Profile
   Set oP = oObject

   Dim oBoundaryPatchDef As BoundaryPatchDefinition
   Set oBoundaryPatchDef = oCompDef.Features _
     .BoundaryPatchFeatures.CreateBoundaryPatchDefinition

   ' Create a boundary patch feature based on the profile
   Call oBoundaryPatchDef.BoundaryPatchLoops.Add(oP)

   Dim oBoundaryPatch As BoundaryPatchFeature
    Set oBoundaryPatch = oCompDef.Features _
      .BoundaryPatchFeatures.Add(oBoundaryPatchDef)

End Sub

 

 

0 Likes
Message 7 of 7

VGonsalves
Advocate
Advocate

Hi ALink

 

I am trying to loop the extrude command with predefined settings. I have used your code and modified it to suit, refer below. Now I am struggling with the fact that only closed profiles get extruded and I am not able to even pick the open profiles. Can you have a look at the code and assist

 

Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition = oPartDoc.ComponentDefinition
Dim oObject As Object
Dim oP As Profile
Dim oExtrude As ExtrudeFeature
oObject = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter, "Pick an object")
oP = oObject
While oP IsNot Nothing
oExtrude = oCompDef.Features.ExtrudeFeatures.AddByDistanceExtent(oP, "100 mm", kSymmetricExtentDirection, kSurfaceOperation)
oObject = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter, "Pick an object")
oP = oObject
End While

 

Thanks

0 Likes