Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Catia MACRO: Show/Hide Mechanical Features in Body

Status
Not open for further replies.

Daniel Popa

Automotive
Joined
Sep 23, 2016
Messages
19
Location
GB
Hello everyone

I am trying to create a macro that would show/hide all the features inside a Body. I have managed to get to a point where it is working nicely but I can not figure out how to make it check all the bodies and not just the ones with the name "Part Body".
Does anyone have any suggestions?

Thank you.

Code:
Language="VBSCRIPT"

Sub CATMain()

Set productDocument1 = CATIA.ActiveDocument

Set productDocument1 = CATIA.ActiveDocument

Set productDocument1 = CATIA.ActiveDocument

Set selection1 = productDocument1.Selection

selection1.Search "(CATPrtSearch.BodyFeature.Visibility=Visible),all"

Set selection1 = productDocument1.Selection

selection1.Search "CATPrtSearch.MechanicalFeature,sel"

Set selection1 = productDocument1.Selection

Set visPropertySet1 = selection1.VisProperties

Set visPropertySet1 = visPropertySet1.Parent

visPropertySet1.SetShow catVisPropertyShowAttr

selection1.Clear 

selection1.Search "((((CATStFreeStyleSearch.BodyFeature + CATPrtSearch.BodyFeature) + CATGmoSearch.BodyFeature) + CATSpdSearch.SpdBodyRef) + CATSpdSearch.BodyFeature),all"

Set selection1 = productDocument1.Selection

Set visPropertySet1 = selection1.VisProperties

Set visPropertySet1 = visPropertySet1.Parent

visPropertySet1.SetShow catVisPropertyShowAttr

selection1.Clear 

End Sub

 
Hi,

Daniel, your code is working fine, no matter the name of the body but you can clean it a little bit.

Code:
Language="VBSCRIPT"

Sub CATMain()
Set productDocument1 = CATIA.ActiveDocument

Set selection1 = productDocument1.Selection
selection1.Search "(CATPrtSearch.BodyFeature),all"

Set selection1 = productDocument1.Selection
selection1.Search "CATPrtSearch.MechanicalFeature,sel"

Set visPropertySet1 = selection1.VisProperties
Set visPropertySet1 = visPropertySet1.Parent
visPropertySet1.SetShow catVisPropertyShowAttr

selection1.Clear 

selection1.Search "((((CATStFreeStyleSearch.BodyFeature + CATPrtSearch.BodyFeature) + CATGmoSearch.BodyFeature) + CATSpdSearch.SpdBodyRef) + CATSpdSearch.BodyFeature),all"

visPropertySet1.SetShow catVisPropertyShowAttr

selection1.Clear 

End Sub

Regards
Fernando

- Romania
- EU
 
Sorry for my late reply.

Thank you. It was not working on some of the projects and i have found the problem. It was just the way the parts were hidden.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top