API - Retrieve File Name

Hello

I'm trying to create a fairly simple macro (I think) that would allow me to save a drawing in PDF and DWG and store them in the appropriate folder. So I saved the macro while saving the document, but how to indicate in the macro that it should take the name of the document to be saved and not a name already defined in the mcro (I don't know if I'm clear...)


api.png

See this link

http://www.lynkoa.com/forum/3d/macro-pour-enregistrer-un-plan-sw-en-pdf-avec-l-indice-de-revision

4 Likes

Hello

I use:

 sPathName = swModel.GetPathName' retrieves the folder name
 sPathName = Left(sPathName, Len(sPathName) - 7)
 sPathName = sPathName + ".dxf"  ' Edit: add dxf at the end of the variable to save in this format (can be replaced by pdf)

 

then:  bRet = swModel.SaveAs4(sPathName, swSaveAsCurrentVersion, swSaveAsOptions_Silent, nErrors, nWarnings)

3 Likes

@gt22: I got the macro in the link, but it saves the files in the folder where the SolidWorks drawing is located and I don't know where to modify the code to indicate my paths :-(

1 Like

Hello

Personally, I don't know anything about macro creation, but when I need to do pdf and dwg exports of plan folders I use the task scheduler, there is an export function provided for this purpose. You can even program it to work at night.

On the other hand, knowing macros interests me strongly, if someone  has documentation to train me, I'm interested.

May the force be with you.


planificateur.jpg
3 Likes

@ DoubleL

Why doesn't it suit you?

whether this is recorded in the drawing files of the said part or assembly

1 Like

In fact we have a folder where the SolidWorks drawings are recorded, a folder for the MEP in DWG and a folder for the MEP in PDF... A top organization... Laughing out loud

I tinkered with the file a little and I manage to change the path but I lose the name of the file... But I'll get there eventually :-)

1 Like

Look from this macro, you will find a method to choose a folder.

Otherwise you could put your code and a detail of the tree (if the folders all have the same name)? I have some time to lend a hand.


step_en_masse.swp
1 Like

and on the names of folders with an extension 

Types

DXF for DXF

PDF for PDF

SLDDRW for SLDRW

then just sort through the extensions and store them where it should be, right?

 

1 Like

By dint of tinkering and searching thanks to the GT22 link, I finally have a macro that works and allows me to save my PDF file in a certain folder and in parallel my DWG file in another folder.

Thank you all!!

2 Likes