×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Count number of solid elements in the tree

Count number of solid elements in the tree

Count number of solid elements in the tree

(OP)
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


RE: Count number of solid elements in the tree

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 --> CATScript

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

https://picasaweb.google.com/102257836106335725208
https://picasaweb.google.com/103462806772634246699...

RE: Count number of solid elements in the tree

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.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources