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!

Catia macro: boolean operations -> remove 1

Status
Not open for further replies.

elmundo777

Automotive
Jun 23, 2020
93
BY
Hi everyone!
I'm interested in the issue of automating boolean operations. There are always two bodies statically. But always different names. How can I assign a button to remove the second body from the first?
boolean_pdbvfa.png


What the macro records when executed is not entirely correct. And there is a link to the name of the documents:

Code:
Sub CATMain()

Dim partDocument1 As PartDocument
Set partDocument1 = CATIA.ActiveDocument

Dim part1 As Part
Set part1 = partDocument1.Part

Dim shapeFactory1 As ShapeFactory
Set shapeFactory1 = part1.ShapeFactory

Dim bodies1 As Bodies
Set bodies1 = part1.Bodies

Dim body1 As Body
Set body1 = bodies1.Item("[b][COLOR=#8AE234]new77777777777777777777777777777777.1\PartBody[/color][/b][i][s][/s][/i]") [COLOR=#EF2929]<--Something universal is needed here. since it is known that the second body is always removed from the first.

and this automatically recorded macro does not work, but only deletes the body.[/color]

shapeFactory1.AddNewRemove body1

part1.Update

End Sub
 
Replies continue below

Recommended for you



the first body is always the Mainbody (in you case it is empty)

When you "remove" it removes the body from the active body, which in your case is the Mainbody

Why would you want to remove a body when you do not have geometry yet in the mainbody ?


Eric N.
indocti discant et ament meminisse periti
 
This is a generated allcatpart from two products. I want to do boolean operations to compare geometry. so all documents will be identical to this.
 
yes, in the case in the picture this will be the removal of the third body from the second.
 
then you should define the second body as current body and do a remove from the third

Set body1 = bodies1.Item(2)
set body2 = bodies1.Item(3)

part1.InWorkObject = body1

shapeFactory1.AddNewRemove body2

Eric N.
indocti discant et ament meminisse periti
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top