Extracting file information from model & Drawing

Hi Guys,  

I'm completely new to creating a macro, but I have to add a suffix to all the drawings which are based off some information from the models and drawings. The information is: 

-If model is part or assembly

-Number of sheets in the drawing

The goal is then to rename or do a pack and go of the SW files and respective drawing to add this on to the existing part#. 

I'm not really sure where to even start, if you have any useful links that can help me get started, that would be greatly appreciated!

Thanks! 

SolidworksApi/macros
Answers 3
FR
FR 2021-04-08 Best Answer

Hello,

You will need several steps:

- find the properties

- copy the files with a new filename

- update the internal references in assemblies, drawing, (and eventually also parts) with the filenames of parts and assemblies defined in the previous step.

Depending if you want to do that only on the files opened, or without opening the files at all, it will require different solidworks functions.

The first step for example will require either 2017 SOLIDWORKS API Help - GetSheetCount Method (IDrawingDoc) 

or 2017 SOLIDWORKS API Help - GetSheetCount Method (ISwDMDocument4) 

DG
DG 2021-04-08

As Fifi mentioned the required steps, it can be done via macro but I've following concerns: 

1. Are you using any PDM system? If not then open drawing won't work since model and drawing name are not sane. 

2. What would happen when number of sheets would change? 

3. How you create the drawings in case of configuration? 

NP
NP 2021-04-08

‌,

Please contact ‌ and he will be able to help with you project.