ds-blue-logo
Preview  |  SOLIDWORKS USER FORUM
Use your SOLIDWORKS ID or 3DEXPERIENCE ID to log in.
RPRandy Petkoff28/09/2009

Hello All,

I am having difficulties getting custom properties from a drawing view unless that view is manually selected.  I am trying to use the Get First View method and ultimately would like the macro to go through all views and grab each components properties.  Below is what I have at this point; but for this macro to work I need to use the Selection Mgr method with manually selecting the view. And I would rather have the Get First/ Next view method do the job.

Any help would be greatly appreciated.

Option Explicit

Sub main()

    Dim swApp As SldWorks.SldWorks
    Dim swModel As SldWorks.ModelDoc2
    Dim swDraw As SldWorks.DrawingDoc
    Dim swSheet As SldWorks.Sheet
    Dim swView As SldWorks.View
    Dim swDrawModel As SldWorks.ModelDoc2
    Dim swSelMgr As SldWorks.SelectionMgr
       
    Set swApp = Application.SldWorks
    Set swModel = swApp.ActiveDoc
    Set swDraw = swModel
    Set swSheet = swDraw.GetCurrentSheet
    Set swSelMgr = swModel.SelectionManager
   
       
    
    Set swView = swDraw.GetFirstView

    Set swView = swSelMgr.GetSelectedObject5(1)
    'While Not (swView Is Nothing)
        Set swDrawModel = swActiveView
      
        'While Not (swView Is Nothing)
           
             Debug.Print swDrawModel.GetCustomInfoValue("", "PoundWt")
            
    'Wend
            'Set swView = swView.GetNextView
       
   'Wend

End Sub