Using SLDW Macros

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

Lucas

I did the usual manipulations (without going through the macro)

File/Save As/DWG Format.

when I open the DWG "with AUTOCAD2013, the same message actually appears.

As I said in a previous post about the case:

 

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

 

Do you have a personal property or something in the codification that tells you this:

 

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

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

 

The part:

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

 

Should look like this:

 

Select case type 'select case avoids many nested FIs

box = "CAR" 'if type = car

 Folder = "C:\CAR" 'we save in the car folder

case = "MOTO" 'ditto...

  Folder = "C:\MOTO"

box = "TRACTOR"

  Folder = "C:\TRACTOR"

case = "BIKE"

  Folder = "C:\VELO"

else' case 'if other type or no type, error

 msgbox "Type Error1"

 exit

end select

 

Select case type2 

case = "CUT" 'if type1 = cut

 Folder = Folder & "\CUT" 'we add cut to the folder

case = "CAB"

 Folder = Folder & "\CAB"

case = "4x4"

 Folder = Folder & "\4x4"

case = "MONOSPACE"

 Folder = Folder & "\MONOSPACE"

case else

 msgbox "Type2 Error"

 exit

end select

 

For information:

type1 and type2 must be variables that already exist in your files or to be asked of the user when launching the macro.

swDraw.SaveAs(Folder & "\PDF\" & FileName & ".PDF")
swDraw.SaveAs(Folder & "\DWG\" & FileName & ". DWG")

1 Like

To use the FSO, you need to add the Microsoft Scripting Runtime reference to your macro

See screenshot


capture.jpg
4 Likes

For the message problem when opening with AutoCAD, there is no box to uncheck so that the message no longer appears?

 

Otherwise see this link /

 

http://autodesk.blogs.com/between_the_lines/2005/06/how_to_tell_if_.html

Did you get out of it?

1 Like

Hello, I want to thank you for your help.

 

For the moment, the macro suits our BE. We'll just do the DWG and PDF files, by hand.

We already save a lot of time.

 

The company may invest in EPDM...

We will work on the file storage at that time.

 

Kind regards.

 

 

2 Likes

Please designate the best answer in this case!