Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations KootK on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Accessing body inside multibody from selection 1

Status
Not open for further replies.

Manuel Pimenta

Mechanical
Aug 17, 2019
11
Hi everyone,

I have a body (called Circuito1 in the images) that is made of several other bodies (let's call them HoleBody) assembled together.
The HoleBody are all identical in structure, since they are copies of each other.
Captura_de_ecr%C3%A3_2020-10-28_081712_xinfm0.jpg

All of them have the same features, parameters and geometrical set inside.

In a section of my code I need to access one HoleBody.
The user selects on the 3D a face of the desired HoleBody, and I need to assign a body variable in VBA to that HoleBody, to do some tasks.

My problem is that I have no simple (and fast) way of accessing the HoleBody entity from the selection value I'm getting.
I have found a way that works, but is slow, especially when there are hundreds of HoleBodies.
What i'm doing:
From selection.value.name I extract the Hole feature name, and then I run a search for that Hole feature.
Captura_de_ecr%C3%A3_2020-10-28_082820_tjdcgm.jpg


I tried to access it from selection.value.parent, but this always points to the last assemble in the Circuito1 body, which is not what I want.

Does anyone know of a better way to access a body assembled in another body from a selection?
 
Replies continue below

Recommended for you

try the two solutions;
parent of the selection, it does give correct result, but only sometimes... havn't really had time to investigate...

MsgBox oSelection.item(1).Value.Parent.name

if you know that the user will select a face of a hole (always) you can get hold of it by using the .FindObject of the selection

Dim FoundObject As AnyObject
Set FoundObject = CATIA.ActiveDocument.Selection.FindObject("CATIAHole")



regards,
LWolf
 
Use Item(1).Value.Parent, it works as expected in the scenario you described and returns feature owning generic geometry.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor