Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Tek-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
Sep 23, 2016
19
0
0
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

 
Replies continue below

Recommended for you

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.
Back
Top