body inside body

body inside body

Michele_DeLucaSW7PJ
Contributor Contributor
412 Views
2 Replies
Message 1 of 3

body inside body

Michele_DeLucaSW7PJ
Contributor
Contributor

Hi Everybody i need some help ho to get the name of a body nested in another body

with this script i get only the "parent" body and not the one nested inside

 

Dim oCompDef as ComponentDefinition
oCompDef = ThisDoc.Document.ComponentDefinition


'define the solidbody
Dim oBody As SurfaceBody
Dim i As Integer
i = 1

For Each SurfaceBody In oCompDef.SurfaceBodies
oBody = oCompDef.SurfaceBodies.Item(i)

MsgBox(oBody.Name)

i = i +1
Next

 

Cattura.PNG 

0 Likes
Accepted solutions (1)
413 Views
2 Replies
Replies (2)
Message 2 of 3

TomaszDabrowski
Autodesk
Autodesk
Accepted solution

I am not sure, but I think it is not a body inside a body, but rather a feature used to create this body.

You can try with:

Dim oCompDef As ComponentDefinition
oCompDef = ThisDoc.Document.ComponentDefinition


'define the solidbody
Dim oBody As SurfaceBody
Dim i As Integer
i = 1

For Each SurfaceBody In oCompDef.SurfaceBodies
oBody = oCompDef.SurfaceBodies.Item(i)

MsgBox(oBody.CreatedByFeature.Name)

i = i +1
Next

 

Tomasz Dąbrowski
Technical Support Specialist
Customer Technical Success
Message 3 of 3

Michele_DeLucaSW7PJ
Contributor
Contributor
It works, thank you!
0 Likes