×
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

Deactivate Assembles with empty bodies

Deactivate Assembles with empty bodies

Deactivate Assembles with empty bodies

(OP)
Hello all,

due to standard issues I have to present the all the part assembles that contains empty bodies inactive. The bodies must be there, not possible just to delete them....

So far I've tried to make a script, but it is not working because I can not match the empty body with assemble to be deactivated. Can I get someones help? Please look at the code below. Not necessary to say that I am new to VBA, right?

Language="VBSCRIPT"

Sub CATMain()
Set Document = CATIA.ActiveDocument
Set Part1 = Document.Part
Set Bodies = Document.Part.Bodies
Set body1 = Bodies.Item("PartBody")
Set shapes1 = body1.Shapes
Set selection1 = Document.Selection

For i = 1 To Shapes1.Count
if CheckEmptyBody (Bodies.Item(i)) = true then
selection1.Add Shapes1.Item(i)
Part1.Inactivate Shapes1.Item(i)
end if
Next

MsgBox "Assembles with empty Bodies Inactive"

End Sub

Function CheckEmptyBody(body)
Set HybridShapes = body.HybridShapes
Set ogs = body.OrderedGeometricalSets
Set Shapes = body.Shapes
Set Sketches = body.Sketches
On Error Resume Next
Count1 = HybridShapes.Count
Count2 = ogs.Count
Count3 = Shapes.Count
Count4 = Sketches.Count
on error goto 0
If Count1 = 0 And Count2 = 0 And Count3 = 0 And Count4 = 0 Then
CheckEmptyBody = true
Else
CheckEmptyBody = false
End If

End Function

RE: Deactivate Assembles with empty bodies

I forgot to mention that what code is doing is to find the name which you will have to search (in the comments is Body.5 if I remember correctly).

Regards
Fernando

https://picasaweb.google.com/102257836106335725208

RE: Deactivate Assembles with empty bodies

(OP)
Thank you Fernando,

I will give it a try!

Regards

Jcruz

RE: Deactivate Assembles with empty bodies

(OP)
Hello Fernando,

this weekend I was around the code, and I had no problems with the combined search, and the CATIA.StartCommand "DeActivate", but I need the name of the assemble to search for.
In your code it is "Bodies.Item(oEmptyCount).Name", but this does not give me the name of the assemble. Shouldn't be a "shape" somewhere in the code line?

Thanks for the support,

JCruz

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