NutAce
Mechanical
- Apr 22, 2010
- 1,192
Hi All,
I found this piece of code on here which I tweaked to my needs..
Originally it changed the body color to red but I tweaked it to change the line width to 0,5 mm
Problem is that the type filter is wrong. I would like it to be set to solid body but that part isn't working.
What I changed is below.
this gives me the following error...
UFConstants is not declared, and after that a bunch of other errors but I would like to tackle this one first...
What did I do wrong here?
Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
HPZ420 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz, 32 Gb Win7 64B
Nvidea Quadro4000 2048MB DDR5
HP Zbook15
Intel(R) Core(TM) i7-4800MQ
CPU @ 2.70 GHz Win7 64b
Nvidia K1100M 2048 MB DDR5
I found this piece of code on here which I tweaked to my needs..
Originally it changed the body color to red but I tweaked it to change the line width to 0,5 mm
Problem is that the type filter is wrong. I would like it to be set to solid body but that part isn't working.
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...
' ----------------------------------------------
' ----------------------------------------------
' Dialog Begin Edit Object Display
' ----------------------------------------------
' ----------------------------------------------
' Dialog Begin linewidth
' ----------------------------------------------
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.NewWidth = DisplayableObject.ObjectWidth.Five
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
REM Dim typeArray() As Selection.SelectionType = _
REM { Selection.SelectionType.All, _
REM Selection.SelectionType.Faces, _
REM Selection.SelectionType.Edges, _
REM Selection.SelectionType.Features}
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)
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
What I changed is below.
Code:
Function SelectAnObject(prompt As String, _
ByRef selObj As DisplayableObject) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim cursor As Point3d
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)
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
this gives me the following error...
UFConstants is not declared, and after that a bunch of other errors but I would like to tackle this one first...
What did I do wrong here?
Ronald van den Broek
Senior Application Engineer
Winterthur Gas & Diesel Ltd
NX9 / TC10.1.2
HPZ420 Intel(R) Xeon(R) CPU E5-1620 0 @ 3.60GHz, 32 Gb Win7 64B
Nvidea Quadro4000 2048MB DDR5
HP Zbook15
Intel(R) Core(TM) i7-4800MQ
CPU @ 2.70 GHz Win7 64b
Nvidia K1100M 2048 MB DDR5