"Where used "option for a property in a FEM?

To all

Does anyone know if there is a way of checking if a property is used in a FEM?
I can extract the list of properties in a fem, see below, but cannot see anything obvious in the doc (probably because there isn't!). Only think I can think of is to loop trough all the meshes and check the name of the property associated with the mesh (ElementPropertyTable)

Thanks
Regards

Dim physPropTableList As New List(Of CAE.PhysicalPropertyTable)(theFEMPart.PhysicalPropertyTables.ToArray)
For each Item As CAE.PhysicalPropertyTable In physPropTableList
theLW.WriteLine("--Property name is: " + item.Name)
Next Item

I don't know of any such "where used" function for such properties; though I'd love to be pleasantly surprised to learn of one.

Thanks. Did a bit od digging around and it looks like one may need a loop to get the property associated with each meshcollector

Scope may look like
Get list of name of all the properties defined – List A
For each item in ‘List A’
Get all the meshes collector
For each theMeshColl
Get property table associated with mesh collector and get name (propname)
If propname = item Then
count+=1
Exit For ‘No need to carry on the loop as the properties is used at least once
End If
Next

If count=0 Then .addtodeletelist(item)
Next item

Thanks
Regards

Ok. 1st pass and some minor success. Below is a test code to loop through mesh collectors and try to get the property associated with each mesh collector.
Problem: I am not getting "anything" out of ElementPropertyTable()

Can anyone enlighten me on how to access the info "contained" in ElementPropertyTable()?

Thanks
Regards

Dim theFEModel As CAE.FEModel = CType(theFEMPart.BaseFEModel(), CAE.FEModel)
Dim theMeshManager As CAE.MeshManager = CType(theFEModel.Find("MeshManager"), CAE.MeshManager)

'Get all meshes in the collector. GetMeshes() returns the mesh collector associated meshes
For Each myMeshCollector As CAE.IMeshCollector In theMeshManager.GetMeshCollectors()
meshes = myMeshCollector.GetMeshes()
Dim propTable As CAE.PropertyTable = myMeshCollector.ElementPropertyTable()

theLW.WriteLine("Mesh Collector Name: " + myMeshCollector.Name)
theLW.WriteLine("property table name: " & propTable.Name)

Next myMeshCollector 'mesh collector

1st

Thanks
Regards

The code below may get you started; make the FEM part the work (or displayed) part before running the journal.

Are you looking for a particular property?

Option Strict Off
Imports System
Imports NXOpen

Module Module1

Sub Main()

Dim theSession As Session = Session.GetSession()
Dim lw As ListingWindow = theSession.ListingWindow
lw.Open()

Dim femPart As CAE.FemPart
Try
femPart = CType(theSession.Parts.BaseWork, CAE.FemPart)
Catch ex As Exception
MsgBox("Not a FEM part")
Return
End Try

Const undoMarkName As String = "report meshes"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)

lw.WriteLine("Mesh Collectors:")
For Each theMeshCollector As CAE.MeshCollector In femPart.BaseFEModel.MeshManager.GetMeshCollectors
lw.WriteLine(" name: " & theMeshCollector.Name)
lw.WriteLine(" type: " & theMeshCollector.CollectorType)

Dim propTable As CAE.PropertyTable = theMeshCollector.ElementPropertyTable
lw.WriteLine(" properties:")
For i As Integer = 0 To propTable.GetPropertyCount - 1
Dim propName As String = propTable.GetPropertyNameByIndex(i)
lw.WriteLine(" " & i.ToString & "): " & propName & " [type: " & propTable.GetPropertyType(propName).ToString & "]")

Dim theNamedPropTable As CAE.NamedPropertyTable
If propTable.GetPropertyType(propName) = CAE.PropertyTable.PropertyType.NamedPropertyTable Then
theNamedPropTable = propTable.GetNamedPropertyTablePropertyValue(propName)
lw.WriteLine(" property table name: " & theNamedPropTable.Name)
lw.WriteLine(" label: " & theNamedPropTable.Label)
For j As Integer = 0 To theNamedPropTable.PropertyTable.GetPropertyCount - 1
Dim ptPropName As String = theNamedPropTable.PropertyTable.GetPropertyNameByIndex(j)
lw.WriteLine(" property name: " & ptPropName)
lw.WriteLine(" property type: " & theNamedPropTable.PropertyTable.GetPropertyType(ptPropName).ToString)

Next

End If

Dim materialOptions As CAE.MaterialOptions
Try
materialOptions = propTable.GetPhysicalMaterialPropertyValue(propName)
lw.WriteLine(" ID: " & materialOptions.Material.GetId.ToString)
lw.WriteLine(" category: " & materialOptions.Material.GetCategory)
lw.WriteLine(" description: " & materialOptions.Material.GetDescription)

Catch ex As Exception

End Try

Next

lw.WriteLine(" contains meshes:")

For Each theMesh As CAE.Mesh In theMeshCollector.GetMeshes

lw.WriteLine(" name: " & theMesh.Name)
lw.WriteLine(" type: " & theMesh.GetType.ToString)
lw.WriteLine(" descriptor name: " & theMesh.ElementPropertyTable.DescriptorSpecificName)
'lw.WriteLine(" property count: " & theMesh.ElementPropertyTable.GetPropertyCount.ToString)
lw.WriteLine("")

Next

Next

lw.Close()

End Sub

Public Function GetUnloadOption(ByVal dummy As String) As Integer

'Unloads the image when the NX session terminates
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination

End Function

End Module

Thanks for that. Much appreciated. No particular property being sought. Just a check that is used

I have (obviously) kept your kindly provided code for future and lifted the few lines of code I needed. It seems to work but will play with it a bit later.

Thanks
Regards

For Each Item As CAE.PhysicalPropertyTable In physPropTableList
counter=0
For Each theMeshCollector As CAE.MeshCollector In theMeshManager.GetMeshCollectors

Dim propTable As CAE.PropertyTable = theMeshCollector.ElementPropertyTable
Dim theNamedPropTable As CAE.NamedPropertyTable
Dim propName As String = propTable.GetPropertyNameByIndex(0)
theNamedPropTable = propTable.GetNamedPropertyTablePropertyValue(propName)
If theNamedPropTable.Name = Item.Name Then counter +=1
Next theMeshCollector

If counter = 0 Then Dim nErrs1 As Integer = theSession.UpdateManager.AddToDeleteList(Item)
Next Item

Thanks
Regards