blaR3
Mechanical
- Nov 16, 2016
- 8
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
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