Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Help with Journal to edit object display on solid bodies

Status
Not open for further replies.

NetDog

Marine/Ocean
Joined
Jun 7, 2013
Messages
10
Location
GB
Trying to create a journal to edit object display (chabge colour to a preset value) of any pre-selected solid bodies.
I have tried the below, but I still have to select "solid body" from the selection filters for it to work.
Any help greatly appreciated.

Code:
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

' ----------------------------------------------
'   Menu: Edit->Object Display...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Start")

theSession.SetUndoMarkName(markId1, "Class Selection Dialog")

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Class Selection")

theSession.DeleteUndoMark(markId2, Nothing)

Dim markId3 As Session.UndoMarkId
markId3 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Class Selection")

theSession.DeleteUndoMark(markId3, Nothing)

theSession.SetUndoMarkName(markId1, "Class Selection")

theSession.DeleteUndoMark(markId1, Nothing)

' ----------------------------------------------
'   Dialog Begin Edit Object Display
' ----------------------------------------------
' ----------------------------------------------
'   Dialog Begin Color
' ----------------------------------------------
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Edit Object Display")

Dim displayModification1 As DisplayModification
displayModification1 = theSession.DisplayManager.NewDisplayModification()

displayModification1.ApplyToAllFaces = False

displayModification1.ApplyToOwningParts = False

displayModification1.NewColor = 186

displayModification1.NewWidth = DisplayableObject.ObjectWidth.One

Dim objects1(0) As DisplayableObject
'Dim body1 As Body = CType(workPart.Bodies.FindObject("BLOCK(1)"), Body)

Dim body as DisplayableObject
Dim Resp as integer
Resp=SelectAnObject ("identify body",body)
objects1(0) = body
displayModification1.Apply(objects1)

displayModification1.Dispose()
' ----------------------------------------------
'   Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
Function SelectAnObject(prompt As String, _
               ByRef selObj As DisplayableObject) As Selection.Response
 
       Dim theUI As UI = UI.GetUI
       Dim cursor As Point3d
       Dim typeArray() As Selection.SelectionType = _
           {   Selection.SelectionType.All, _
               Selection.SelectionType.Faces, _
               Selection.SelectionType.Edges, _
               Selection.SelectionType.Features}
 
       Dim resp As Selection.Response = theUI.SelectionManager.SelectObject( _
               prompt, "Selection", _
               Selection.SelectionScope.AnyInAssembly, _
               False, typeArray, selobj, cursor)
 
       If resp = Selection.Response.ObjectSelected Or _
               resp = Selection.Response.ObjectSelectedByName Then
           Return Selection.Response.Ok
       Else
           Return Selection.Response.Cancel
       End If
 
    End Function

End Module
 
I now have this working by:

Code:
        Dim selectionMask_array(1) As Selection.MaskTriple
        With selectionMask_array(0)
            .Type = UFConstants.UF_solid_type
            .Subtype = 0
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
        End With

        response = ui.SelectionManager.SelectObjects(message, title, scope, _
                                         selectionAction, includeFeatures, _
                                     keepHighlighted, selectionMask_array, _
                                                      selectedObjects)

Not sure if this is the best method? But it works!

Thanks anyway!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top