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!

Ansys Workbench ACT - Accessing face IDs of elements subjected to pressure load 1

Status
Not open for further replies.

xtremi

Structural
Jul 27, 2018
10
I am trying to create a plugin for Ansys Mechanical in Workbench 19.0, and I am doing so using the .NET API in a mix of C# and C++/CLI project.

Part of the plugin is to extract a lot of information form an analysis. It took me a long time to figure out how to set up my environment, but I'm finally able to read Analysis Settings, mesh and much more.

Unfortunately, now I'm stuck on specific problem;

If an analysis has a pressure load applied to a geometric face, I can retrieve an object of the [tt]Pressure[/tt] class. This class has a property [tt]Location[/tt] which is an interface class [tt]ISelectionInfo[/tt]. From there I can access a set of Ids.

Using the [tt]IMeshData[/tt] interface class of the analysis, I get the [tt]IMeshRegion[/tt] of the specific Ids using the method [tt]MeshRegionById(int id)[/tt]. This allows me to retrieve the elements on which the pressure is applied using the property [tt]ElementsIds[/tt] of [tt]IMeshRegion[/tt].

Now I have the elements, but I also need to know which faces the pressure is applied on.
The [tt]IMeshRegion[/tt] interface has these 4 methods:

Code:
void GetFaces(Int32[]& param1, Int32[]& param2, Int32[]& param3, Int32[]& param4)
Int32[] GetTri3ExteriorFaces()
Int32[] GetTri6ExteriorFaces()
Int32[] GetQuad4ExteriorFaces()
Int32[] GetQuad8ExteriorFaces()

In my example case I'm working on, the pressure load is applied to a geometric face, where the mesh attached to it are quadratic solid elements (20 noded).

By calling the GetFaces() method, I will receive an array of face ids, but it holds all the face ids (each face of each elements) not the face ids of where the pressure load is applied.

In the API Reference Guide, i found an Interface class [tt]IMechanicalSelectionInfo[/tt] which is derived from the [tt]ISelectionInfoClass[/tt]. That class has a property called [tt]ElementFaceIndices[/tt].
But I don't see how to access it. The [tt]Pressure[/tt] class only returns a [tt]ISelectionInfo[/tt] for the property [tt]Location[/tt].


So I guess my question is, given an [tt]IMeshRegion[/tt], how can I know which element faces belong to this region?


Thanks for any feedback!



 
Replies continue below

Recommended for you

Could you paste the code you have written so far? I have problems finding GetFaces() method through
the console. I am using 19.1 (and python if that matters).
 
Here is some code I tried. The problem is that auto-completion didn't offer
those methods for the region.

model = ExtAPI.DataModel.Project.Model
a = model.Analyses[0]
meshData = a.MeshData

#ids for selected faces
current_ids = ExtAPI.SelectionManager.CurrentSelection.Ids
#mesh region for first selected face
region = meshData.MeshRegionById(current_ids[0])
#first element of mesh region
elem = region.Elements[0]

selection = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.MeshElements)
selection.Ids = [elem.Id]

#autocompletion offers this property for the selection, but there is nothing returned
selection.ElementFaceIndices

selection2 = ExtAPI.SelectionManager.CreateSelectionInfo(SelectionTypeEnum.MeshElementFaces)

 
Can you do this:

model = ExtAPI.DataModel.Project.Model
a = model.Analyses[0]
meshData = a.MeshData

#ids for selected faces
current_ids = ExtAPI.SelectionManager.CurrentSelection.Ids
#mesh region for first selected face
region = meshData.MeshRegionById(current_ids[0])

quad8faces = []
tri6faces = []
quad4faces = []
tri3faces = []

region.GetFaces(quad8faces, tri6faces, quad4faces, tri6faces)

?

If you can't access the function, maybe you need to import a cetain module.

 
Sorry for hijacking the thread. I got region.GetFaces() to work. My test model
consists of 1 element. Region.GetFaces() returns a list of 4 lists. Second
lists consists of 8 integers. I am wondering what the numbers represent.


Edit: Figured it out. They are the nodes of the selected face.
 
Interesting, so [tt]getFaces[/tt] returns the node ids defining the face?


Maybe my code works then...

In C# I call getFaces something like this:

Code:
int[] tri3faces;
int[] tri6faces;
int[] quad4faces;
int[] quad8faces;

meshregion.GetFaces(out tri6faces, out quad8faces, out tri3faces, out quad4faces);

If my selected geometry is a face, where the mesh consists of 2100 quadratic hexahedron elements, my quad8faces array gets filled with 16800 ids.

For some reason I thought that was the ids of all the faces for all the 2100 elements. But that doesn't even make sense, because 6 faces * 2100 elements does not equal 16800. BUT, as you say, if those ids are the nodes, defining the faces which are on the mesh, then that makes sense. Each face of my elements have 8 nodes (as they quadratic), 8*2100 = 16800.

I would have to check this again, but I think you have solved a very big problem (that has taken me hours and hours) for me! Thank you!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor