Get existing PartFeatureExtentDirectionEnum of HoleFeature in PartDocDef

Get existing PartFeatureExtentDirectionEnum of HoleFeature in PartDocDef

josh.nieman
Advocate Advocate
607 Views
3 Replies
Message 1 of 4

Get existing PartFeatureExtentDirectionEnum of HoleFeature in PartDocDef

josh.nieman
Advocate
Advocate

Using Ivnentor 2019.3

 

I am in a part file.

There is a base extrusion object.

I have existing hole features placed through this object.

I would like to modify the depth of these hole features.

 

I'm trying to use the "SetDistanceExtent" method of the HoleFeature, to modify the depth of each hole in a collection.

This requires three parameters.  The second being of the PartFeatureExtentDirectionEnum type, or I would just take the heavy-handed approach and do that, since my changes are temporary.

 

Every example I can find working with holes in a part is calling the PartFeatureExtentDirectionEnum directly, and not calling it from a stored value. 

 

Example code:

 

For Each hf_Ftr In oc_Holes
'------hf_Ftr as HoleFeature object
'------oc_Holes as ObjectCollection [containing HoleFeature objects]
Dim HFDepth as string = "0.375 in" hf_Ftr.SetDistanceExtent(HFDepth, HFDir, True) Next

 

 

What I cannot figure out is how to store the PartFeatureExtentDirectionEnum of hf_Ftr in order to later recall it.


Everything works fine if I replace "HFDir" with "PartFeatureExtentDirectionEnum.kNegativeExtentDirection" for example.  I just don't know that I can rely on it always being Pos or Neg, and you can't make a HoleFeature symmetric, it would seem.

 

0 Likes
Accepted solutions (2)
608 Views
3 Replies
Replies (3)
Message 2 of 4

JaneFan
Autodesk
Autodesk
Accepted solution

Assume the existing Hole feature to be edited is got as object oHole1, here is the way to get the current direction and can be used in set method:

Dim eDirection = oHole1.Extent.Direction




Jane Fan
Inventor/Fusion QA Engineer
0 Likes
Message 3 of 4

chandra.shekar.g
Autodesk Support
Autodesk Support
Accepted solution

@josh.nieman ,

 

Try below code to get existing PartFeatureExtentDirectionEnum 

 

For Each hf_Ftr In oc_Holes
'------hf_Ftr as HoleFeature object
'------oc_Holes as ObjectCollection [containing HoleFeature objects]

Dim oExtent As DistanceExtent
oExtent = hf_Ftr.Extent

Dim HFDepth As String = "0.375 in"

hf_Ftr.SetDistanceExtent(HFDepth, oExtent.Direction, True)

Next

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes
Message 4 of 4

josh.nieman
Advocate
Advocate

Thank you, @JaneFan  & @chandra.shekar.g that is perfect.

I've proved it to work on parts with hole features that have positive, negative, and a mixture of both, directions, when iterating through. 
Thank you.  

0 Likes