Check if a mesh is "lockable"?

To all

I'd like to know what would be the best way of checking if a mesh is "lockable"? People using the simulation module to create FEMs will know that a "manual" mesh cannot be locked. Below is an extract of a code which loops all through the mesh and lock them

As manual mesh cannot be locked the line: If bMeshStatusCheck = False is always executed and the line to the listing window (info to the user) will always say that the program is locking the mesh when in fact it isn't (it does nothing)

I am looking for a way of skipping the non-lockable mesh. Any ideas/suggestions?

Thanks
Regards
JXB

For Each mymesh In meshes
bMeshStatusCheck = mymesh.LockStatus 'get the status of the mesh
If bMeshStatusCheck = False Then
mymesh.LockStatus=True
theLW.WriteLine ("-Locking mesh: " & mymesh.Name)
End if
Next mymesh

Does an error occur if you attempt to lock a "non-lockable" mesh?

If so, you could use a Try block to trap the error and take suitable action.

no error at all. Code just loops through all the meshes, states that its locking it (if not locked) and that's it. Even though it can't! it's just that the message in the LW is misleading snd I'd like to "fix" it

Thanks
Regards

Going through the doc I thought that maybe by getting the "mesh recipe" theMesh.GetType.ToString one might be able to see/check what is a "auto" mesh (i.e. creating a mesh applied to geometry) and what is a mesh created manually (Element Create, Extrude, Revolve,3D sweep, Translate, Reflect, Project). Unfortunately I think the option GetType returns something like: NXOpen.CAE.Mesh3d

I cannot find any other info on the mesh recipe. Does anyone know if there is such thing?

Thanks
Regards

Thanks
Regards

Just came across the possible option. It seems that each mesh type (mesh 0d, mesh1d,etc) have a sub-types. Take in mesh2d as an example, it seems that there are three sub type (see below). How do I get the sub types (DependentMesh, MappedMesh, Mesh2dFree)? I'd like to see if I can do the test "lockable" on this sub type. Having said that for all the sub type there is an property 'LockStatus' so it might be a dead end

NXOpen.CAE.Mesh
Mesh0d
Mesh1d
Mesh2d
DependentMesh
MappedMesh
Mesh2dFree
Mesh3d
MeshFollower
PrimitiveMesh
SweptMesh

Thanks
Regards

Is the lock status reported correctly if you query it directly after attempting to set the status? In other words, when you try "mymesh.LockStatus = True", but the mesh is not lockable, if you query "mymesh.LockStatus" in the next line of code, will it return True or False?

For Each mymesh In meshes
bMeshStatusCheck = mymesh.LockStatus 'get the status of the mesh
If bMeshStatusCheck = False Then
theLW.WriteLine(" Attempting to lock mesh: " & mymesh.Name)
mymesh.LockStatus = True
If mymesh.LockStatus = True Then
theLW.WriteLine(" mesh successfully locked")
Else
theLW.WriteLine(" mesh could not be locked")
End If
End If
Next mymesh

Just tested the suggestion and false is returned for "manual" mesh after setting the lock status to True (True=False !). I have therefore added the extra line/check and move the counter and user displayed line in the LW in that check. Seems to work

Thanks for the suggestion

Thanks
Regards