Step through part dimension visibility

Step through part dimension visibility

rogmitch
Advocate Advocate
595 Views
2 Replies
Message 1 of 3

Step through part dimension visibility

rogmitch
Advocate
Advocate

I have been trying to sequentially show (and then hide) the dimensions for each feature (together with  its related sketch dimensions)  in a part browser tree.

 

 I can set the visibility for any one of the sketches with e.g.

 

oSketches.Item(1).Visible = True 
oSketches.Item(1).DimensionsVisible = True 'Show sketch dimension

 

and show the visibilty of the feature dims with e.g.

 

Set oFeature = odef.Features.Item(1)
oFeature.FeatureDimensions.Show  'Show feature dimension

but I cannot work out how to test which feature a particular sketch is dependent upon. Until I do this the visibiliy

of the feature and sketch dimensions cannot be synchronised.

 

 I expected something like

 

If odef.Features.Item(1) = oSketch.Parent might work or maybe the  Isownedby function but so far I have had no luck with anything I have tried.

 

If anyone can help I would much appreciate it.

 

Thanks

 

Roger Mitchell

 

 

0 Likes
596 Views
2 Replies
Replies (2)
Message 2 of 3

rogmitch
Advocate
Advocate

Update- I worked out one way to check if a feature has a dependent sketch. Just in case anybody is interested the following returns the 1st sketch item number under a feature

 

Function CheckFeaturehasSketch(intFeatureNum As Long) As Long

Dim odef As PartComponentDefinition
Set odef = oPartDoc.ComponentDefinition
Set oSketches = odef.Sketches
Dim oFeature As PartFeature
Dim oSketch As PlanarSketch
Dim intcount As Long

 

For Each oSketch In oSketches
intcount = intcount + 1
On Error Resume Next
If oSketch Is odef.Features.Item(intFeatureNum).Profile.Parent Then
If Err <> 0 Then Exit Function 'Feature does not have sketch
CheckFeaturehasSketch = intcount
Exit Function
End If
Next

End Function

 

If anyone knows a tidier way to do this please post.

 

Thanks

0 Likes
Message 3 of 3

philippe.leefsma
Alumni
Alumni

Hi,

 

Some Faetures are sketch-based and some other aren't, eg. fillets, chamfers, ...

 

For sketch based features, Feature.Profile.Parent "is" the sketch the feature is based upon, so i don't understand why you would need to go the other way around and iterate through all sketches to compare it... Going from the sketch you can try to use "PlanarSketch.Dependents" property to find the feature.

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes