Blockstyler tree list example

The following code sample (NX 11) was submitted by member GZN. This is an example of using the blockstyler tree list control. When run on an assembly, it will list all the assembly components in the tree list. After selecting one or more rows in the tree list, press OK and the selected rows will be exported to an HTML file.

The sample makes use of the TreeListDemo.dlx file found in the sample applications that ship with NX; be sure to modify the code to point to the location of this file on your machine before running the journal.

Thanks GZN for sharing your code!

Option Strict Off
Imports System
Imports System.String
Imports System.IO
Imports System.Collections
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Utilities
Imports NXOpen.BlockStyler
Imports NXOpen.Assemblies

'------------------------------------------------------------------------------
'Represents Block Styler application class
'------------------------------------------------------------------------------
Public Class Parts_List
'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 tree_control0 As NXOpen.BlockStyler.Tree ' Block type: Tree Control

Private lastnode As NXOpen.BlockStyler.Node
Private nColumnID As Integer = 0
Private lNodes As ArrayList = Nothing
Private previousAddedNode As BlockStyler.Node = Nothing
Private sequential_nr As Integer = 1
Private Shared Lista_Itens_Biblioteca As ArrayList = New ArrayList
Private Shared Lista_Itens_Cad As ArrayList = New ArrayList
Private Shared newlist As ArrayList = New ArrayList
Private Shared itqnt As New Dictionary(Of String, Integer)
Private Shared upd As Integer = 0
Private Shared Columns_List As New Dictionary(Of String, String)

Private stateIconGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private addDeleteNodeGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private NodeEditGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private menuGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private dragDropGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private defaultActionGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private nodeDataGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private redrawGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group
Private listingWindowGroup As NXOpen.BlockStyler.UIBlock ' Block type: Group

#Region "Block Styler Dialog Designer generator code"
'------------------------------------------------------------------------------
'Constructor for NX Styler class
'------------------------------------------------------------------------------
Public Sub New()
Try

theSession = Session.GetSession()
theUI = UI.GetUI()

'USE YOUR PATH"
theDlxFileName = "C:\Program Files\Siemens\NX 11.0\UGOPEN\SampleNXOpenApplications\C++\BlockStyler\TreeListDemo\TreeListDemo.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)

lNodes = New ArrayList()
'
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 theParts_List As Parts_List = Nothing

On_Main()

Try
theParts_List = New Parts_List()
' The following method shows the dialog immediately
theParts_List.Show()
Catch ex As Exception
'---- Enter your exception handling code here -----
theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString)
Finally
If theParts_List IsNot Nothing Then
theParts_List.Dispose()
theParts_List = 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)
tree_control0 = CType(theDialog.TopBlock.FindBlock("tree_control0"), NXOpen.BlockStyler.Tree)
'------------------------------------------------------------------------------
'Registration of Treelist specific callbacks
'------------------------------------------------------------------------------
'tree_control0.SetOnExpandHandler( AddressOf OnExpandCallback )

'tree_control0.SetOnInsertColumnHandler( AddressOf OnInsertColumnCallback )

'tree_control0.SetOnInsertNodeHandler( AddressOf OnInsertNodeCallback )

'tree_control0.SetOnDeleteNodeHandler( AddressOf OnDeleteNodeCallback )

'tree_control0.SetOnPreSelectHandler( AddressOf OnPreSelectCallback )

'tree_control0.SetOnSelectHandler( AddressOf OnSelectCallback )

'tree_control0.SetOnStateChangeHandler(AddressOf OnStateChangecallback)

'tree_control0.SetToolTipTextHandler( AddressOf ToolTipTextCallback )

'tree_control0.SetColumnSortHandler(AddressOf ColumnSortCallback)

'tree_control0.SetStateIconNameHandler(AddressOf StateIconNameCallback)

' tree_control0.SetOnBeginLabelEditHandler(AddressOf OnBeginLabelEdit)

'tree_control0.SetOnEndLabelEditHandler(AddressOf OnEndLabelEdit)

'tree_control0.SetOnEditOptionSelectedHandler(AddressOf OnEditOptionSelected)

'tree_control0.SetAskEditControlHandler(AddressOf AskEditControl)

'tree_control0.SetOnMenuHandler(AddressOf OnMenuCallback)

'tree_control0.SetOnMenuSelectionHandler(AddressOf OnMenuCommandCallback)

'tree_control0.SetIsDropAllowedHandler(AddressOf IsDropAllowedCallback)

'tree_control0.SetIsDragAllowedHandler(AddressOf IsDragAllowedCallback)

'tree_control0.SetOnDropHandler(AddressOf OnDropCallback)

'tree_control0.SetOnDropMenuHandler(AddressOf OnDropMenuCallback)

'tree_control0.SetOnDefaultActionHandler(AddressOf OnDefaultActionCallback)

'------------------------------------------------------------------------------

addDeleteNodeGroup = CType(theDialog.TopBlock.FindBlock("addDeleteNodeGroup"), NXOpen.BlockStyler.UIBlock)
addDeleteNodeGroup.Show = False

stateIconGroup = CType(theDialog.TopBlock.FindBlock("stateIconGroup"), NXOpen.BlockStyler.UIBlock)
stateIconGroup.Show = False

NodeEditGroup = CType(theDialog.TopBlock.FindBlock("NodeEditGroup"), NXOpen.BlockStyler.UIBlock)
NodeEditGroup.Show = False

menuGroup = CType(theDialog.TopBlock.FindBlock("menuGroup"), NXOpen.BlockStyler.UIBlock)
menuGroup.Show = False

dragDropGroup = CType(theDialog.TopBlock.FindBlock("dragDropGroup"), NXOpen.BlockStyler.UIBlock)
dragDropGroup.Show = False

defaultActionGroup = theDialog.TopBlock.FindBlock("defaultActionGroup")
defaultActionGroup.Show = False

nodeDataGroup = CType(theDialog.TopBlock.FindBlock("nodeDataGroup"), NXOpen.BlockStyler.UIBlock)
nodeDataGroup.Show = False

redrawGroup = CType(theDialog.TopBlock.FindBlock("redrawGroup"), NXOpen.BlockStyler.UIBlock)
redrawGroup.Show = False

listingWindowGroup = theDialog.TopBlock.FindBlock("listingWindowGroup")
listingWindowGroup.Show = False

Dim group0PropList As BlockStyler.PropertyList = group0.GetProperties()
group0PropList.SetString("Label", "List")

Dim theDialoprop As BlockStyler.PropertyList = theDialog.GetBlockProperties("Dialog")
theDialoprop.SetString("Label", "Parts List")
theDialoprop.SetEnum("Dialog Sizing", 0)

Size()

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 -----
Shown_()

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

Export_()

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

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

'------------------------------------------------------------------------------
'Treelist specific callbacks
'------------------------------------------------------------------------------
'Public Sub OnExpandCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node as NXOpen.BlockStyler.Node )
'End Sub

'Public Sub OnInsertColumnCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal columnID As Integer)
'End Sub

'Public Sub OnInsertNodeCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node)
'End Sub

'Public Sub OnDeleteNodeCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node as NXOpen.BlockStyler.Node )
'End Sub

'Public Sub OnPreSelectcallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node as NXOpen.BlockStyler.Node , ByVal columnID As Integer, ByVal selected As Boolean)
'End Sub

'Public Sub OnSelectcallback(ByVal tree as NXOpen.BlockStyler.Tree, ByVal node as NXOpen.BlockStyler.Node , ByVal columnID As Integer, ByVal selected As Boolean)
'End Sub

'Public Sub OnStateChangecallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal State As Integer)
'End Sub

'Public Function ToolTipTextcallback(ByVal tree as NXOpen.BlockStyler.Tree, ByVal node as NXOpen.BlockStyler.Node , ByVal columnID As Integer) As String
'End Function

'Public Function ColumnSortcallback(ByVal tree as NXOpen.BlockStyler.Tree, ByVal columnID As Integer, ByVal node1 as NXOpen.BlockStyler.Node, ByVal node2 as NXOpen.BlockStyler.Node) As Integer
'End Function

'This is called when Node is set with state other than 1 and 2
'Public Function StateIconNameCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal state As Integer) As String
'End Function

'Public Function OnBeginLabelEdit(ByVal tree As Tree, ByVal node As Node, ByVal columnId As Integer) As NXOpen.BlockStyler.Tree.BeginLabelEditState
'End Function

'Public Function OnEndLabelEdit(ByVal tree As Tree, ByVal node As Node, ByVal columnId As Integer, ByVal editedText As String) As NXOpen.BlockStyler.Tree.EndLabelEditState
'End Function

'Public Function OnEditOptionSelected(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal columnID As Integer, ByVal selectedOptionID As Integer, ByVal selectedOptionText As String, ByVal type As NXOpen.BlockStyler.Tree.ControlType) As NXOpen.BlockStyler.Tree.EditControlOption
'End Function

'Public Function AskEditControl(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal columnID As Integer) As NXOpen.BlockStyler.Tree.ControlType
'End Function

'Public Sub OnMenuCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal columnID As Integer)
'End Sub

'Public Sub OnMenuCommandCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal menu_item_id As Integer)
'End Sub

'Public Function IsDropAllowedCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal columnID As Integer, ByVal targetNode As NXOpen.BlockStyler.Node, ByVal targetColumnID As Integer) As NXOpen.BlockStyler.Node.DropType
'End Function

'Public Function IsDragAllowedCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal columnID As Integer) As NXOpen.BlockStyler.Node.DragType
'End Function

'Public Function OnDropCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node() As NXOpen.BlockStyler.Node, ByVal columnID As Integer, ByVal targetNode As NXOpen.BlockStyler.Node, ByVal targetColumnID As Integer, ByVal dropType As NXOpen.BlockStyler.Node.DropType, ByVal dropMenuItemId As Integer) As Boolean
'End Function

'Public Sub OnDropMenuCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal columnID As Integer, ByVal targetNode As NXOpen.BlockStyler.Node, ByVal targetColumnID As Integer)
'End Sub

'Public Sub OnDefaultActionCallback(ByVal tree As NXOpen.BlockStyler.Tree, ByVal node As NXOpen.BlockStyler.Node, ByVal columnID As Integer)
'End Sub

'------------------------------------------------------------------------------
'Function Name: GetBlockProperties
'Returns the propertylist of the specified BlockID
'------------------------------------------------------------------------------
'Public Function GetBlockProperties(ByVal blockID As String) As PropertyList
'End Function

'###############################################################################################################

Public Shared Sub On_Main() ' add to Main()

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

If workPart Is Nothing Then Return

'##################################################################################
'List of Columns "Name" and "Attributes , whidth of column" in order as they will be show

Columns_List.Add("SEQ", "SEQ, 40") 'SEQ is a wildcard in the nexts steps for Sequential Number
Columns_List.Add("QTY REAL", "QTY, 50") 'Qty is a wildcard in the nexts steps for the real quantity
Columns_List.Add("DESCRIPTION", "PartName, 250") 'PartName is a wildcard in the nexts steps for the file name
' Columns_List.Add("MATERIAL", "MATERIAL, 80")

'UNCOMENT THE ABOVE LINE TO ADD MATERIAL PROPERTIES TO THE TABLE
'Columns_List.Add("MATERIAL", "MATERIAL, 80")

'You can add more columns

'##################################################################################

End Sub

Sub Size() ' add to initialize_cb()

tree_control0.Width = 1600
tree_control0.Height = 500
tree_control0.CanStretchWidth = True

End Sub

Sub Shown_() ' add to dialogShown_cb()

tree_control0.ShowExpandCollapseMarker = False

Dim ii As Integer = 0
For Each kvp As KeyValuePair(Of String, String) In Columns_List
tree_control0.InsertColumn(ii, kvp.Key, kvp.Value.Split(", ")(1))
ii += 1
Next kvp

If upd = 0 Then
listallcomp_()
Else
sequential_nr = 1
End If
upd = 1

UpdateDialog()

End Sub

Sub Export_()

Dim selectedNode() As BlockStyler.Node = tree_control0.GetSelectedNodes()
Dim i As Integer
Dim color As Integer = 0
Dim Table As ArrayList = New ArrayList
Dim str As String = Nothing
Dim prefix As String = " "
Dim sufix As String = ""
Dim text As String = Nothing

If selectedNode.Length < 1 Then Return

Table.Add("")
Table.Add("")
Table.Add("")
Table.Add("Lista de Materiais")
Table.Add("")
Table.Add("")
Table.Add("")
Table.Add("")
Table.Add("")

For Each kvp As KeyValuePair(Of String, String) In Columns_List
str = kvp.Key
text = prefix & str & sufix
Table.Add(text)
Next kvp

Table.Add("")

For Each nd As Node In selectedNode

If color = 0 Then
Table.Add("")
color = 1
Else
Table.Add("")
color = 0
End If

For i = 0 To Columns_List.Count - 1
str = nd.GetColumnDisplayText(i)
text = prefix & str & sufix
Table.Add(text)
Next

Table.Add("")

Next

Table.Add("")
Table.Add("")
Table.Add("")

log(Table)
Table.Clear()

End Sub

Sub Echo(ByVal output As String)
theSession.ListingWindow.Open()
theSession.ListingWindow.WriteLine(output)
theSession.LogFile.WriteLine(output)
End Sub

Sub listallcomp_()

Dim root As Component = _
theSession.Parts.Display.ComponentAssembly.RootComponent

If Not IsNothing(root) Then
Walk(root, 0)
Else
Read_Attr(theSession.Parts.Work)
End If

End Sub

Sub Walk(ByVal c As Component, ByVal indent As Integer)

Dim child As Component = Nothing
Dim PLIST_IGNORE_SUBASSEMBLY As String = Nothing
Dim PLIST_IGNORE_MEMBER As String = Nothing

If TypeOf c.Prototype Is Part Then

Try
PLIST_IGNORE_MEMBER = c.GetUserAttributeAsString("PLIST_IGNORE_MEMBER", NXObject.AttributeType.Any, -1)
Catch ex As Exception
End Try

Try
PLIST_IGNORE_SUBASSEMBLY = c.GetUserAttributeAsString("PLIST_IGNORE_SUBASSEMBLY", NXObject.AttributeType.Any, -1)
Catch ex As Exception
End Try

If PLIST_IGNORE_MEMBER = Nothing Or PLIST_IGNORE_MEMBER = "off" Then
newlist.Add(c.DisplayName)
End If

For Each child In c.GetChildren()
If Not child.IsSuppressed Then
If PLIST_IGNORE_SUBASSEMBLY = Nothing Or PLIST_IGNORE_SUBASSEMBLY = "off" Then
Walk(child, indent + 1)
End If
End If
Next

Else
'Echo(New String(" "c, indent) & c.Name & " is not loaded")
End If

End Sub

Public Sub UpdateDialog()

Dim newlist3 As ArrayList = New ArrayList

newlist.Sort()

For Each Str As String In newlist

If Not newlist3.Contains(Str) Then newlist3.Add(Str)

If Not itqnt.ContainsKey(Str) Then
itqnt.Add(Str, 1)
Else
itqnt.Item(Str) += 1
End If
Next

For Each Str As String In newlist3
Dim prt As Part = CType(theSession.Parts.FindObject(Str), Part)
Read_Attr(prt)
Next

End Sub

Sub Read_Attr(ByVal Attr_Part As Part)

Dim afterNode As BlockStyler.Node = Nothing
Dim Attr_List As New Dictionary(Of String, String)
Dim PartName As String = Attr_Part.Leaf
Dim Qty As String = 1

Try
Qty = itqnt.Item(PartName)
Catch ex As Exception
End Try

Dim ii As Integer = 0
For Each kvp As KeyValuePair(Of String, String) In Columns_List
Dim att As String = kvp.Value.Split(", ")(0)
Attr_List.Add(ii, "")
Try
Attr_List(ii) = Attr_Part.GetUserAttributeAsString(att, NXObject.AttributeType.Any, -1)
Catch ex As Exception
End Try

If att = "PartName" Then Attr_List(ii) = PartName
If att = "QTY" Then Attr_List(ii) = Qty
If att = "SEQ" Then Attr_List(ii) = sequential_nr

ii += 1
Next kvp

Dim node As BlockStyler.Node = CreateAndAddNode(afterNode, Attr_List)

Attr_List.Clear()

End Sub

Function CreateAndAddNode(ByVal afterNode As BlockStyler.Node, ByVal AttrList As Dictionary(Of String, String)) As BlockStyler.Node

Dim parentNode As BlockStyler.Node = Nothing

Dim nodeDisplayString As String = sequential_nr

sequential_nr += 1

Dim node As BlockStyler.Node = tree_control0.CreateNode(nodeDisplayString)

'Set few properties of node
node.ForegroundColor = 211 '198
' node.DisplayIcon = "extrude" 'randomIconString(randomIcon)
' node.SelectedIcon = "draft"

'Insert Node
tree_control0.InsertNode(node, parentNode, afterNode, Tree.NodeInsertOption.Last)
'node.ScrollTo(Columns.SEQ, BlockStyler.Node.Scroll.MostScroll)

'Change the last node color. Making sure that new node color is distinct
' If Not previousAddedNode Is Nothing Then
' previousAddedNode.ForegroundColor = 211
' End If
previousAddedNode = node

'Assign return value
CreateAndAddNode = node

' Dim ii As Integer = 1

For Each kvp As KeyValuePair(Of String, String) In AttrList
node.SetColumnDisplayText(kvp.Key, kvp.Value)
Next kvp

End Function

Sub log(ByVal Table As ArrayList)

Dim workPart As Part = theSession.Parts.Work
Dim temp As String = theSession.GetEnvironmentVariableValue("TEMP")
Dim Log_File As String = temp & "\" & workPart.Leaf & ".html"

If File.Exists(Log_File) Then
Dim i As Integer
Do
i += 1
Log_File = Log_File.Replace(".html", i & ".html")
Loop Until Not File.Exists(Log_File)
End If

Try
Dim outFile As IO.StreamWriter = My.Computer.FileSystem.OpenTextFileWriter(Log_File, True)
For Each Str As String In Table
outFile.WriteLine(Str)
Next
outFile.Close()
System.Diagnostics.Process.Start(Log_File) ' OPEN THE HTML FILE
Catch ex As Exception
Console.OpenStandardOutput()
Console.WriteLine(ex.ToString)
Console.WriteLine()
End Try

End Sub

End Class

Comments

Hi,

i have two bodies say one cube upon another cube/one curved face body over the another cuved face body. Now i need to highlight those touching faces using nxopen apis. is it possible? if yes plz suggest me.

Thank you.

Thank you.