Community Tip - Stay updated on what is happening on the PTC Community by subscribing to PTC Community Announcements. X

Translate the entire conversation x

Get A list of drawing file in workspace? Can anyone provide a vb code example?

SC_TK
10-Marble

Get A list of drawing file in workspace? Can anyone provide a vb code example?

Hi, 

 

Creo Windchill is very different from other PDM system. There is no real folder structure. I am confused of how to extract all drawing files from active workspace. I like to create a VB.net program to export all of them to PDFs, But I don't know how to extract the list of the filenames. 

Can anyone provide a code example of how to create a file list in Active workspace? 

 

Thanks

ACCEPTED SOLUTION

Accepted Solutions
RandyJones
20-Turquoise
(To:SC_TK)

4 REPLIES 4
VladimirN
24-Ruby II
(To:SC_TK)

Article - "SQL script to retrieve the file names of the CAD documents related to a part in Windchill PDMLink": https://www.ptc.com/en/support/article/CS353515 

SC_TK
10-Marble
(To:VladimirN)

Thanks. That is not what I am looking for.  What I like to be able to list all drawing files under active workspace. We need to export them to PDFs.  And each drawing will add a custom stamp to indicate which project it will be used to. 

I used to work with Solidworks and it is relatively easy as SW has a local folder. But Creo doesn't really have one only a encoded structure. There is no straightforward method to get the file list. 

RandyJones
20-Turquoise
(To:SC_TK)

Thanks for providing this link.  I use the same method to develop the vb,.net code as following. It works well.  The server name is "CreoServer". And workspace name is "Production Workspace".  The code will pull all the drawings in the workspace and display them in a Listview, "lvDrawings". 

Dim strAliasName As String = "CreoServer"
Dim strWsName As String = "Production Workspace"
Dim wsPath As String = "wtws://" & strAliasName & "/" & strWsName & "/"

' Retrieve drawing files
Dim drawingFiles As Cstringseq = session.ListFiles("*.drw", EpfcFileListOpt.EpfcFILE_LIST_LATEST, wsPath)

' Check if any files were found
If drawingFiles IsNot Nothing AndAlso drawingFiles.Count > 0 Then
	' Create a list to hold items for sorting
	Dim itemsToSort As New List(Of ListViewItem)()

	For i As Integer = 0 To drawingFiles.Count - 1
		' Create a ListViewItem with filename
		Dim item As New ListViewItem(drawingFiles(i))
		item.SubItems.Add("0") ' Default revision as "0"

		' Add item to the list
		itemsToSort.Add(item)
	Next

	' Sort the list by filename (first column)
	itemsToSort.Sort(Function(x, y) String.Compare(x.Text, y.Text))

	' Add sorted items to ListView
	For Each item As ListViewItem In itemsToSort
		FormMain.lvDrawings.Items.Add(item)
	Next
End If

 

Announcements

Top Tags