Monday 17 November 2014

Making of PacEdge Part 05

...continued from part 4

Each node has its own image from the ImageList control as the second argument.


The TreeList control has several columns:

1. Name: Displays just the name of the file without the extension.

2. Count: This applies only to root nodes like the Part, Draft, Sheetmetal, Assembly and the Other nodes and displays the total documents of each type that have been picked by the user for PacEdging.

3. Location: This displays the Folder or Path of each file.

4. File Size: Displays the size on disk value of the file.


5. Draft Exists ?: This displays a Yes or No depending whether a Draft file exists in the same folder as the model i.e. Part or Sheetmetal file. Additionally the Yes is highlighted in green to indicate it more prominently.


These columns are added to the TreeList from its Collection property or by clicking Edit Columns from the Edit columns Link which can be displayed by right-clicking anywhere in the Properties window and selecting Commands form the pop-up menu.


This opens up the Column Header Collection Editor dialog where you can set the Name, DisplayIndex and the Text properties for each column .

To display the various data in the TreeList columns, several variables are declared as below:

Dim sExt As String = String .Empty

Dim sFileName As String = String .Empty

Dim sPath As String = String .Empty

Dim sDraftYN As String = String .Empty

Dim n As TreeListViewItem = Nothing

The last variable n is a node in the TreeListView control and is officially called as a TreeViewListItem whereas the various columns are officially the SubItems.

A For Each loop is deployed to iterate through each file name in the ListOfSolidEdgeFiles:

For Each s As String In ListOfSolidEdgeFiles

  sExt = Path.GetExtension(s).ToUpper()

  sFileName = Path.GetFileNameWithoutExtension(s)

  sPath = Path.GetDirectoryName(s)

The file’s name, extension and path are separated.

The File Name is used to display in column 1, path in column 3 and the extension is used to determine the type as below:

Select Case sExt

Case ".ASM"

n = nodeASM.Items.Add(sFileName, 2) 'File name

n.SubItems.Add("") ' Count, leave blank

n.SubItems.Add(sPath) ' Path

n.SubItems.Add(GetFileSize(s)) ' File size

n.SubItems.Add(DraftYesNo(s)) '' Draft Exist Yes or No

I am not much familiar with this free version of the TreeList control but found that SubItems can be added in sequence or by index. There is another overload with a key argument but not able to find how to attach a key to a node.

Hence for the file node, the first sub-item i.e. column is assigned the file name whereas the second is left empty.

Continued to part 6... 

Index of all Solid Edge Tips, Tutorials and Videos...

No comments:

Post a Comment