AnsweredAssumed Answered

retrieving the part component names of all drawing views in a multi sheet drawing

Question asked by John Smith on May 14, 2016
Latest reply on May 15, 2016 by Deepak Gupta

I have the following code to retrieve the part component names of all drawing views in a multi sheet drawing. it works fine for views containing assemblies only but when it comes to views of part components it returns NULL for the array "vDrawChildCompArr", your help is appreciated, thanks.


Dim sheetCount As Long

    Dim viewCount As Long

    Dim currentSheetNum  As Integer

    currentSheetNum = 0

    Dim ss As Variant

    ss = swDraw.GetViews                                              'The return value is an array of arrays with a length equal to the number of sheets in the drawing document.

    For sheetCount = LBound(ss) To UBound(ss)           'goes through all sheets

        currentSheetNum = currentSheetNum + 1

        Dim vv As Variant                                                    'defines a variable to explore through the views of each sheet

        vv = ss(sheetCount)                                                'gets views of each sheet

        For viewCount = 1 To UBound(vv)                          'first element of the array is the sheet itself and we dont need it

            Debug.Print currentSheetNum

            Set swView = vv(viewCount)

            Set swRootDrawComp = swView.RootDrawingComponent

            vDrawChildCompArr = swRootDrawComp.GetChildren

                    For Each vDrawChildComp In vDrawChildCompArr

                        Set swDrawComp = vDrawChildComp

                        Set swComp = swDrawComp.Component

                        strName = swComp.Name2

                        Debug.Print (strName)

                    Next vDrawChildComp

           Next viewCount

    Next sheetCount