Cancel
Showing results for
Did you mean:

# Mapping Polygon Faces to CAD Faces within a NXOpen framework

Solution Partner Valued Contributor

## Quick Overview

This Tips & Trick shows how to map Polygon Faces (i.e., CAE faces) to CAD Faces. Given a CAD Face in the Modeling application, what is its corresponding CAE Face in the Advanced Simulation application ?

## Core content

How to find the corresponding CAE Face for a given CAD Face ? Visually, it is obvious to make the match in most cases. For example, Figure 1 shows three (3) faces of a cube in the Modeling application (in a PART file) and their corresponding CAE faces in the FEM part. Equivalent faces share the same color.

However, when writing a NXOpen script, the user does not see the geometry. Therefore, making the match between CAD Faces and CAE Faces is not straightforward. How can we proceed ?

## The case of bodies

Matching bodies in NXOpen is easier that matching faces. Indeed, there exist Open C functions that provide the polygon body that corresponds to a given solid / sheet CAD body, and vice versa. These functions are:

Input: the CAD body.  It can be a solid or a sheet body.
Output: the CAE (polygon) body.

Input:  the CAE (polygon) body. It can be a solid or a sheet body.

The first function takes as input the tag of the CAD Body and returns the tag of the corresponding CAE Body. The second function takes as input the tag of the CAE Body and returns the tag of the corresponding CAD Body.

Unfortunately, there are no such functions for CAD and CAE Faces. A different and less explicit approach should be used.

Figure 1: Three (3) CAD Faces of a cube (TOP figure) and their corresponding Polygon Faces (BOTTOM figure).

## The power of attributes

Attributes of NX Objects are automatically transferred from PART to FEM (the inverse is not true !). For example, if an attribute is set to a CAD Face, the equivalent CAE Face will inherit the same attribute. To set manually an attribute in NX, right-click on the desired NX Object, go to “Properties“ and select the “Attributes” tab.

Figure 2 shows the attributes dialog of Face # 3. We have created a string attribute with the title “HELLO” and the value “FACE”.

Figure 2: Setting an attribute for CAD Face # 3

Then we go to the FEM and open the attributes dialog for Polygon Face # 3. The polygon face inherits the attribute of its corresponding CAD face, as shown in Figure 3.

## Mapping Polygon Faces to CAD Faces by using attributes.

After what has been discussed above, mapping between Polygon Faces and CAD Faces can be done using the following steps:

1. In the PART, loop over all CAD bodies using the Body Collection.

2. For each Body, get all the CAD Faces using the function GetFaces().

Figure 3: Attributes dialog for the Polygon Face # 3. The attributes are inherited from CAD Face # 3.

3. Loop over all the CAD Faces and for each, set a unique attribute using the function SetAttribute(). The attribute should be unique for each face. For example, set an attribute with title = “ID” and value = “FACE_1” for the first face and another attribute with title = “ID” and value = “FACE_2” for the second face.

4. Create a map that stores all the pairs (FACE, ID).

5. Go to the FEM.

6. Loop over all Polygon bodies using the function UF_SF_ask_all_polygon_bodies().

7. For each Polygon Body, get all the Polygon faces using the function UF_SF_body_ask_faces().

8. For each Polygon Face, read the attribute “ID” using the function GetUserAttribute().

9. Using the map created in step 4, find the corresponding CAD Face.

Maya HTT
US & Canada: +1-800-343-6292 | UK: +44 (0) 330 024 1029
info@mayahtt.com | https://www.mayahtt.com
2 REPLIES 2

# Re: Mapping Polygon Faces to CAD Faces within a NXOpen framework

Siemens Phenom

Note that in NX / Simcenter 12.0, the following method was added to get the CAD faces directly from the CAE face:

NXOpen.CAE.CAEFace.GetUgfaces()

# Re: Mapping Polygon Faces to CAD Faces within a NXOpen framework

Creator

There is a function to map general objects between CAD/CAD_I/FEM/SIM parts: map_object_to_current_part(Tag).

However, it might require you to switch the work/or displayed part.
Building an example map for ~13,000 faces with the python API took 0.5s.