"Edit" a feature in a part using API

By Augusto Goncalves

Each Feature has a method called SetEndOfPart which takes boolean as argument. If you want to "Edit" a particular feature, first you need to call SetEndOfPart(true). This moves the "Part End Marker" to above this feature. After this do the necessary changes in the feature you were looking for. After this do not forget to move the "Part End Marker" to the end of this feature by calling SetEndOfPart (False).

The code below changes the workplane of a hole feature in the attached part.

Public Sub ChangeOfFace()

  Dim oDef As PartComponentDefinition

  oDef = m_inventorApplication.ActiveDocument.ComponentDefinition

 

  ‘Get the hole feature

  Dim oHoleFeat As HoleFeature

  oHoleFeat = oDef.Features.HoleFeatures.Item(1)

 

  ‘Move the EndofPart position before Hole feature

  oHoleFeat.SetEndOfPart(True)

  Dim oWorkplane As WorkPlane

 

  ‘Change the workplane

  oWorkplane = oDef.WorkPlanes.Item(5)

  ‘?Set it to hole feature

  oHoleFeat.SetToFaceExtent(oWorkplane, True)

 

  ‘Move Back the EndofPart position after last feature

  oDef.Features.Item(oDef.Features.Count).SetEndOfPart(False)

End Sub


Comments

Leave a Reply

Discover more from Autodesk Developer Blog

Subscribe now to keep reading and get access to the full archive.

Continue reading