DELETE Physical Property in Physical Properties (NX CAE)

Hi

Physical property is not set forth in Mesh Collectors(shell property). I want to search for and delete them. But, I don't know with the journal.

Please help me

Is the code above for NX?
It looks more like it is creating power point slides rather than working with NX models...

It is indeed hard to find the Physical property table from the mesh. I use the Meshbuilder to edit a mesh, get the propertytable and then from that I think the GetNamedPropertyTablePropertyValue("Mesh Collector") should work (see below)


Dim meshManager1 As NXOpen.CAE.MeshManager = CType(fEModel.Find("MeshManager"), NXOpen.CAE.MeshManager)
Dim mesh2dBuilder1 As NXOpen.CAE.Mesh2dBuilder mesh2dBuilder1 = meshManager1.CreateMesh2dBuilder(MeshToEdit)
mesh2dBuilder1.PropertyTable.GetNamedPropertyTablePropertyValue("Mesh Collector")

Thanks frvanhee.

I developed a project
and want to simplify the code, but do not fully understand. looking forward to the help from everyone.

Option Strict Off
Imports System
Imports NXOpen
Imports Microsoft
Imports NXOpenUI
Imports System.Windows.Forms
Module Module1

Public theSession As Session = Session.GetSession()
Public workFemPart As NXOpen.CAE.FemPart = CType(theSession.Parts.BaseWork, NXOpen.CAE.FemPart)
Public lw As ListingWindow = theSession.ListingWindow
Public theUI As UI = UI.GetUI()
Public objects1(0) As NXOpen.TaggedObject
Public mesh1 As CAE.Mesh = CType(theUI.SelectionManager.GetSelectedTaggedObject(0), NXOpen.CAE.Mesh)
Public Meshcollector As CAE.IMeshCollector
Public caePart1 As NXOpen.CAE.CaePart = CType(workFemPart, NXOpen.CAE.CaePart)
Public physicalPropertyTable2 As NXOpen.CAE.PhysicalPropertyTable
Public theNamedPropTable As CAE.NamedPropertyTable

Sub Main()
Dim myDialog As New TEST
myDialog.ShowDialog()

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

Public Class TEST
Private myAttributeTitle As String = "Input IDs Material"
Sub idou()
For Each theMeshCollector As CAE.MeshCollector In workFemPart.BaseFEModel.MeshManager.GetMeshCollectors
If theMeshCollector.Name = physicalPropertyTable2.Name Then
Dim fEModel2 As NXOpen.CAE.FEModel = CType(workFemPart.FindObject("FEModel"), NXOpen.CAE.FEModel)

Dim meshManager2 As NXOpen.CAE.MeshManager = CType(fEModel2.Find("MeshManager"), NXOpen.CAE.MeshManager)

Dim id1 As NXOpen.Session.UndoMarkId
id1 = theSession.NewestVisibleUndoMark

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(id1)

meshManager2.DragNDropMesh(CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.CAE.Mesh), mesh1.MeshCollector, theMeshCollector)
End If
Next
End Sub
Sub idou2()
For Each theMeshCollector As CAE.MeshCollector In workFemPart.BaseFEModel.MeshManager.GetMeshCollectors
If theMeshCollector.Name = physicalPropertyTable2.Name Then
Dim fEModel2 As NXOpen.CAE.FEModel = CType(workFemPart.FindObject("FEModel"), NXOpen.CAE.FEModel)

Dim meshManager2 As NXOpen.CAE.MeshManager = CType(fEModel2.Find("MeshManager"), NXOpen.CAE.MeshManager)

Dim id1 As NXOpen.Session.UndoMarkId
id1 = theSession.NewestVisibleUndoMark

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(id1)

meshManager2.DragNDropMesh(CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.CAE.Mesh), mesh1.MeshCollector, theMeshCollector)
End If
Next
End Sub

Sub SetthinShell()
physicalPropertyTable2 = caePart1.PhysicalPropertyTables.CopyPhysicalPropertyTable(theNamedPropTable)

Dim markId3 As NXOpen.Session.UndoMarkId
markId3 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Start")

Dim propertyTable1 As NXOpen.CAE.PropertyTable
propertyTable1 = physicalPropertyTable2.PropertyTable

' ----------------------------------------------
' Dialog Begin PSHELL
' ----------------------------------------------
Dim markId6 As NXOpen.Session.UndoMarkId
markId6 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, Nothing)

physicalPropertyTable2.SetName(theNamedPropTable.Name & "_MAT" & TextBox1.Text)

' --------------------------------------------------------------------------------------------
Dim count As Integer
count = 0
Dim physicalMaterial1 As NXOpen.PhysicalMaterial
For Each physicalMaterialListBuilder1 As PhysicalMaterial In workFemPart.MaterialManager.PhysicalMaterials.GetUsedMaterials
If TextBox1.Text = physicalMaterialListBuilder1.GetId Then

physicalMaterial1 = physicalMaterialListBuilder1
propertyTable1.SetMaterialPropertyValue("material", False, physicalMaterial1)
count += 1

End If
Next
propertyTable1.SetTablePropertyWithoutValue("bending material")

propertyTable1.SetTablePropertyWithoutValue("transverse shear material")

propertyTable1.SetTablePropertyWithoutValue("membrane-bending coupling material")

Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(markId6)

theSession.SetUndoMarkName(markId3, "PSHELL")

theSession.DeleteUndoMark(markId3, Nothing)

Dim markId7 As NXOpen.Session.UndoMarkId
markId7 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Start")

Dim fEModel1 As NXOpen.CAE.FEModel = CType(workFemPart.FindObject("FEModel"), NXOpen.CAE.FEModel)

Dim meshManager1 As NXOpen.CAE.MeshManager = CType(fEModel1.Find("MeshManager"), NXOpen.CAE.MeshManager)

Dim nullNXOpen_CAE_MeshCollector As NXOpen.CAE.MeshCollector = Nothing

Dim meshCollectorBuilder2 As NXOpen.CAE.MeshCollectorBuilder
meshCollectorBuilder2 = meshManager1.CreateCollectorBuilder(nullNXOpen_CAE_MeshCollector, "ThinShell")

meshCollectorBuilder2.CollectorName = "ThinShell(4)"
' ----------------------------------------------
' Dialog Begin Mesh Collector
' ----------------------------------------------
Dim markId9 As NXOpen.Session.UndoMarkId
markId9 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Mesh Collector")

meshCollectorBuilder2.CollectorName = physicalPropertyTable2.Name

theSession.DeleteUndoMark(markId9, Nothing)

Dim markId10 As NXOpen.Session.UndoMarkId
markId10 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Invisible, "Mesh Collector")

meshCollectorBuilder2.PropertyTable.SetNamedPropertyTablePropertyValue("Shell Property", physicalPropertyTable2)

Dim nXObject2 As NXOpen.NXObject
nXObject2 = meshCollectorBuilder2.Commit()

theSession.DeleteUndoMark(markId10, Nothing)

meshCollectorBuilder2.Destroy()
End Sub
Private Sub OK_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OK_Button.Click
workFemPart.SetAttribute(myAttributeTitle, TextBox1.Text)
lw.Open()
objects1(0) = mesh1
Dim propTable As CAE.PropertyTable = mesh1.MeshCollector.ElementPropertyTable
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)

If propTable.GetPropertyType(propName) = CAE.PropertyTable.PropertyType.NamedPropertyTable Then
theNamedPropTable = propTable.GetNamedPropertyTablePropertyValue(propName)

' ----------------------------------------------
Dim physicalPropTableCollec As CAE.PhysicalPropertyTableCollection = workFemPart.PhysicalPropertyTables
Dim Listofproperties() As CAE.PhysicalPropertyTable = physicalPropTableCollec.ToArray
Dim counter As Integer
counter = 0

For Each phyprotable As CAE.PhysicalPropertyTable In Listofproperties
If theNamedPropTable.Name & "_MAT" & TextBox1.Text = phyprotable.Name Then
For Each theMeshCollector As CAE.MeshCollector In workFemPart.BaseFEModel.MeshManager.GetMeshCollectors
Dim propTable2 As CAE.PropertyTable = theMeshCollector.ElementPropertyTable
Dim theNamedPropTable2 As CAE.NamedPropertyTable
For j As Integer = 0 To propTable2.GetPropertyCount - 1
Dim propName2 As String = propTable2.GetPropertyNameByIndex(j)
If propTable2.GetPropertyType(propName2) = CAE.PropertyTable.PropertyType.NamedPropertyTable Then
theNamedPropTable2 = propTable.GetNamedPropertyTablePropertyValue(propName2)
'If phyprotable.Name = theMeshCollector.Name Then
For Each theMesh As CAE.Mesh In theMeshCollector.GetMeshes
If theMesh.MeshCollector.Name = theMeshCollector.Name And phyprotable.Name <> theMeshCollector.Name Then

Dim showOnlyBuilder1 As NXOpen.CAE.ShowOnlyBuilder
showOnlyBuilder1 = caePart1.ShowHideMgr.CreateShowOnlyBuilder()

Dim added1 As Boolean
added1 = showOnlyBuilder1.Selection.Add(objects1)
Dim added2 As Boolean
added2 = showOnlyBuilder1.Selection.Add(theMesh)

Dim nXObject1 As NXOpen.NXObject
nXObject1 = showOnlyBuilder1.Commit()

showOnlyBuilder1.Selection.Clear()

showOnlyBuilder1.Destroy()

End If

Next
If phyprotable.Name = theMeshCollector.Name Then
Dim fEModel2 As NXOpen.CAE.FEModel = CType(workFemPart.FindObject("FEModel"), NXOpen.CAE.FEModel)

Dim meshManager2 As NXOpen.CAE.MeshManager = CType(fEModel2.Find("MeshManager"), NXOpen.CAE.MeshManager)

Dim id1 As NXOpen.Session.UndoMarkId
id1 = theSession.NewestVisibleUndoMark

Dim nErrs2 As Integer
nErrs2 = theSession.UpdateManager.DoUpdate(id1)

meshManager2.DragNDropMesh(CType(theUI.SelectionManager.GetSelectedObject(0), NXOpen.CAE.Mesh), mesh1.MeshCollector, theMeshCollector)
End If
'End If
End If
Next
Next
lw.WriteLine(" ThinShell が有りました : ")
counter += 1
End If
Next
If counter = 0 Then

Call SetthinShell()
Call idou()

End If
End If

Next i
lw.Close()
Me.DialogResult = System.Windows.Forms.DialogResult.OK
Me.Close()
End Sub

Private Sub Cancel_Button_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Cancel_Button.Click
Me.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Close()
End Sub

Private Sub Dialog1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

Try
TextBox1.Text = workFemPart.GetStringAttribute(myAttributeTitle)
Catch ex As ApplicationException
'attribute does not exist
TextBox1.Text = ""
End Try

Label1.Text = myAttributeTitle

End Sub
End Class
_
Partial Class TEST
Inherits System.Windows.Forms.Form

'Form overrides dispose to clean up the component list.
_
Protected Overrides Sub Dispose(ByVal disposing As Boolean)
Try
If disposing AndAlso components IsNot Nothing Then
components.Dispose()
End If
Finally
MyBase.Dispose(disposing)
End Try
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
_
Private Sub InitializeComponent()
Me.TableLayoutPanel1 = New System.Windows.Forms.TableLayoutPanel()
Me.OK_Button = New System.Windows.Forms.Button()
Me.Cancel_Button = New System.Windows.Forms.Button()
Me.Label1 = New System.Windows.Forms.Label()
Me.TextBox1 = New System.Windows.Forms.TextBox()
Me.TableLayoutPanel1.SuspendLayout()
Me.SuspendLayout()
'
'TableLayoutPanel1
'
Me.TableLayoutPanel1.Anchor = CType((System.Windows.Forms.AnchorStyles.Bottom Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.TableLayoutPanel1.ColumnCount = 2
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.ColumnStyles.Add(New System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.Controls.Add(Me.OK_Button, 0, 0)
Me.TableLayoutPanel1.Controls.Add(Me.Cancel_Button, 1, 0)
Me.TableLayoutPanel1.Location = New System.Drawing.Point(277, 122)
Me.TableLayoutPanel1.Name = "TableLayoutPanel1"
Me.TableLayoutPanel1.RowCount = 1
Me.TableLayoutPanel1.RowStyles.Add(New System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 50.0!))
Me.TableLayoutPanel1.Size = New System.Drawing.Size(146, 29)
Me.TableLayoutPanel1.TabIndex = 0
'
'OK_Button
'
Me.OK_Button.Anchor = System.Windows.Forms.AnchorStyles.None
Me.OK_Button.Location = New System.Drawing.Point(3, 3)
Me.OK_Button.Name = "OK_Button"
Me.OK_Button.Size = New System.Drawing.Size(67, 23)
Me.OK_Button.TabIndex = 0
Me.OK_Button.Text = "OK"
'
'Cancel_Button
'
Me.Cancel_Button.Anchor = System.Windows.Forms.AnchorStyles.None
Me.Cancel_Button.DialogResult = System.Windows.Forms.DialogResult.Cancel
Me.Cancel_Button.Location = New System.Drawing.Point(76, 3)
Me.Cancel_Button.Name = "Cancel_Button"
Me.Cancel_Button.Size = New System.Drawing.Size(67, 23)
Me.Cancel_Button.TabIndex = 1
Me.Cancel_Button.Text = "Cancel"
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(12, 52)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(134, 26)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Attribute:"
Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleRight
'
'TextBox1
'
Me.TextBox1.Location = New System.Drawing.Point(152, 56)
Me.TextBox1.Name = "TextBox1"
Me.TextBox1.Size = New System.Drawing.Size(234, 20)
Me.TextBox1.TabIndex = 2
'
'Dialog1
'
Me.AcceptButton = Me.OK_Button
Me.AutoScaleDimensions = New System.Drawing.SizeF(8.0!, 18.0!)
Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
Me.CancelButton = Me.Cancel_Button
Me.ClientSize = New System.Drawing.Size(435, 163)
Me.Controls.Add(Me.TextBox1)
Me.Controls.Add(Me.Label1)
Me.Controls.Add(Me.TableLayoutPanel1)
Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
Me.MaximizeBox = False
Me.MinimizeBox = False
Me.Name = "Dialog1"
Me.ShowInTaskbar = False
Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent
Me.Text = "FEMFAT"
Me.TableLayoutPanel1.ResumeLayout(False)
Me.ResumeLayout(False)
Me.PerformLayout()

End Sub
Friend WithEvents TableLayoutPanel1 As System.Windows.Forms.TableLayoutPanel
Friend WithEvents OK_Button As System.Windows.Forms.Button
Friend WithEvents Cancel_Button As System.Windows.Forms.Button
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

End Class

huyen

Hello Huyen,

Let's start with first things first. What do you want your project to do?

regards,
Frederik