Changing body Line widths Journaling VB
Changing body Line widths Journaling VB
(OP)
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?
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 --> vb
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 --> vb
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





RE: Changing body Line widths Journaling VB
UFConstants lives in the NXOpen.UF namespace. To fix this particular error, you can do either of the following:
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UFOR
CODE
With selectionMask_array(0) .Type = NXOpen.UF.UFConstants.UF_solid_type .Subtype = 0 .SolidBodySubtype = NXOpen.UF.UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY End Withwww.nxjournaling.com
RE: Changing body Line widths Journaling VB
CODE --> VB
Option Strict Off Imports System Imports System.Collections.Generic Imports NXOpen Imports NXOpen.UF Module NXJournal Sub Main (ByVal args() As String) Dim theSession As Session = Session.GetSession() Dim displayModification1 As DisplayModification displayModification1 = theSession.DisplayManager.NewDisplayModification() displayModification1.ApplyToAllFaces = False displayModification1.ApplyToOwningParts = False displayModification1.NewWidth = DisplayableObject.ObjectWidth.Five Dim body() as TaggedObject If SelectAnObject("identify body",body) = Selection.Response.Cancel Then Return End If Dim objects1 As New List(Of DisplayableObject) For Each temp As TaggedObject In body objects1.Add(CType(temp, DisplayableObject)) Next displayModification1.Apply(objects1.ToArray) displayModification1.Dispose() End Sub Function SelectAnObject(prompt As String, _ ByRef selObj() As TaggedObject) As Selection.Response Dim theUI As UI = UI.GetUI Dim title As String = "Select one or more bodies" Dim scope As Selection.SelectionScope = Selection.SelectionScope.AnyInAssembly Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_solid_type .Subtype = 0 .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_BODY End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObjects( _ prompt, title, scope, selAction, _ includeFeatures, keepHighlighted, selectionMask_array, _ selobj) If resp = Selection.Response.Ok Then Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function End ModuleRE: Changing body Line widths Journaling VB
Got it working!
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