List materials in dropdown

All topics about specific development with COM interface, LIP language, API in VB, ...

Moderators: remi77, jacs, Daniel

cam
Master Corporal
Master Corporal
Posts: 39
Joined: Fri Oct 02, 2009 9:46 am
TopSolid Module: TopSolid'Cam
TopSolid Version: 7.8
Location: Germany

List materials in dropdown

Unread post 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.
Last edited by cam on Thu Jun 30, 2016 5:57 am, edited 1 time in total.
Greetings
Chris
cam
Master Corporal
Master Corporal
Posts: 39
Joined: Fri Oct 02, 2009 9:46 am
TopSolid Module: TopSolid'Cam
TopSolid Version: 7.8
Location: Germany

Re: List materials in dropdown

Unread post 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
Greetings
Chris
User avatar
JuP
Major
Major
Posts: 169
Joined: Tue Sep 09, 2014 5:45 pm
Answers: 6
TopSolid Module: TopSolid'Steel
TopSolid Version: 7.14

Re: List materials in dropdown

Unread post 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
Julien POIROT
TopSolid'Steel Product Manager
Youtube
GrabCad
Facebook
cam
Master Corporal
Master Corporal
Posts: 39
Joined: Fri Oct 02, 2009 9:46 am
TopSolid Module: TopSolid'Cam
TopSolid Version: 7.8
Location: Germany

Re: List materials in dropdown

Unread post by cam »

Hi,

thank you very much.
I translated in C# and it works also well for me.

greetings
Christian
Greetings
Chris
gmanucci
Master Corporal
Master Corporal
Posts: 49
Joined: Tue Sep 29, 2015 2:48 pm
TopSolid Module: TopSolid'Cam
TopSolid Version: 6.26

Re: List materials in dropdown

Unread post by gmanucci »

nice code!

Thanks, JuP!
Post Reply