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!

AskFaceData & other possibilites 1

Status
Not open for further replies.

cmick31

Mechanical
Jun 1, 2021
19
Hello all,

I'm working on a program that sifts through all components > all bodies in components > all faces in bodies > ending with grabbing all holes in the model.

I wanted to get the Coordinates of each hole, with my initial take being to use AskFaceData and grabbing the point coordinates that it returns for a cylinder face(point on axis). However, this provides me the coordinates from within the components local WCS.

If I want to get the point coordinates globally from assembly level with these components having translation to them, do I need to look for a different method? Is there a way for me to convert this point readout to global? I've been stumped on this for a few days, reaching out here in hopes for some guidance. Appreciate any help!
 
Replies continue below

Recommended for you

Prototypes and occurrences: you model geometry in a part file, create an assembly file and add your part as a component. The geometry you see in the assembly: the body, every face, and every edge is an occurrence of the prototype geometry defined in the part file. When you use AskFaceData on a prototype face, it will return info based on the orientation in the part file. If you use AskFaceData on an occurrence face, it will return the information based on the assembly orientation. When you have a reference to a prototype object, you can use .FindOccurrence to get the corresponding occurrence in the assembly.

www.nxjournaling.com
 
You turned a week long duration of digging and headache into 15 minute fix in my code. Much appreciated Cowski.
 
Cowski,

I am able to get what I need perfectly, beside one main issue:

Some standard components in our libraries have features tied to them. This seems to not be able to grab the bodies when im processing the component because they're not considered dumb bodies but rather 'Extrusions' for example.. Is there still a way for me to process these components and grab the prototype parts & eventually the occurence?
 
It sounds like you might be iterating through the features in the part looking for "body" features. Instead, I'd suggest looking at the part's .Bodies collection. The process is the same whether your part has "dumb" geometry or whether it is fully parameterized. Each part has a .Bodies collection that will give you access to all the solid and sheet bodies in the part. The difference might be that the native part has extra geometry in the file - e.g. it might have multiple tool bodies saved in the part along with the final geometry. In this case, you need some logic to determine which body you want. In the places that I've worked, the final geometry was saved on layer 1 and all the support geometry was moved to other layers. In this case, I could look at the .Bodies collection of the part and look for the solid on layer 1. Alternately, if you are starting at the assembly level and processing components, you could check which reference set the component is using. There are function to return the objects in the reference set. From here, you could track down the prototype body in the part file and its occurrences in the assembly.

www.nxjournaling.com
 
.Bodies is currently what I'm running to grab all the solid bodies, poor debugging had me believing this was the issue. Looking into this made me catch the error however, thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor