hi
i am trying to get the modeldoc from component ofview.rootdrawingcomponent.
I am not getting the model doc from component incase of part view.
I am getting swRootComp =Nothing after this line of code SetswRootComp = swRootDrawComp.Component
This is the sample code
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 swActiveView As SldWorks.View
Dim bRet As Boolean
Dim swRootDrawComp As SldWorks.DrawingComponent
Dim swRootComp As SldWorks.Component2
Dim swRootCompModelDoc As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
Set swActiveView = swDraw.ActiveDrawingView
Set swRootDrawComp = swActiveView.RootDrawingComponent
'Check whether Root drawing component is nothing or not
If (swRootDrawComp Is Nothing) Then
Exit Sub
End If
Debug.Print ""; swRootDrawComp.Name
Set swRootComp = swRootDrawComp.Component
'Check whether Root component is nothing or not
If (swRootComp Is Nothing) Then
Exit Sub
End If
Set swRootCompModelDoc = swRootComp.GetModelDoc
'Check whether Root component's Model document is nothing or not
If (swRootCompModelDoc Is Nothing) Then
Exit Sub
End If
End Sub
Thanks in advance
Anil GhotekarSolidworksApi macros
i am trying to get the modeldoc from component ofview.rootdrawingcomponent.
I am not getting the model doc from component incase of part view.
I am getting swRootComp =Nothing after this line of code SetswRootComp = swRootDrawComp.Component
This is the sample code
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 swActiveView As SldWorks.View
Dim bRet As Boolean
Dim swRootDrawComp As SldWorks.DrawingComponent
Dim swRootComp As SldWorks.Component2
Dim swRootCompModelDoc As SldWorks.ModelDoc2
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swDraw = swModel
Set swSheet = swDraw.GetCurrentSheet
Set swActiveView = swDraw.ActiveDrawingView
Set swRootDrawComp = swActiveView.RootDrawingComponent
'Check whether Root drawing component is nothing or not
If (swRootDrawComp Is Nothing) Then
Exit Sub
End If
Debug.Print ""; swRootDrawComp.Name
Set swRootComp = swRootDrawComp.Component
'Check whether Root component is nothing or not
If (swRootComp Is Nothing) Then
Exit Sub
End If
Set swRootCompModelDoc = swRootComp.GetModelDoc
'Check whether Root component's Model document is nothing or not
If (swRootCompModelDoc Is Nothing) Then
Exit Sub
End If
End Sub
Thanks in advance
Anil GhotekarSolidworksApi macros