cancel
Showing results for 
Search instead for 
Did you mean: 

How to Automatically Rename Multiple Meshes in NX

Community Manager Community Manager
Community Manager

 

 

Hi there, 

 

Here's a neat little post from Boris that illustrates how to quickly rename multiple meshes to the name of their mesh container. 

 

The problem occurs when you have a large number of meshes. NX gives the meshes an automatic name based on the mesh type with a counter (3d_mesh(X), 2d_mesh(X)) - so they are somehow difficult to identify if you have a large number of meshes in your analysis.

 

Boris created a quick little NX open script that helps address this problem, so thanks for that! The original question was mesh names in postview, but if you rename in the FEM file, they automatically will propagate to the post view too.

 

 

 

As always if you have any questions, feel free to contact me about this or any NX CAE related question


Thank you as always for participating in our community! 

 

Cheers,

Ganesh

 

_____________________________________________________________________________________

 

Please find below a .NET NX Open Skript that is automatically modifying all names of all meshes in the FEM and setting it to the name of the mesh container. So you can realize solution 1) of my previous post for all meshes in the .fem file.
If you select an appropriate name for the mesh container, you can find these names in post view.

 

This VB.Net program is provided "as is" without any warranty of any kind.

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.Annotations

Module Module1

    Sub Main()

        Dim theSession As Session = Session.GetSession()

        Dim MCols() As CAE.IMeshCollector
        Dim MCol As CAE.IMeshCollector

        Dim meshes() As CAE.Mesh
        Dim mesh As CAE.Mesh

        Dim counter As Integer

        Dim basePart As BasePart = theSession.Parts.BaseWork

        'check if basepart is a FEMPart. otherwise the Skript will not work
        If TypeOf basePart Is CAE.FemPart Then

            Dim femPart As CAE.FemPart = CType(basePart, CAE.FemPart)
            Dim fEModel As CAE.FEModel = CType(femPart.BaseFEModel(), CAE.FEModel)
            Dim meshManager As CAE.MeshManager = CType(fEModel.Find("MeshManager"), CAE.MeshManager)

            ' Loop all mesh Collectors
            MCols = meshManager.GetMeshCollectors()
            For Each MCol In MCols
                'get all meshes in the collector
                meshes = MCol.GetMeshes()
                ' Loop all meshes in collector
                counter = 0
                For Each mesh In meshes
                    counter = counter + 1
                    mesh.SetName(MCol.Name & "(" & counter & ")")
                Next
            Next
        Else
            MsgBox("ERROR: The Work Part has to be a FEM Part")
        End If
 End Sub
End Module

 

 

 

 


Regards,
Ganesh

Simcenter 3D Community Manager
Simulation and Test Solutions
Contributors