cancel
Showing results for 
Search instead for 
Did you mean: 

Getting Property type and material name associcated with property in NX.CAE?

Phenom
Phenom

To all

 

I am trying to access the type of the property ("PSHELL", "PSHEAR","PSOLID" etc...) and the name of the associated material (field Type: "PhysicalMaterial")

I can loop through the properties but accessing the data I want is proving elusive

 

Any hint on how I need ot modify the test code below?

 

Dim physicalPropTableCollec As CAE.PhysicalPropertyTableCollection = theCAEPart.PhysicalPropertyTables
Dim ListofPhysicalPropTable() As CAE.PhysicalPropertyTable = physicalPropTableCollec.ToArray

'TheLW.WriteLine("-Total number of properties to check: " & ListofPhysicalPropTable.Length.ToSTring)

For Each thephysicalproptable As CAE.PhysicalPropertyTable In ListofPhysicalPropTable

	Dim proptable As CAE.PropertyTable = thephysicalproptable.PropertyTable
	
		TheLW.WriteLine("-Name is: " & thephysicalproptable.Name)
		'TheLW.WriteLine("-DescriptorNeutralName is: " & thephysicalproptable.DescriptorNeutralName)
		'TheLW.WriteLine("-DescriptorSpecificName is: " & thephysicalproptable.DescriptorSpecificName)
		
		TheLW.WriteLine("-GetPropertyCount is: " & propTable.GetPropertyCount.ToString)
		
		
	'Search for the Type "PhysicalMaterial"	by looping through the proptable
	For i As Integer = 0 To propTable.GetPropertyCount - 1
			Dim propName As String = propTable.GetPropertyNameByIndex(i)
			theLW.WriteLine("    " & i.ToString & "): " & propName & " [type: " & propTable.GetPropertyType(propName).ToString & "]")
			
			
			
			'just a test !!
			Dim theNamedPropTable As CAE.NamedPropertyTable
			
			If propTable.GetPropertyType(propName).ToString = "PhysicalMaterial" Then
				TheLW.WriteLine("material found")
				TheLW.WriteLine("")
				theNamedPropTable = propTable.GetNamedPropertyTablePropertyValue(propName)
				thelw.WriteLine("    property table name: " & theNamedPropTable.Name)
				thelw.WriteLine("    label: " & theNamedPropTable.Label)
				thelw.WriteLine("    descriptor type is: " & theNamedPropTable.DescriptorType)
				thelw.WriteLine("    LanguageName is: " & theNamedPropTable.LanguageName)
				
				
			End if	
	Next i

Next thephysicalproptable

 

 

 

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)
5 REPLIES

Re: Getting Property type and material name associcated with property in NX.CAE?

Siemens Phenom Siemens Phenom
Siemens Phenom
        Dim physicalPropTableCollec As CAE.PhysicalPropertyTableCollection = theCAEPart.PhysicalPropertyTables
        Dim ListofPhysicalPropTable() As CAE.PhysicalPropertyTable = physicalPropTableCollec.ToArray

        'TheLW.WriteLine("-Total number of properties to check: " & ListofPhysicalPropTable.Length.ToSTring)

        For Each thephysicalproptable As CAE.PhysicalPropertyTable In ListofPhysicalPropTable

            Dim proptable As CAE.PropertyTable = thephysicalproptable.PropertyTable

            theLw.WriteLine("-Name is: " & thephysicalproptable.Name)
            'TheLW.WriteLine("-DescriptorNeutralName is: " & thephysicalproptable.DescriptorNeutralName)
            'TheLW.WriteLine("-DescriptorSpecificName is: " & thephysicalproptable.DescriptorSpecificName)

            theLw.WriteLine("-GetPropertyCount is: " & proptable.GetPropertyCount.ToString)


            'Search for the Type "PhysicalMaterial"	by looping through the proptable
            For i As Integer = 0 To proptable.GetPropertyCount - 1
                Dim propName As String = proptable.GetPropertyNameByIndex(i)
                theLw.WriteLine("    " & i.ToString & "): " & propName & " [type: " & proptable.GetPropertyType(propName).ToString & "]")



                'just a test !!
                Dim theNamedPropTable As CAE.NamedPropertyTable

                If proptable.GetPropertyType(propName).ToString = "PhysicalMaterial" And
                   propName = "material" Then
                    'theLw.WriteLine("material found")
                    'theLw.WriteLine("")
                    'theNamedPropTable = proptable.GetNamedPropertyTablePropertyValue(propName)
                    'theLw.WriteLine("    property table name: " & theNamedPropTable.Name)
                    'theLw.WriteLine("    label: " & theNamedPropTable.Label)
                    'theLw.WriteLine("    descriptor type is: " & theNamedPropTable.DescriptorType)
                    'theLw.WriteLine("    LanguageName is: " & theNamedPropTable.LanguageName)

                    Dim materialOptions As CAE.MaterialOptions = proptable.GetPhysicalMaterialPropertyValue(propName)
                    If materialOptions.MaterialInherited Then
                        theLw.WriteLine("        Material is inherited")
                    Else
                        Dim physMat As PhysicalMaterial = materialOptions.Material
                        theLw.WriteLine("        Material Name: " + physMat.Name)
                        theLw.WriteLine("        Material Type: " + physMat.GetMaterialType.ToString)

                    End If
                End If
            Next i

        Next thephysicalproptable

Re: Getting Property type and material name associcated with property in NX.CAE?

Phenom
Phenom

Thansk for that JimB. Not sure why it works but it does. So I'll take that. The logic is a bit confusing to my simple mind. Look over complicated to have to loop through all these properties. I am sure there must be a way of accessing the data directly if one knows one is looking for "material" and "PhysicalMaterial". Maybe a simple Try...Catch loop. Anyway. Your example of: materialOptions.MaterialInherited was very helpful.

 

I am trying to use/access the properties: DescriptorType &  LanguageName but neither work as properties of the CAE.PhysicalPropertyTable. I am still trying to do a check on the property type: PSHELL, PSOLID, etc. It should be "somewhere" as they appears if one creates a new property as shown below. Any ideas/suggestion?

 

Dim physPropTable1 As CAE.PhysicalPropertyTable
physPropTable1 = caePart1.PhysicalPropertyTables.CreatePhysicalPropertyTable("PSHELL", "NX NASTRAN - Structural", "NX NASTRAN", "PSHELL1", 10)

 

 

Thanks

Regards

 

 

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Getting Property type and material name associcated with property in NX.CAE?

Phenom
Phenom

Just realised. I overlooked a test and it kinda produces what I am after

 

For Each thephysicalproptable As CAE.PhysicalPropertyTable In ListofPhysicalPropTable
	TheLW.WriteLine("-Name is: " & sthePropTableName)
	TheLW.WriteLine("    descriptor type is: " & thephysicalproptable.DescriptorType)
		'will return something like
		'Shell Property
		'Cshear Property
		'Crod Property
Next

 

I believe "PSHELL", "PSOLID" etc are related to the FE solver being used (in my case NX.Nastran). Still ther emust be a way of getting this info!

I have modified my test code to check against "Shell Property" (rather than "PSHELL") and it seems to work

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Getting Property type and material name associcated with property in NX.CAE?

Siemens Phenom Siemens Phenom
Siemens Phenom

You are correct - the actual name of the exported card in the solver input deck is dependent on the solver being used.

 

If you really want to get at that data, you can use the solver syntax preview to get it:

 

For Each ppt As CAE.PhysicalPropertyTable In caePart.PhysicalPropertyTables

    theLw.WriteLine("Physical Property Table")
    theLw.WriteLine("  Name: " + ppt.Name)
    theLw.WriteLine("  Descriptor Type: " + ppt.DescriptorType)
    theLw.WriteLine("  Language Name: " + ppt.LanguageName)
    theLw.WriteLine("  Solver Name: " + ppt.SolverName)

    Dim pptSolverName As String = Nothing
    'theLw.WriteLine("  Solver Card:")
    Dim pptCardList As New List(Of String)(ppt.GetSolverCardSyntax())
    For Each pptCard As String In pptCardList
        'theLw.WriteLine("    " + pptCard)
        If Not pptCard.StartsWith("$") And pptSolverName = Nothing Then
            pptSolverName = pptCard.Substring(0, pptCard.IndexOf(" "))
        End If
    Next pptCard
    theLw.WriteLine("  Solver Card Name: " + pptSolverName)

    'theLw.WriteLine("  Properties:")
    Dim propTable As CAE.PropertyTable = ppt.PropertyTable
    For i As Integer = 0 To propTable.GetPropertyCount - 1

        Dim propName As String = propTable.GetPropertyNameByIndex(i)
        Dim propType As CAE.PropertyTable.PropertyType = propTable.GetPropertyType(propName)

        'theLw.WriteLine(String.Format("    {0}) {1} [{2}]", i, propName, propType))

        If propName = "material" Then

            theLw.WriteLine("Material Property Table")

            Dim materialName As String = Nothing
            Dim materialSolverName As String = Nothing

            Dim matOpt As CAE.MaterialOptions = propTable.GetPhysicalMaterialPropertyValue(propName)
            If matOpt.MaterialInherited Then
                materialName = "*Inherited*"
                materialSolverName = "*Inherited*"
            Else
                Dim material As PhysicalMaterial = matOpt.Material
                materialName = material.Name
                Dim matCardList As New List(Of String)(material.GetSolverCardSyntax())
                For Each matCard As String In matCardList
                    'theLw.WriteLine("    " + matCard)
                    If Not matCard.StartsWith("$") And materialSolverName = Nothing Then
                        materialSolverName = matCard.Substring(0, matCard.IndexOf(" "))
                    End If
                Next matCard

            End If

            theLw.WriteLine("  Name: " + materialName)
            theLw.WriteLine("  Solver Card Name: " + materialSolverName)

        End If

    Next i

    theLw.WriteLine(vbNewLine)

Next ppt

Re: Getting Property type and material name associcated with property in NX.CAE?

Phenom
Phenom

Thaks for the example. Will keep it for future use/reference

Set up my code as follows and it seems to work

 

Select Case thephysicalproptable.DescriptorType.ToString		
	Case 	"Shell Property", "Cshear Property", "Solid Property"
		bValidPropertyType = True
End Select

 

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)