Question

Set swDocument = Application.SldWorks.ActiveDoc
Set Sheet = swDocument.GetCurrentSheet
MySheet = Sheet.GetName
MyPath = swDocument.GetPathName
Const swSelNOTES = 15

I'm taking a Solidworks 2010 macro and attempting to update it to Solidworks 2013 and it seems they have removed/depreciated the GetCurrentSheet property on Application.SldWorks.ActiveDoc does anyone know the current method to get that?

Was it helpful?

Solution

As far as I remember and know, there was at no time a GetCurrentSheet method on a ModelDoc2 object, it is, in fact, a method of the DrawingDoc type.

So, reading your code, I would suppose that ActiveDoc is not a DrawingDoc. To be sure, simply use:

Dim swApp       as SldWorks
Dim swDrawing   as DrawingDoc
Dim swDocument  as ModelDoc2

Set swApp      = Application.SldWorks
Set swDocument = swApp.ActiveDoc 
Set swDrawing  = swDocument

If swDrawing is Nothing Then
   MsgBox "No valid drawing doc!"
   Exit Sub
End If

Or

Dim swApp       as SldWorks
Dim swDrawing   as DrawingDoc
Dim swDocument  as ModelDoc2

Set swApp      = Application.SldWorks
Set swDocument = swApp.ActiveDoc 

If swDocument.GetType() <> swDocumentTypes_e.swDocDRAWING Then
   MsgBox "No valid drawing doc!"
   Exit Sub
Else 
    Set swDrawing  = swDocument
End If

And you know if this is the case. I would also recommend you to check the following additional information from the API documentation:

http://help.solidworks.com/2013/English/api/sldworksapi/solidworks.interop.sldworks~solidworks.interop.sldworks.idrawingdoc~getcurrentsheet.html

http://help.solidworks.com/2013/English/api/sldworksapi/Get_and_Set_Sheet_Properties_Example_VB.htm

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top