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!

Insert new add in selected body

Status
Not open for further replies.

blaR3

Mechanical
Nov 16, 2016
8
SI
Hello everyone.

I made a .catvbs script that inserts new body in part and adds a pre-selected body (and sub-bodies) to this new body. This only works if pre-selected body is in root of structure so I ended code if anything else is selected (MsgBox: "Select first body!").
Now I've been trying to continue this code that if sub-body of existing body (inBoolean operation) was pre-selected new body would be inserted (added) before this pre-selected sub-body (sub-body added inside new body in existing body) ... of course with no success :)

If any of you know if this is solvable and how I would kindly ask for your help.
Thank you.


This is part of the code so far:

Set partDocument1 = Catia.ActiveDocument
Set part1 = PartDocument1.part
Set Selection2 = partDocument1.Selection

''''''''''''''''''''''''''''''''''''''''''''''''
If selection2.Count <> 1 Then
MsgBox ("Select one body!")
Exit Sub
Else
End If

''''''''''''''''''''''''''''''''''''''''''''''''
Selection2.Search "CATPrtSearch.BodyFeature, sel"
MsgBox ("Selection is not a body!")
Exit Sub
Else
End If

''''''''''''''''''''''''''''''''''''''''''''''''
Set Selection3 = Selection2.item(1).value
If Selection3.InBooleanOperation = False then
Set bodies1 = part1.Bodies
Set shapeFactory1 = part1.ShapeFactory
part1.inworkobject = Selection3
Set body1 = Bodies1.add
part1.inworkobject = body1
Set add1 = shapeFactory1.AddNewAdd (Selection3)
part1.inworkobject = body1
part1.update
Else
MsgBox ("Select first body!") 'here is where i need your help (the rest of the code instead of MsgBox)
Exit Sub
 
Replies continue below

Recommended for you

i find a solution but links might be impacted as I do not create Add.5 under Body.2 but change Add.4 to include new body then make new add to bring back body.6 into new body

i could rename add.5 and add.4 but i'm not sure links or other downstream operation would follow properly.

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

Part and Inventory Search

Sponsor

Back
Top