Macro step

Hello

I try in vain to create a macro that would allow to save a STEP (AP214) of the file in use. The particularity is to use property names specific to the active configuration (because file with several configurations) as the file name. The properties to be used are " N_PLAN " and " IND_SUIVANT " separated by a " - " (Dash of 6). And finally, I want to save this file in this directory: Z:\STEP

Example:
N_PLAN Property: PS270
IND_SUIVANT Property: B
So the name of the final file is: PS270-B.step

Thank you in advance,

Hello
Try this
macro_STEP.swp (28 KB)
may the force be with you.

2 Likes

Thank you... Super fast type

It saves me the file, in the right folder... but on the other hand, the name of the output file is the same as the SLDPRT file. It does not use configuration-specific properties

Update: I just retested with another file, it doesn't work anymore... Weird thing

Hello.

I didn't look at the macro of @OBI_WAN ... But what is certain is that it would be more positive for you to open it and try to understand what is in it. Having a turnkey thing won't help you when it doesn't work anymore (change of version, etc)

Basically, try, try and come and ask questions about your journeys :slight_smile:

2 Likes

Hello
Code below to test, I didn't manage the control of the presence of the step file and its deletion or not.

Edit: deleted wrong macro file

1 Like

Thank you all for your answers but macros don't work :sob:

I know absolutely nothing about macro coding and I don't have time to look into this part.

Thanks anyway and I'll try to go through my SolidWorks reseller to try to find a solution.

You had time to post your request.
Take 5 minutes to explain more clearly what is not working.
It's also a certain respect for @cyril.f and @OBI_WAN who have wasted some time to help you solve your problem.

1 Like

Hello
You just have to go to the macro editor and activate some references (there is a function that controls the presence of the folder and creates it if necessary but you have to activate the references).
It goes through this (tools->references)
image

2 Likes

This option is already checked in my SolidWorks (FYI, I don't know if there is an important one but it's SolidWorks 2021)

When I run your macro, I get runtime error 91: Object variable or With block variable not defined

The only thing you forget in your macro @Cyril.f was the forgetfulness to uncomment your 2 constants added for testing.
If you correct these 2 lines (exchange constants to test your export) it works perfectly.
image
FYI, the export is done to C:\Export.

In case I copy the code to replace for you:

'Constantes
Const cDirSave = "Z:\STEP\"
'Const cDirSave = "C:\Export\"
Const cPropNumPlan = "N_PLAN"
'Const cPropNumPlan = "reference"
Const cPropRev = "IND_SUIVANT"
'Const cPropRev = "Indice_general"

In place of:

'Constantes
'Const cDirSave = "Z:\STEP\"
Const cDirSave = "C:\Export\"
'Const cPropNumPlan = "N_PLAN"
Const cPropNumPlan = "reference"
'Const cPropRev = "IND_SUIVANT"
Const cPropRev = "Indice_general"

Edit:
The apostrophe puts a line in comment and this line is therefore not processed.
Your export was therefore done to c:\Export with the name -.step since it did not find the properties.

1 Like

@sbadenis , oops, exactly, I thought I had purged. Not well awake

2 Likes

It's fixed:
ExporStep.swp (31.5 KB)

1 Like

It even happens to the best apparently.
So before crying wolf!
Perfectly written code, a beautiful textbook case.
Thank you @Cyril.f :stuck_out_tongue_winking_eye:

And well, it's perfect, it works perfectly. :smiley:

Thank you very much.

1 Like

Thank you for choosing the best answer and closing the topic as well, that's also the forum spirit:


Thank you!

1 Like