Using SLDW Macros

Hello

 

I'm on SLDW 2014 in 64bits.

 

I did some research to save time when saving our files.

So let me explain.

 

Our solidworks MEPs must be saved in 3 different formats each time. An SLDDRW, a PDF, and a DWG (in 2000 or 2002 version).

These files are categorized into respective files.

At the moment, we open the solidworks MEP, then save us in PDF, then we do the same in DWG, while using a conversion file.

So, it takes quite a bit of time.

 

And I saw, during my research, that there are a multitude of macros for this.

 

But who could direct me to carry out the manipulations correctly.

And where are PDF and DWG files saved?

 

Thank you in advance.

Recurring topic on Lynkoa

http://www.lynkoa.com/search/enregistrer%20pdf%20dwg

there are ready-made tools

as well as macro

@+;-)

 

4 Likes

Hello

 

As I have stated here:

http://www.lynkoa.com/forum/3d/comment-enregister-des-plusieurs-fichiers-slddrw-en-pdf-et-dxf

 

If you have the MyCAD tools, there is BatchConverter,

 

Otherwise it's possible by macro:

 

http://www.lynkoa.com/forum/cao/macro-d-enregistrement-en-pdf-et-dxf-dan...

http://www.lynkoa.com/forum/3d/macro-d-enregistrement-en-pdf

http://www.lynkoa.com/forum/3d/convertion-pdf-en-2014

http://www.lynkoa.com/forum/3d/macro-enregistrement-en-pdf-dans-un-dossi...

http://www.lynkoa.com/forum/3d/plan-sldrw-en-pdf-dans-dossier-different

 

In particular the first link which gives in better response a functional macro where simply small modifications are necessary.

3 Likes

For beginners in VBA see also my tutorial where each line is commented:

 

http://www.lynkoa.com/tutos/3d/macro-enregistrer-sous-avec-solidworks

 

BatchConverter is available here at 70 € minus a cent:

 

http://www.lynkoa.com/store/fr/tools-et-macros/utilitaires/utilitaire-batchconverter.html

 

And as @flegendre says in the 1st link:

 

"If you have the EPDM add-on , it's even better, you set a "conversion task" (pdf, dxf,iges,....)  automatic on your Workflow, when the drawing is validated."

4 Likes

To answer the last question:

 

With a macro you can choose to define a common folder, a folder by file type, a folder according to a custom property (client, deal number) or offer a file explorer to choose each time where to save the different files.

 

In BatchConverter, you have to save the manipulation once to remind it each time: 

You can choose a folder for a file type as well.

1 Like

Thank you for these answers,

But, when I open the tutorial (http://www.lynkoa.com/tutos/3d/macro-enregistrer-sous-avec-solidworks), I am disconnected from the site, and can no longer access it.... What for?

Oh, and additional question on this subject...

Are we obliged to open the plan file with solidworks to save in the other formats?

 

I'll take the example of a person who would have the task of performing these manipulations, but who won't have the version of SLDW as me, or who won't have one at all.

I believe that in any case SolidWorks is needed on the PC to do the conversion.

1 Like

a par ça to convert without a base license log SW

http://www.datakit.com/convertisseurs-cao/solidworks-3d-vers-pdf-3d/3-72-0.html

http://www.datakit.com/fr/cross_manager.php

See also

http://helpx.adobe.com/fr/acrobat/kb/supported-file-formats-acrobat-reader.html

@+ ;-)

As Lucas says, there are code examples to do this, on this forum or others that can be found from google

All these examples require SW, 

 

It is possible to use eDrawing's APIs to create a PDF (via a PDF print driver) or an image file, but nothing more.

 

 

7 Likes

I specify that the conversion quality is not guaranteed via eDrawing

4 Likes

Well, I searched through all these links, and I found for the moment, the macro that allows the recording in the 2 formats.

 

Now I have to find a way to save them in a specific folder.

 

And finally, check in which version of autocad it saves them.

Then

The recording version does not depend on the macro, but on the settings set in AutoCAD.

So this point is resolved.

 

When saving the DWG and PDF, the macro creates a sufix to the plan name. Which is "space -", and I'll delete it.

I think it comes from : FileName = Left(swDraw.GetTitle, Len(swDraw.GetTitle) - 9)

 

 

And before putting the site on our network.....

 

We arrange our files as follows:

 

top-level file: CAR or  MOTORCYCLE or TRACTOR or BICYCLE

second level file:  Cabriolet or Coupe or MPV or 4x4

Third Level File: 3D / DWG / PDF

 

 

So in our first levels, we have a category

a specific size or type

Third, sorted folders of files.

 

And so this third level is found in all the files. But how do you tell the macro that you have to save the file in a very specific DWG folder (knowing that there are dozens of them)

 

 

in fact it is better to use 

 

Dim fso As New Scripting.FileSystemObject
Set fso = CreateObject("Scripting.FileSystemObject") ' add the reference "microsoft Scripting Runtime

 

FileName = fso. GetBaseName(swDraw.GetPathName)

 

Because swDraw.GetTitle retorune the name of the ficheri + the name of the mourner and we stitched 9 characters to remove the name of the sheet!

 

6 Likes

I just replaced FileName = Left(swDraw.GetTitle, Len(swDraw.GetTitle) - 9)

by

FileName = fso. GetBaseName(swDraw.GetPathName)

 

And at runtime, runtime error "424"

 

.. What for?

Mistake on my part I think.

 

because the macro, now names DWG and PDF files as the origin.

 

Update on the macro.

 

Sub main()

Set swApp = Application.SldWorks
Set swModel = swApp.ActiveDoc

' Check to see if a drawing is loaded.

If (swModel Is Nothing) Or (swModel.GetType <> swDocDRAWING) Then

swApp.SendMsgToUser ("To be used for drawings only, Open a drawing first and then TRY!")

' If no model currently loaded, then exit
Exit Sub

End If
 
Set swDraw = swModel

Filepath = Left(swDraw.GetPathName, InStrRev(swDraw.GetPathName, "\"))
Set fso = CreateObject("Scripting.FileSystemObject") ' add the reference "microsoft Scripting Runtime
FileName = fso. GetBaseName(swDraw.GetPathName)

swDraw.SaveAs (Filepath + FileName + ".PDF")
swDraw.SaveAs (Filepath + FileName + ". DWG")

End Sub

 

 

A negative point,

 

I just opened the DWG backup, and I get the following message:

 

The DWG file was saved in an application that was not developed by Autodesk or does not have an Autodesk license. What do you want to do?

 

 

When I continue the opening, nothing special, but we cannot allow such a message to appear when it is opened. (Quality audit obliges)

 

How to do it?

It's going to be complicated to answer dozens of questions in this discussion!

 

Why not open a new question for each problem?

 

For the macro, for the DWG error, etc?

2 Likes

When saving as DWG from SolidWorks, is there the same message?

If yes (and it probably is), you need to change the export options to DWG:

 

File> Save-As> Choose DWG, and there an Options button appears

 

What software is DWG opened with?

2 Likes