×
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

Insert new add in selected body

Insert new add in selected body

Insert new add in selected body

(OP)
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

RE: Insert new add in selected body

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

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