cancel
Showing results for 
Search instead for 
Did you mean: 

assign NX render materials using journal ?

Siemens Genius Siemens Genius
Siemens Genius

Any tips on workarounds to assign , say "steel",  to a body/all bodies in the work part ?

 Note: Render materials. The "engineering materials" are no problem to assign using a journal.

 

The render materials palette (NX10) does not seem to register journal recording.

any workarounds to assign render materials are welcome.

 

 

Regards,

 Tomas

1 REPLY

Re: assign NX render materials using journal ?

Experimenter
Experimenter

Yes it seems to be possible, look into the User Function Display library (nxopen.uf.ufdisp),

 To open an LWA material library use

Public Sub OpenLwaArchiveMaterialsLibrary(lwa_archive_library_name As String) 

where the input is the full path to the lwa library.

 

It is then possible to copy a material from the library to work part, which gives the material_tag

Public Sub CopyLwaArchiveMaterialToWorkPart (Byval material_name As String, ByRef material_tag As Tag)

 Then use the assign material function

NXOpen.UF.UFDisp.AssignMaterial(ByVal material_tag As tag, ByVal object_tag As tag)

but make sure that the object_tag is of the type UF_solid_type, UF_solid_face_subtype or UF_faceted_model_type.

 

The only example for studio materials I could find on GTAC shows how one can use cycle objects to find all materials in a part.

Option Strict Off
Imports System
Imports System.Collections
Imports NXOpen
Imports NXOpen.UF
Module report_studio_materials_in_part
Dim theSession As Session = Session.GetSession()
Dim ufs As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main
Dim materials As New SortedList()
get_part_materials(materials)
lw.Open()
If materials.Count = 0 Then
lw.WriteLine("Part has no materials applied.")
Else
For Each material As DictionaryEntry in materials
lw.WriteLine("Part Material " + material.Key.ToString() + " is " + material.Value)
Next
End If
End Sub
Function get_part_materials(ByRef materials As SortedList)
Dim matTag As Tag = Tag.Null
ufs.Obj.CycleObjsInPart ( theSession.Parts.Work.Tag, _
UFConstants.UF_material_type, _
matTag)
While matTag <> Tag.Null
Dim matName As String = Nothing
ufs.Obj.AskName(matTag, matName)
materials.Add(matTag, matName)
ufs.Obj.CycleObjsInPart ( theSession.Parts.Work.Tag, _
UFConstants.UF_material_type, _
matTag)
End While
End Function
End Module