cancel
Showing results for 
Search instead for 
Did you mean: 

Access Mesh Type of an element (1D, 2D ...)

Pioneer
Pioneer

Hi,

I would like to verify the mesh of a specific element (1D, or 2D or 3D) in NX Open (VBA code).

The idea would consist in implementing different actions depending on the fact that the element is a 1D mesh, or a 2D mesh.

To do so, I decided to proceed with this script :

----------------------------------------------------------------------------------------------------------------------------
1                 Dim groupItems() As TaggedObject = caegroup.GetEntities

2                 For Each grpItem As Taggedobject In groupItems
3                     Dim group_mesh As CAE.Mesh = CAE.FEElement.Mesh(grpItem)
4                     Dim group_test As CAE.Mesh1D = TryCast(group_mesh, CAE.Mesh1D)

5                     If group_test Is Nothing Then 
6                         ' [ACTIONS]
7                     Else 
8                         '[ACTIONS] 
9                     End If

10               Next grpItem

-------------------------------------------------------------------------------------------------------------------

However, I have an error occured line 3 : How can I use this command correctly ?

The idea would be to access the mesh type of the element, and then verify if it is a 1D mesh (beam element) or a 2D element (Shell element) ...

Thanks

Best Regards,

Baptiste

6 REPLIES

Re: Access Mesh Type of an element (1D, 2D ...)

Siemens Phenom Siemens Phenom
Siemens Phenom

CAE.FEElement.Mesh is a property that returns the mesh that contains the FEElement. You need to call it on an existing CAE.FEElement object. It does not take any arguments.

 

Re: Access Mesh Type of an element (1D, 2D ...)

Pioneer
Pioneer

Ok, thanks for your help, so what would be the best way to compare element type (1D, 2D) ?

Is there a command to check if the element is a 1D beam or a 2D shell ?

Re: Access Mesh Type of an element (1D, 2D ...)

Siemens Phenom Siemens Phenom
Siemens Phenom

You can use the CAE.FEElement properties Shape or NumberOfCornerNodes or you could get the mesh and determine it's type (Mesh1d, Mesh2d, etc.)

Re: Access Mesh Type of an element (1D, 2D ...)

Pioneer
Pioneer

The problem is I don't know how to use correctly those command :

CAE.FEElement. NumberOfCornerNodes() or CAE.FEElement.Mesh()

Could you give me just one example to write it properly ?   

Re: Access Mesh Type of an element (1D, 2D ...)

Pioneer
Pioneer

With your advice, I found out how to use it properly ! Thanks a lot !

Baptiste

Re: Access Mesh Type of an element (1D, 2D ...)

Phenom
Phenom
For Each obj As TaggedObject In theCAEGroup.GetEntities()

	'theLW.WriteLine("object type: " & obj.GetType.ToString)

	If TypeOf (obj) Is CAE.FEElement Then
		Dim theElement As CAE.FEElement = obj
		If theElement.Shape = CAE.ElementTypes.Shape.Line Then 'integer value = 1 
			'do something
		Else
			'do something else
		End if
	Else
		'do nothing
	End if
Next obj
Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)