List materials in dropdown

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

Moderators: remi77, jacs, Daniel

Post Reply
cam
Master Corporal
Master Corporal
Posts: 37
Joined: Fri Oct 02, 2009 9:46 am
TopSolid Module: TopSolid'Cam
TopSolid Version: 7.7
Location: Germany

List materials in dropdown

Post by cam » Mon Jun 06, 2016 12:04 pm

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: 37
Joined: Fri Oct 02, 2009 9:46 am
TopSolid Module: TopSolid'Cam
TopSolid Version: 7.7
Location: Germany

Re: List materials in dropdown

Post by cam » Wed Jun 29, 2016 6:52 am

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
Chief
Chief
Posts: 109
Joined: Tue Sep 09, 2014 5:45 pm

Re: List materials in dropdown

Post by JuP » Wed Jun 29, 2016 11:28 am

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 . P
Youtube
Grabcad

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

Re: List materials in dropdown

Post by cam » Thu Jun 30, 2016 5:58 am

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: 47
Joined: Tue Sep 29, 2015 2:48 pm
TopSolid Module: TopSolid'Cam
TopSolid Version: 7.7

Re: List materials in dropdown

Post by gmanucci » Thu Jul 07, 2016 2:27 pm

nice code!

Thanks, JuP!

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests