Hi all
I currently have a macro that saves my solidworks drawing in PDF, DXF and STEP but I have a slight problem.
Sometimes the recording location doesn't match the path of my drawing.
How do I recover the path of my drawing that is open and force the files to be saved there?
Thank you in advance.
Kind regards.
Hello
Before you run the macro, do a saved under the SW plane in the right folder. and then executes the macro.
If it's the macro I know, it saves by default in the last folder where you made a recording.
may the force be with you.
2 Likes
Thank you master obiwan kenobi for your answer.
Yes I know this manipulation but unfortunately I don't necessarily think about it because I am often on several files at the same time, that's why if it would be done automatically, it would avoid some problem.
because I think it's not much if you know a little about it (not like me)..
Thank you again for your answer but don't forget "I AM YOUR FATHER"
Attached is the macro I'm currently using.
pdf_dxf_et_step.swp
1 Like
Hello
Do you know anything about VBA and APIs?
SPathName = SwDraw.GetPathName 'retrieves the name and full path of the current document
FileName2D = Right(SPathName, Len(SPathName) - InStrRev(SPathName, "\")) 'retrieves the filename with the extension
Dirname = Left$(SPathName, InStrRev(SPathName, "\")) 'Retrieves the full path
Good night
Hello
In your macro you already retrieve the path of the folder using the variable "Filepath" but this is not used in the "saveas" function so it's normal that it doesn't work as you want ... In addition, file names are constructed using the "+" sign when it is better to use the "&" symbol to concatenate multiple strings...
And small problem in your macro, you use a "SendKeys "^{q}"" function to force the regeneration but you have to be careful with this kind of command because it doesn't always give the desired effect, see HERE, for example for me it unlocks the numeric keypad ...
In short, I'm sorry to announce that, from my point of view, the best solution would be to re-write this macro ...
Kind regards
Hello
First of all, thank you for your answers.
Yes I think it would be a good solution to rewrite it but unfortunately I don't have the necessary skills to do that. I made this macro by getting bits of macro from the internet and tinkering a little. But I don't know much about it, whether it's in VBA or API to answer your question Emmanuel.
And to force the save in the recover path, I can't find how to do it. Can you help me please.
Kind regards.