Macro generation pdf and step

Hi all!

First of all, thank you to the forum for existing, it is a real source of solution, and thank you all for your participations, which make it live!

I have come to join you in a new company and I would like to set up new ways of working.

To do this, I'm looking for a macro that will generate for me, from the 3D sldprt part, a STEP file with in the file name, the name of the part + the revision, i.e. the NomPièce_Révision.stp format, with if possible an icon when you are on the part window in the taskbar.

And for drawings, a macro that exports the drawing, with the revision and description of the part, i.e. the NomPièce_révision - description.pdf format, while taking up the personalized properties of the part (it is at the part level that the revision and description fields are edited).

Hoping to have been precise in my request, I thank you in advance for your help!

Have a nice day @ all

Hello
By accumulating macros already available, you can create a macro that does the job according to the type of file opened (a single launch icon in the interface).
It's also good to get started if you have a little knowledge of VBA :slight_smile:

there is where the bottom hurts... It's because I've never touched a macro in my life.
I tried to open some to see the contents, but I get lost...

I have some time on my lunch break, so what is the name of the custom properties (review and description) so that I can provide the final code directly?
Do we agree that File Name = Part Name?

yes absolutely
file name = part name
Template Utilisés.zip (136.5 KB)

I allow myself to attach the files with the exact names and properties as they are named

Thank you so much for the help

Is it possible to have comment lines in the code? So that I can be guided and maybe make it evolve over time, without bothering everyone :wink:

Also, for requesting an icon in the Solidworks taskbar, how does it work?

Re
Attached is the code commented as much as possible.
The .dot having no properties I put xxx, to change to the right values
Macro-PDF_STEP.swp (87.5 KB)

2 Likes

Hello Cyril.f,

Thank you for this work!!

However, I don't know about .swp files and I don't know with which application to open them :confused:

oops I think I saw how to open it...

I'm testing this step :slight_smile:
Thanks again!!

This is the native format for macros.
See this link to launch and add a quick button:

Hi all

Thanks once again to Cyril.f, the macro works great!!

Just a downside for me, because when reading other posts (here and on other forums), macros can't read custom properties?

I explain myself by custom properties:
in order to have a pleasant interface, with drop-down list, calendar to click, etc... I used the form editor

This allows me to have a nice tree structure to fill in the fields of the desired properties

Except that this only edits the fields in the configuration-specific tab


And a priori not readable by macros

Is there a trick either to fill in the fields of the customize tab (and they readable by macros) or that macros can read the fields in the tab specific to the configuration?

In addition, once I have filled in the fields of my part, they are not automatically written in the fields of the properties of the drawing (of the part concerned)

How do I fill in only the fields in the room and have them written directly in the MEP?

A lot of questions, I know, but I'm trying to understand as best I can to be more autonomous

Thank you all!!

Hello
If it's readable via macros when the file is opened in SW. It's only if you want to play them without opening the file, that's where it gets complicated.
In the macro I provided, you can add a processing to find out if there is any info in the configuration specific tab (only on part and asm).

Cyril.f could you let me know what I need to write in the macro to read the fields in the macro?

And is it possible to write the configuration-specific fields edited in the room, directly in the fields on the customize tab of the MEP?

Macros can read custom or configuration-specific properties, but not the same (macro) function for either.
For the last point there are macros to take the properties of the part and re-write them in the MEP, but the properties are also accessible from the MEP by going to the property of the part linked to the view.
Example for the material: $PRPSHEET:"Material" fetches the material from the part to the view referenced in the MEP, while $PRP:"DATE" refers to the property of the MEP:
https://help.solidworks.com/2020/french/EnterprisePDM/Admin/t_creating_SOLIDWORKS_PRP_PRPSHEET_links.htm

I want the fields on the property map to be populated by the fields filled in the room and not just the block.
For the moment, I fill in the properties of the part but in the drawing, the fields of the property card are empty, while my title block follows those of the part

As a result, because the fields are empty, the macro does not run as it should

There are two possibilities: either you get the 3D attached to the plane and you inject the values into the properties of the drawing.
Another solution: scan the cartridge and retrieve the properties we are interested in and copy them into the properties of the drawing.
To retrieve the values that are in the specific to the configuration of a part or asm you have to change in these lines:
sRevision = swModel.CustomInfo2("", "xxx")
By:

sRevision = swModel.CustomInfo2("Défaut", "xxx") 

Default being the name of a configuration. If several configurations are required, the different information must be scanned in case there are differences and the right treatment applied.

1 Like

Which is the easiest?
Would you rather read the info that is the cartridge?

And if not, how to inject the 3D values into the MEP property map?

Both are simple.
After another solution in the properties you just have to put in the expression column $PRPSHEET:"xxx" and it allows you to link the properties and values.
To see if it spreads in the form

It doesn't read the value

And furthermore, it generates an error when running the macro

Capture Erreur Macro

And when I press debug

So we need to change in the macro the fields that are the cartridge to read?

Like what
change
sDescription = swModel.CustomInfo2("  ", " Description ")

by

sDescription = swModel.CustomInfo2("  ", " $PRPSHEET"Description ")

Or do I mess up completely?

Oops, yes it's not evaluated. Apart from the macro I don't see any other solutions