Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations SSS148 on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assign render materials using Journal ?

Status
Not open for further replies.

Toost

Mechanical
Jan 18, 2011
2,993
I am posting this question on this forum also, hoping to find new readers... :)

Any tips on workarounds to assign , say "steel", to a body/all bodies in the work part using a journal ?
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 , other methods, to assign render materials are welcome.
The drag-drop from the materials palette does not record in the journal.
- Possible to import .lwa files ? Assign material from ?
- Cowski ?



Regards,
Tomas
 
Replies continue below

Recommended for you

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

To open an LWA material library use

Code:
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
Code:
Public Sub CopyLwaArchiveMaterialToWorkPart (Byval material_name As String, ByRef material_tag As Tag)

Then use the assign material function
Code:
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.
Code:
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


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor