Page 1 of 1
List materials in dropdown
Posted: Mon Jun 06, 2016 12:04 pm
by cam
Hi,
how can I get the materials from my library to show in a dropdown on my windowsform ?
The materials are organized in folders in a company specific library.
Up to date, I only can open the library.
Re: List materials in dropdown
Posted: Wed Jun 29, 2016 6:52 am
by cam
Hi,
I think the methode "GetProjectFolderConstituents" is the solution.
But.....
I don't know how to use it ?
Has anybody an example ?
For Missler.....
it would be nice if we can get examples "how to use" in the TopSolid.Automation Help
Re: List materials in dropdown
Posted: Wed Jun 29, 2016 11:28 am
by JuP
Hi,
Try it (it works well for me):
Code: Select all
Try
'Active document object ID getting
Dim ActiveDocumentId As PdmObjectId
ActiveDocumentId = TopSolidHost.Documents.GetPdmObject(DocId)
'Active Project object ID getting
Dim ActiveProjectId As PdmObjectId
ActiveProjectId = TopSolidHost.Pdm.GetProject(ActiveDocumentId)
'Active Project referenced project getting
Dim ReferencedProjectsIdList As New List(Of PdmObjectId)
ReferencedProjectsIdList = TopSolidHost.Pdm.GetReferencedProjects(ActiveProjectId)
'Searching in each referenced project
Dim DocumentsIdList As New List(Of PdmObjectId)
Dim FoldersIdList As New List(Of PdmObjectId)
For Each Reference In ReferencedProjectsIdList
Dim _DocumentsIdList As New List(Of PdmObjectId)
Dim _FoldersIdList As New List(Of PdmObjectId)
TopSolidHost.Pdm.GetConstituents(Reference, _FoldersIdList, _DocumentsIdList)
DocumentsIdList.AddRange(_DocumentsIdList)
FoldersIdList.AddRange(_FoldersIdList)
Do
Dim _FoldersIdList2 As New List(Of PdmObjectId)
_FoldersIdList2.AddRange(FoldersIdList)
FoldersIdList.Clear()
For i = 0 To _FoldersIdList2.Count - 1
Dim _FoldersIdList3 As New List(Of PdmObjectId)
Dim _DocumentsIdList2 As New List(Of PdmObjectId)
TopSolidHost.Pdm.GetConstituents(_FoldersIdList2.Item(i), _FoldersIdList3, _DocumentsIdList2)
DocumentsIdList.AddRange(_DocumentsIdList2)
FoldersIdList.AddRange(_FoldersIdList3)
Next
Loop While FoldersIdList.Count - 1 >= 0
Next
'Material documents getting
Dim MaterialDocumentsIdList As New List(Of PdmObjectId)
For Each DocumentId In DocumentsIdList
Dim Type As String = ""
TopSolidHost.Pdm.GetType(DocumentId, Type)
If Type = ".TopMat" Then
MaterialDocumentsIdList.Add(DocumentId)
End If
Next
'Material Documents name getting
Dim MaterialDocumentsNameList As New List(Of String)
For Each MaterialDocumentId In MaterialDocumentsIdList
MaterialDocumentsNameList.Add(TopSolidHost.Pdm.GetName(MaterialDocumentId))
Next
Catch ex As Exception
MsgBox("Error during the Material Documents getting" + vbNewLine + ex.Message)
End Try
Re: List materials in dropdown
Posted: Thu Jun 30, 2016 5:58 am
by cam
Hi,
thank you very much.
I translated in C# and it works also well for me.
greetings
Christian
Re: List materials in dropdown
Posted: Thu Jul 07, 2016 2:27 pm
by gmanucci
nice code!
Thanks, JuP!