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 TugboatEng on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count number of solid elements in the tree

Status
Not open for further replies.

douddy34

Mechanical
Joined
May 31, 2014
Messages
1
Location
CA
Hi guys,

i'm trying to develop a simple code to count the number of solid elements in the my main body.
The problem is, it only returns the number 1.

If any of you can help me. Thx a lot

Sub CATMain()

Dim MyPart As Part
Dim MyBodies As Bodies
Set MyPart = CATIA.ActiveDocument.Part
Set MyBodies = MyPart.Bodies
MsgBox (MyBodies.Count)

End Sub


 
Hi,

You mean mechanical features? If yes, check macro bellow (it will count in all bodies, not only in main body, you need to modify macro if you want only in main body).


Code:
Language="VBSCRIPT"

Sub CATMain()

Dim partDocument1 As Document
Set partDocument1 = CATIA.ActiveDocument

Dim selection1 As Selection
Set selection1 = partDocument1.Selection

selection1.Search "Name=*Body*,all"

Dim selection2 As Selection
Set selection2 = partDocument1.Selection

selection2.Search "CATPrtSearch.MechanicalFeature,sel"
MsgBox selection2.Count
End Sub

Regards
Fernando

 
hi,

Try ctrl + F and specify the elements to search and click search and select. It displays the no of elements selected.
Hope it helps. All the best.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top