The real art of programming is deconstructing your problem in pieces so small that a computer can execute them. Start small and don't try to everything at once.
It this case that would mean:
- Connect to Solidworks (check any macro on this forum for an example, the macro recorder result isn't great)
- Get the current document (see 1)
- Make sure a document is open (check to see if the model from step 2 isn't null), otherwise exit
- Make sure the document is a drawing, otherwise exit
- Get the number of sheets (n) of this drawing
- Get the names of sheets in an array
- Loop through the sheets until page n, so:
- Get the name of the current sheet
- Activate the sheet using the name
- Make the right layers visible (just checked, this needs to be done per page)
- Save sheets 1 to n-1 to PDF
- Save sheet n to DXF
When you want to deal with multiple files at once, you can either write you own software to do that or use existing software like BatchProcess of #Task. I don't think #task is very user friendly, but it has some smart features to prevent timeouts and other cock-ups.
It seems that every single company has trouble printing documents the right way. Does nobody know any software that can do this properly? Otherwise I'm gonna build it myself soon.
(check any macro on this forum for an example, the macro recorder result isn't great)
Agreed with Peter B.
This task is not hard to write but we don't have time to create a whole macro for you
have your checked Keith Rice site which includes many sample macros (need to be a member)
I would have the time actually, for a fee Peter, you can message me to create that macro for you. That saves you the time of finding it all our yourself.
I never asked for any one to write the whole macro for me.
Sorry, I shouldn't say "for you" - I mean it in general
I like this reply!
I'm not trying to print multiples files I was just trying to figure out the layers for printing and change which pages to print I was able to figure it out.
The SOLIDWORKS API Help section looks like it has an example written that you can reference
This example shows how to get the layers in a drawing document.
Public Enum swLineStyles_e
swLineCONTINUOUS = 0
swLineHIDDEN = 1
swLinePHANTOM = 2
swLineCHAIN = 3
swLineCENTER = 4
swLineSTITCH = 5
swLineCHAINTHICK = 6
swLineDEFAULT = 7
Public Enum swLineWeights_e
swLW_NONE = -1
swLW_THIN = 0
swLW_NORMAL = 1
swLW_THICK = 2
swLW_THICK2 = 3
swLW_THICK3 = 4
swLW_THICK4 = 5
swLW_THICK5 = 6
swLW_THICK6 = 7
swLW_NUMBER = 8
swLW_LAYER = 9
Dim swApp As SldWorks.SldWorks
Dim swModel As SldWorks.ModelDoc2
Dim swLayerMgr As SldWorks.LayerMgr
Dim vLayerArr As Variant
Dim vLayer As Variant
Dim swLayer As SldWorks.Layer
Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc
Set swLayerMgr = swModel.GetLayerManager
Debug.Print "File = " & swModel.GetPathName
Debug.Print " Current Layer = " & swLayerMgr.GetCurrentLayer
vLayerArr = swLayerMgr.GetLayerList
For Each vLayer In vLayerArr
Set swLayer = swLayerMgr.GetLayer(vLayer)
Debug.Print " " & swLayer.Name
Debug.Print " Color = " & swLayer.Color
Debug.Print " Description = " & swLayer.Description
Debug.Print " GetId = " & swLayer.GetId
Debug.Print " Style = " & swLayer.Style
Debug.Print " Visible = " & swLayer.Visible
Debug.Print " Width = " & swLayer.Width
yeah.. it's all you need !!!
Thanks for the info.