Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

MACRO FOR REMOVAL TAPS BODY IN A ASSEMBLY

Status
Not open for further replies.

nad35

Bioengineer
Oct 5, 2006
2
I have a product with a base plate on which I assemble other 4 parts. I want to automate the removal tap body from each part to the main plate with a macro. Is it possible...
Ferdo please give me an tip....
By the way nice pictures. RO este foarte frumoasa....
 
Replies continue below

Recommended for you

Hi

Yes indeed, is very nice. I have many more pictures, but I need time (and a good connection [bigsmile] ).
Coming to your question, tap body is the name of a body or ? A sample product would be great (up to r18 in my case) or more details or what you've tried....
The bellow code is deleting empty bodies and is modified previously by peterguy (which by the way I don't know why he is not active anymore here) and I just done conversion for CATScript
Based on this example, it really depends on what does it means "tap body" (if is a body name search for name and follow the example).
Waiting for your feedback...

Code:
 Sub CATMain()
 
 'Code modified by peterguy
 Dim selection1 As Selection
Set Document = CATIA.ActiveDocument
Set Bodies = Document.Part.Bodies
Set selection1 = Document.Selection
selection1.Clear

For i = 1 To Bodies.Count

if CheckEmptyBody (Bodies.Item(i)) = true then
selection1.Add Bodies.Item(i)
end if

Next

selection1.Delete
MsgBox "Empty Bodies Deleted "
End Sub

Function CheckEmptyBody(body) as boolean

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
'~ debug.print body.Name & " is an Empty Body "
CheckEmptyBody = true

Else
'~ debug.print "No Empty Body"
CheckEmptyBody = false
End If

End Function







Regards
Fernando

 
Ma poti contacta pe yahoo punct com la dtudor88
Thanks ferdo.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor