NX8.5 and Block UI Styler
NX8.5 and Block UI Styler
(OP)
At some length, and with forum help I was able to create a dialog box that assigns attributes to solid bodies. This journal (below) calls a primitive input box and I've since had an NX dialog box created with Block UI Styler.
Saving the Block UI Styler dialog box outputs a .vb and .dxi file - I'm not sure where to put those and then how to execute them from within NX.
I'm out of my depth here but can usually tweak some code to get a decent result with help but if this is simply beyond a noob I'd be almost relieved to hear it. If so, then outsourcing it would make the most sense.
But I hate admitting defeat!
Thanks for any insight in advance!
Current journal:
Option Strict Off
Imports NXOpenUI
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "body attributes")
lw.Open()
Dim selobj As NXObject
Dim type As Integer
Dim subtype As Integer
Dim theBodies As New List(Of Body)
Dim theUI As UI = UI.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
Dim answer As String = ""
'process the preselected bodies
If numsel > 0 Then
For inx As Integer = 0 To numsel - 1
selobj = theUI.SelectionManager.GetSelectedTaggedObject(inx)
theUfSession.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
If type = UFConstants.UF_solid_type Then
theBodies.Add(selobj)
End If
Next
Else
'prompt to select bodies
If SelectBodies("Select Bodies to assign attributes", theBodies) = Selection.Response.Cancel Then
Return
End If
End If
For Each temp As Body In theBodies
DeleteAllAttributes(temp)
'input box: prompt and title
answer = NXInputBox.GetInputString("Detail Name", "")
AddBodyAttribute(temp, "DET_NAME", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Detail Number", "")
AddBodyAttribute(temp, "DET_NUMBER", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Material", "")
AddBodyAttribute(temp, "MAT'L", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Stock Size", "")
AddBodyAttribute(temp, "STOCK_SIZE", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Heat Treat", "")
AddBodyAttribute(temp, "HEAT_TREAT", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Surface Finish", "")
AddBodyAttribute(temp, "Surface_Finish", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Vendor", "")
AddBodyAttribute(temp, "VENDOR", answer)
'add other attributes as needed
Next
lw.Close()
End Sub
Function SelectBodies(ByVal prompt As String, ByRef selBod As List(Of Body)) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select bodies"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple
Dim selObj() As TaggedObject
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.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
For Each temp As TaggedObject In selObj
selBod.Add(temp)
Next
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Sub AddBodyAttribute(ByVal theBody As Body, ByVal attTitle As String, ByVal attValue As String)
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "add body attribute")
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(theSession.Parts.Work, {theBody}, AttributePropertiesBuilder.OperationType.None)
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String
attributePropertiesBuilder1.Title = attTitle
attributePropertiesBuilder1.StringValue = attValue
Dim nXObject1 As NXObject
nXObject1 = attributePropertiesBuilder1.Commit()
Dim id1 As Session.UndoMarkId
id1 = theSession.GetNewestUndoMark(Session.MarkVisibility.Visible)
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
attributePropertiesBuilder1.Destroy()
End Sub
Sub DeleteAllAttributes(ByVal theObject As NXObject)
Dim attributeInfo() As NXObject.AttributeInformation = theObject.GetUserAttributes
For Each temp As NXObject.AttributeInformation In attributeInfo
theObject.DeleteUserAttributes(temp.Type, Update.Option.Now)
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
Saving the Block UI Styler dialog box outputs a .vb and .dxi file - I'm not sure where to put those and then how to execute them from within NX.
I'm out of my depth here but can usually tweak some code to get a decent result with help but if this is simply beyond a noob I'd be almost relieved to hear it. If so, then outsourcing it would make the most sense.
But I hate admitting defeat!
Thanks for any insight in advance!
Current journal:
Option Strict Off
Imports NXOpenUI
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "body attributes")
lw.Open()
Dim selobj As NXObject
Dim type As Integer
Dim subtype As Integer
Dim theBodies As New List(Of Body)
Dim theUI As UI = UI.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
Dim answer As String = ""
'process the preselected bodies
If numsel > 0 Then
For inx As Integer = 0 To numsel - 1
selobj = theUI.SelectionManager.GetSelectedTaggedObject(inx)
theUfSession.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
If type = UFConstants.UF_solid_type Then
theBodies.Add(selobj)
End If
Next
Else
'prompt to select bodies
If SelectBodies("Select Bodies to assign attributes", theBodies) = Selection.Response.Cancel Then
Return
End If
End If
For Each temp As Body In theBodies
DeleteAllAttributes(temp)
'input box: prompt and title
answer = NXInputBox.GetInputString("Detail Name", "")
AddBodyAttribute(temp, "DET_NAME", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Detail Number", "")
AddBodyAttribute(temp, "DET_NUMBER", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Material", "")
AddBodyAttribute(temp, "MAT'L", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Stock Size", "")
AddBodyAttribute(temp, "STOCK_SIZE", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Heat Treat", "")
AddBodyAttribute(temp, "HEAT_TREAT", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Surface Finish", "")
AddBodyAttribute(temp, "Surface_Finish", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Vendor", "")
AddBodyAttribute(temp, "VENDOR", answer)
'add other attributes as needed
Next
lw.Close()
End Sub
Function SelectBodies(ByVal prompt As String, ByRef selBod As List(Of Body)) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select bodies"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple
Dim selObj() As TaggedObject
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.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
For Each temp As TaggedObject In selObj
selBod.Add(temp)
Next
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Sub AddBodyAttribute(ByVal theBody As Body, ByVal attTitle As String, ByVal attValue As String)
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "add body attribute")
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(theSession.Parts.Work, {theBody}, AttributePropertiesBuilder.OperationType.None)
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String
attributePropertiesBuilder1.Title = attTitle
attributePropertiesBuilder1.StringValue = attValue
Dim nXObject1 As NXObject
nXObject1 = attributePropertiesBuilder1.Commit()
Dim id1 As Session.UndoMarkId
id1 = theSession.GetNewestUndoMark(Session.MarkVisibility.Visible)
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
attributePropertiesBuilder1.Destroy()
End Sub
Sub DeleteAllAttributes(ByVal theObject As NXObject)
Dim attributeInfo() As NXObject.AttributeInformation = theObject.GetUserAttributes
For Each temp As NXObject.AttributeInformation In attributeInfo
theObject.DeleteUserAttributes(temp.Type, Update.Option.Now)
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
~Felicia H.
NX 9.0.2.5
"Design all things as simple as possible but not simpler."





RE: NX8.5 and Block UI Styler
Imports NXOpenUI
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "body attributes")
lw.Open()
lw.Close()
Dim theUI As UI = UI.GetUI
~Felicia H.
NX 9.0.2.5
"Design all things as simple as possible but not simpler."
RE: NX8.5 and Block UI Styler
"Imports NXOpenUI" would be replaced by "Imports NXOpen.BlockStyler" I'm pretty sure.
Block UI Styler:
'==============================================================================
' WARNING!! This file is overwritten by the Block UI Styler while generating
' the automation code. Any modifications to this file will be lost after
' generating the code again.
'
' Filename: C:\Users\Electracomplex\Desktop\OjbAttrib_dialog.vb
'
' This file was generated by the NX Block UI Styler
' Created by: Electracomplex
' Version: NX 8.5
' Date: 02-27-2018 (Format: mm-dd-yyyy)
' Time: 17:25 (Format: hh-mm)
'
'==============================================================================
'------------------------------------------------------------------------------
'These imports are needed for the following template code
'------------------------------------------------------------------------------
Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.BlockStyler
'------------------------------------------------------------------------------
'Represents Block Styler application class
'------------------------------------------------------------------------------
Public Class OjbAttrib_dialog
'class members
Private Shared theSession As Session
Private Shared theUI As UI
Private theDlxFileName As String
Private theDialog As NXOpen.BlockStyler.BlockDialog
Private group0 As NXOpen.BlockStyler.Group' Block type: Group
Private string0 As NXOpen.BlockStyler.StringBlock' Block type: String
Private string01 As NXOpen.BlockStyler.StringBlock' Block type: String
Private string02 As NXOpen.BlockStyler.StringBlock' Block type: String
Private string05 As NXOpen.BlockStyler.StringBlock' Block type: String
Private string03 As NXOpen.BlockStyler.StringBlock' Block type: String
Private string04 As NXOpen.BlockStyler.StringBlock' Block type: String
#Region "Block Styler Dialog Designer generator code"
'------------------------------------------------------------------------------
'Constructor for NX Styler class
'------------------------------------------------------------------------------
Public Sub New()
Try
theSession = Session.GetSession()
theUI = UI.GetUI()
theDlxFileName = "OjbAttrib_dialog.dlx"
theDialog = theUI.CreateDialog(theDlxFileName)
theDialog.AddApplyHandler(AddressOf apply_cb)
theDialog.AddOkHandler(AddressOf ok_cb)
theDialog.AddUpdateHandler(AddressOf update_cb)
theDialog.AddInitializeHandler(AddressOf initialize_cb)
theDialog.AddDialogShownHandler(AddressOf dialogShown_cb)
Catch ex As Exception
'---- Enter your exception handling code here -----
Throw ex
End Try
End Sub
#End Region
'------------------------------- DIALOG LAUNCHING ---------------------------------
'
' Before invoking this application one needs to open any part/empty part in NX
' because of the behavior of the blocks.
'
' Make sure the dlx file is in one of the following locations:
' 1.) From where NX session is launched
' 2.) $UGII_USER_DIR/application
' 3.) For released applications, using UGII_CUSTOM_DIRECTORY_FILE is highly
' recommended. This variable is set to a full directory path to a file
' containing a list of root directories for all custom applications.
' e.g., UGII_CUSTOM_DIRECTORY_FILE=$UGII_ROOT_DIR\menus\custom_dirs.dat
'
' You can create the dialog using one of the following way:
'
' 1. Journal Replay
'
' 1) Replay this file through Tool->Journal->Play Menu.
'
' 2. USER EXIT
'
' 1) Create the Shared Library -- Refer "Block UI Styler programmer's guide"
' 2) Invoke the Shared Library through File->Execute->NX Open menu.
'
'------------------------------------------------------------------------------
Public Shared Sub Main()
Dim theOjbAttrib_dialog As OjbAttrib_dialog = Nothing
Try
theOjbAttrib_dialog = New OjbAttrib_dialog()
' The following method shows the dialog immediately
theOjbAttrib_dialog.Show()
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
Finally
If theOjbAttrib_dialog IsNot Nothing Then
theOjbAttrib_dialog.Dispose()
theOjbAttrib_dialog = Nothing
End If
End Try
End Sub
'------------------------------------------------------------------------------
' This method specifies how a shared image is unloaded from memory
' within NX. This method gives you the capability to unload an
' internal NX Open application or user exit from NX. Specify any
' one of the three constants as a return value to determine the type
' of unload to perform:
'
'
' Immediately : unload the library as soon as the automation program has completed
' Explicitly : unload the library from the "Unload Shared Image" dialog
' AtTermination : unload the library when the NX session terminates
'
'
' NOTE: A program which associates NX Open applications with the menubar
' MUST NOT use this option since it will UNLOAD your NX Open application image
' from the menubar.
'------------------------------------------------------------------------------
Public Shared Function GetUnloadOption(ByVal arg As String) As Integer
'Return CType(Session.LibraryUnloadOption.Explicitly, Integer)
Return CType(Session.LibraryUnloadOption.Immediately, Integer)
' Return CType(Session.LibraryUnloadOption.AtTermination, Integer)
End Function
'------------------------------------------------------------------------------
' Following method cleanup any housekeeping chores that may be needed.
' This method is automatically called by NX.
'------------------------------------------------------------------------------
Public Shared Sub UnloadLibrary(ByVal arg As String)
Try
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
'------------------------------------------------------------------------------
'This method shows the dialog on the screen
'------------------------------------------------------------------------------
Public Sub Show()
Try
theDialog.Show
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
'------------------------------------------------------------------------------
'Method Name: Dispose
'------------------------------------------------------------------------------
Public Sub Dispose()
If theDialog IsNot Nothing Then
theDialog.Dispose()
theDialog = Nothing
End If
End Sub
'------------------------------------------------------------------------------
'---------------------Block UI Styler Callback Functions--------------------------
'------------------------------------------------------------------------------
'------------------------------------------------------------------------------
'Callback Name: initialize_cb
'------------------------------------------------------------------------------
Public Sub initialize_cb()
Try
group0 = CType(theDialog.TopBlock.FindBlock("group0"), NXOpen.BlockStyler.Group)
string0 = CType(theDialog.TopBlock.FindBlock("string0"), NXOpen.BlockStyler.StringBlock)
string01 = CType(theDialog.TopBlock.FindBlock("string01"), NXOpen.BlockStyler.StringBlock)
string02 = CType(theDialog.TopBlock.FindBlock("string02"), NXOpen.BlockStyler.StringBlock)
string05 = CType(theDialog.TopBlock.FindBlock("string05"), NXOpen.BlockStyler.StringBlock)
string03 = CType(theDialog.TopBlock.FindBlock("string03"), NXOpen.BlockStyler.StringBlock)
string04 = CType(theDialog.TopBlock.FindBlock("string04"), NXOpen.BlockStyler.StringBlock)
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
'------------------------------------------------------------------------------
'Callback Name: dialogShown_cb
'This callback is executed just before the dialog launch. Thus any value set
'here will take precedence and dialog will be launched showing that value.
'------------------------------------------------------------------------------
Public Sub dialogShown_cb()
Try
'---- Enter your callback code here -----
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Sub
'------------------------------------------------------------------------------
'Callback Name: apply_cb
'------------------------------------------------------------------------------
Public Function apply_cb() As Integer
Dim errorCode as Integer = 0
Try
'---- Enter your callback code here -----
Catch ex As Exception
'---- Enter your exception handling code here -----
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
apply_cb = errorCode
End Function
'------------------------------------------------------------------------------
'Callback Name: update_cb
'------------------------------------------------------------------------------
Public Function update_cb(ByVal block As NXOpen.BlockStyler.UIBlock) As Integer
Try
If block Is string0 Then
'---- Enter your code here -----
ElseIf block Is string01 Then
'---- Enter your code here -----
ElseIf block Is string02 Then
'---- Enter your code here -----
ElseIf block Is string05 Then
'---- Enter your code here -----
ElseIf block Is string03 Then
'---- Enter your code here -----
ElseIf block Is string04 Then
'---- Enter your code here -----
End If
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
update_cb = 0
End Function
'------------------------------------------------------------------------------
'Callback Name: ok_cb
'------------------------------------------------------------------------------
Public Function ok_cb() As Integer
Dim errorCode as Integer = 0
Try
'---- Enter your callback code here -----
errorCode = apply_cb()
Catch ex As Exception
'---- Enter your exception handling code here -----
errorCode = 1
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
ok_cb = errorCode
End Function
'------------------------------------------------------------------------------
'Function Name: GetBlockProperties
'Returns the propertylist of the specified BlockID
'------------------------------------------------------------------------------
Public Function GetBlockProperties(ByVal blockID As String) As PropertyList
GetBlockProperties = Nothing
Try
GetBlockProperties = theDialog.GetBlockProperties(blockID)
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
End Try
End Function
End Class
Object attribute journal:
Option Strict Off
Imports NXOpenUI
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module1
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession()
Dim theUI As UI = UI.GetUI()
Dim lw As ListingWindow = theSession.ListingWindow
Sub Main()
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "body attributes")
lw.Open()
Dim selobj As NXObject
Dim type As Integer
Dim subtype As Integer
Dim theBodies As New List(Of Body)
Dim theUI As UI = UI.GetUI
Dim numsel As Integer = theUI.SelectionManager.GetNumSelectedObjects()
Dim answer As String = ""
'process the preselected bodies
If numsel > 0 Then
For inx As Integer = 0 To numsel - 1
selobj = theUI.SelectionManager.GetSelectedTaggedObject(inx)
theUfSession.Obj.AskTypeAndSubtype(selobj.Tag, type, subtype)
If type = UFConstants.UF_solid_type Then
theBodies.Add(selobj)
End If
Next
Else
'prompt to select bodies
If SelectBodies("Select Bodies to assign attributes", theBodies) = Selection.Response.Cancel Then
Return
End If
End If
For Each temp As Body In theBodies
DeleteAllAttributes(temp)
'input box: prompt and title
answer = NXInputBox.GetInputString("Detail Name", "")
AddBodyAttribute(temp, "DET_NAME", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Detail Number", "")
AddBodyAttribute(temp, "DET_NUMBER", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Material", "")
AddBodyAttribute(temp, "MAT'L", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Stock Size", "")
AddBodyAttribute(temp, "STOCK_SIZE", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Heat Treat", "")
AddBodyAttribute(temp, "HEAT_TREAT", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Surface Finish", "")
AddBodyAttribute(temp, "Surface_Finish", answer)
'input box: prompt and title
answer = NXInputBox.GetInputString("Vendor", "")
AddBodyAttribute(temp, "VENDOR", answer)
'add other attributes as needed
Next
lw.Close()
End Sub
Function SelectBodies(ByVal prompt As String, ByRef selBod As List(Of Body)) As Selection.Response
Dim theUI As UI = UI.GetUI
Dim title As String = "Select bodies"
Dim includeFeatures As Boolean = False
Dim keepHighlighted As Boolean = False
Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific
Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
Dim selectionMask_array(0) As Selection.MaskTriple
Dim selObj() As TaggedObject
With selectionMask_array(0)
.Type = UFConstants.UF_solid_type
.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
For Each temp As TaggedObject In selObj
selBod.Add(temp)
Next
Return Selection.Response.Ok
Else
Return Selection.Response.Cancel
End If
End Function
Sub AddBodyAttribute(ByVal theBody As Body, ByVal attTitle As String, ByVal attValue As String)
Dim markId4 As Session.UndoMarkId
markId4 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "add body attribute")
Dim attributePropertiesBuilder1 As AttributePropertiesBuilder
attributePropertiesBuilder1 = theSession.AttributeManager.CreateAttributePropertiesBuilder(theSession.Parts.Work, {theBody}, AttributePropertiesBuilder.OperationType.None)
attributePropertiesBuilder1.IsArray = False
attributePropertiesBuilder1.DataType = AttributePropertiesBaseBuilder.DataTypeOptions.String
attributePropertiesBuilder1.Title = attTitle
attributePropertiesBuilder1.StringValue = attValue
Dim nXObject1 As NXObject
nXObject1 = attributePropertiesBuilder1.Commit()
Dim id1 As Session.UndoMarkId
id1 = theSession.GetNewestUndoMark(Session.MarkVisibility.Visible)
Dim nErrs1 As Integer
nErrs1 = theSession.UpdateManager.DoUpdate(id1)
attributePropertiesBuilder1.Destroy()
End Sub
Sub DeleteAllAttributes(ByVal theObject As NXObject)
Dim attributeInfo() As NXObject.AttributeInformation = theObject.GetUserAttributes
For Each temp As NXObject.AttributeInformation In attributeInfo
theObject.DeleteUserAttributes(temp.Type, Update.Option.Now)
Next
End Sub
Public Function GetUnloadOption(ByVal dummy As String) As Integer
'Unloads the image immediately after execution within NX
GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately
End Function
End Module
~Felicia H.
NX 9.0.2.5
"Design all things as simple as possible but not simpler."