nxexplorer
Mechanical
- Jun 23, 2010
- 84
I need help to create NX Journal (VB) for Assigning the Material in the workpart, where the material's name comes from the existing value of a String Attribute which is also similar to the one of Material's name in the Material Library.
'====================================================================
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim markId1 As Session.UndoMarkId
Dim physicalMaterialListBuilder1 As PhysMat.PhysicalMaterialListBuilder
Dim physicalMaterialAssignBuilder1 As PhysMat.PhysicalMaterialAssignBuilder
Dim id1 As Session.UndoMarkId
Dim markId3 As Session.UndoMarkId
Dim physicalMaterial1 As PhysicalMaterial
Dim markId2 As Session.UndoMarkId
Dim str_pre_matl As String = workPart.GetStringAttribute( "preMATL" )
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
physicalMaterialListBuilder1 = workPart.MaterialManager.PhysicalMaterials.CreateListBlockBuilder()
physicalMaterialAssignBuilder1 = workPart.MaterialManager.PhysicalMaterials.CreateMaterialAssignBuilder()
theSession.SetUndoMarkName(markId1, "Assign Material Dialog")
id1 = theSession.GetNewestUndoMark(Session.MarkVisibility.AnyVisibility)
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Assign Material")
theSession.DeleteUndoMark(markId2, Nothing)
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Assign Material")
physicalMaterial1 = workPart.MaterialManager.PhysicalMaterials.LoadFromNxmatmllibrary("&str_pre_matl&")
physicalMaterial1.AssignToAllBodies()
theSession.DeleteUndoMark(markId3, Nothing)
theSession.SetUndoMarkName(id1, "Assign Material")
physicalMaterialAssignBuilder1.Destroy()
physicalMaterialListBuilder1.Destroy()
End Sub
End Module
'====================================================
Any suggest is very much appreciated.
Best Regards,
Maryadi
'====================================================================
Option Strict Off
Imports System
Imports NXOpen
Module NXJournal
Sub Main (ByVal args() As String)
Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
Dim markId1 As Session.UndoMarkId
Dim physicalMaterialListBuilder1 As PhysMat.PhysicalMaterialListBuilder
Dim physicalMaterialAssignBuilder1 As PhysMat.PhysicalMaterialAssignBuilder
Dim id1 As Session.UndoMarkId
Dim markId3 As Session.UndoMarkId
Dim physicalMaterial1 As PhysicalMaterial
Dim markId2 As Session.UndoMarkId
Dim str_pre_matl As String = workPart.GetStringAttribute( "preMATL" )
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")
physicalMaterialListBuilder1 = workPart.MaterialManager.PhysicalMaterials.CreateListBlockBuilder()
physicalMaterialAssignBuilder1 = workPart.MaterialManager.PhysicalMaterials.CreateMaterialAssignBuilder()
theSession.SetUndoMarkName(markId1, "Assign Material Dialog")
id1 = theSession.GetNewestUndoMark(Session.MarkVisibility.AnyVisibility)
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Assign Material")
theSession.DeleteUndoMark(markId2, Nothing)
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Assign Material")
physicalMaterial1 = workPart.MaterialManager.PhysicalMaterials.LoadFromNxmatmllibrary("&str_pre_matl&")
physicalMaterial1.AssignToAllBodies()
theSession.DeleteUndoMark(markId3, Nothing)
theSession.SetUndoMarkName(id1, "Assign Material")
physicalMaterialAssignBuilder1.Destroy()
physicalMaterialListBuilder1.Destroy()
End Sub
End Module
'====================================================
Any suggest is very much appreciated.
Best Regards,
Maryadi