# Adding quantity and thickness to the name while saving the file

**URL:** <https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817>\
**Category:** Macro Library\
**Created:** [July 5, 2021, 10:44am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817 "2021-07-05T10:44:58Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Omur\_Tokman](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/omur_tokman/32/39_2.png) [@Omur\_Tokman](https://forum.cadmunity.com/u/Omur_Tokman)\
**Post date:** [July 5, 2021, 10:44am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/1 "2021-07-05T10:44:58Z")

</div>

Hello there,  
The macro below is artem’s  
This macro saves the sheet metal products in the assembly flat in a folder.  
I want to add sheet thickness and quantity to the file name you saved, I’ve been trying for about 4 days, but I still couldn’t get a result.  
the quantity and thickness I want to add is in summary information/Custom.

Is there anyone who can help me with this?

For example  
The result you want = Part1-1mmDKP-1 Piece  
–Const OUT\_NAME\_TEMPLATE As String = “DXFs\<_FileName_\>_\<_ **Thickness** _\>_\<_ **AutoQty** _\>.dxf”—  
2021-07-05\_13-18-07.png  
[https://www.codestack.net/solidworks-api/document/sheet-metal/export-all-flat-patterns/](https://www.codestack.net/solidworks-api/document/sheet-metal/export-all-flat-patterns/)  
 ![2021-07-05_13-18-07.png](https://forum.cadmunity.com/uploads/default/original/1X/115c03b4b6c10cb87aa14a5666ccf1391dfe1b72.png)  
 ![2021-07-05_12-40-59.png](https://forum.cadmunity.com/uploads/default/original/1X/1eb9285da9c4830792a10c4d9e512e6565f3ee33.png)

---

<div class="post-metadata">

**Author:** ![Jaylin\_Hochstetler](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/jaylin_hochstetler/32/40_2.png) [@Jaylin\_Hochstetler](https://forum.cadmunity.com/u/Jaylin_Hochstetler)\
**Post date:** [July 5, 2021, 11:49am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/2 "2021-07-05T11:49:40Z")

</div>

You have to put “$PRP:” before a the custom property you want in the file name.  
You also have to enter the address of the folder such as “C:\New folder\DXFs”. You had entered “D:” but you have to enter “D:\DXFs”. “DXFs” is the folder the macro creates.

```plaintext
Const OUT_NAME_TEMPLATE As String = "C:\New folder<_FileName_>_<$PRP:AutoQty>_<$PRP:Thickness.dxf"

```

Attached is the macro you posted revised with the custom properties. I also attached my version of it which includes options to give the folder a different name, export with or without sketches (which would be for etching), export with or without bend lines, and enter a different location for the folder either via browsing or entering the address.  
[Omur DXF Export.swp](https://forum.cadmunity.com/uploads/short-url/4qQ1pzLSJiCYhOcricnYUyP0Hfw.swp) (165 KB)

---

<div class="post-metadata">

**Author:** ![Omur\_Tokman](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/omur_tokman/32/39_2.png) [@Omur\_Tokman](https://forum.cadmunity.com/u/Omur_Tokman)\
**Post date:** [July 5, 2021, 12:39pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/3 "2021-07-05T12:39:56Z")

</div>

> [@](#):
>
> You have to put “$PRP:” before a the custom property you want in the file name.  
> You also have to enter the address of the folder such as “C:\New folder\DXFs”. You had entered “D:” but you have to enter “D:\DXFs”. “DXFs” is the folder the macro creates.
> 
> ```plaintext
> Const OUT_NAME_TEMPLATE As String = "C:\New folder<_FileName_>_<$PRP:AutoQty>_<$PRP:Thickness.dxf"
> 
> ```
> 
> Attached is the macro you posted revised with the custom properties. I also attached my version of it which includes options to give the folder a different name, export with or without sketches (which would be for etching), export with or without bend lines, and enter a different location for the folder either via browsing or entering the address.

Hi Jaylin,  
Thank you so so much, both work perfectly! \>\<  
And thank you for teaching me how.

---

<div class="post-metadata">

**Author:** ![DLZ\_SWX\_User](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/d/e36b37/32.png) [@DLZ\_SWX\_User](https://forum.cadmunity.com/u/DLZ_SWX_User)\
**Post date:** [December 20, 2021, 8:39pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/4 "2021-12-20T20:39:26Z")

</div>

We have been using this Macro from @artem 's also. It works very well.

We have modified it to give us the quantity of parts needed of a particular DXF, if a multi bodied part has a linear pattern or a mirror image, by using the following:

Const OUT\_NAME\_TEMPLATE As String = “\<$CLPRP:Sheet Metal Thickness\> \<_FileName_\> \<$CLPRP:QUANTITY\> \<_FeatureName_\> .dxf”

My question is can we somehow do the same from an assembly? Currently if I have a table with 4 legs, either 4 of the same inserted into the assembly or using linear pattern it will only tell me “1” in the file name not 4. If I create this same table as a multi body part it will tell me “4” in the file name not “1” which is what I would like for it to do in assemblies.

I have tried to use what was stated above could not get it to do what I wanted.

---

<div class="post-metadata">

**Author:** ![artem](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/artem/32/5127_2.png) [@artem](https://forum.cadmunity.com/u/artem)\
**Post date:** [December 21, 2021, 5:44am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/5 "2021-12-21T05:44:49Z")

</div>

~~[mention]~~DLZ\_SWX\_User[/mention], I have just published this new macro yesterday which addresses this issue: [https://www.youtube.com/watch?v=Vbxob8fU3R8](https://www.youtube.com/watch?v=Vbxob8fU3R8)

---

<div class="post-metadata">

**Author:** ![Jaylin\_Hochstetler](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/jaylin_hochstetler/32/40_2.png) [@Jaylin\_Hochstetler](https://forum.cadmunity.com/u/Jaylin_Hochstetler)\
**Post date:** [December 22, 2021, 12:27pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/6 "2021-12-22T12:27:05Z")

</div>

~~[quote=artem post\_id=16185 time=1640065489 user\_id=181]~~  
@DLZ_SWX_User, I have just published this new macro yesterday which addresses this issue: [https://www.youtube.com/watch?v=Vbxob8fU3R8](https://www.youtube.com/watch?v=Vbxob8fU3R8)  
[/quote]

Thanks, Artem!

---

<div class="post-metadata">

**Author:** ![Koubaleite](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/k/9dc877/32.png) [@Koubaleite](https://forum.cadmunity.com/u/Koubaleite)\
**Post date:** [July 30, 2024, 1:48pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/7 "2024-07-30T13:48:21Z")

</div>

> [@mike\_miller](#):
>
> We have been using this Macro from @artem 's also. It works very well.
> 
> We have modified it to give us the quantity of parts needed of a particular DXF, if a multi bodied part has a linear pattern or a mirror image, by using the following:
> 
> Const OUT\_NAME\_TEMPLATE As String = “\<$CLPRP:Sheet Metal Thickness\> \<_FileName_\> \<$CLPRP:QUANTITY\> \<_FeatureName_\> .dxf”
> 
> My question is can we somehow do the same from an assembly? Currently if I have a table with 4 legs, either 4 of the same inserted into the assembly or using linear pattern it will only tell me “1” in the file name not 4. If I create this same table as a multi body part it will tell me “4” in the file name not “1” which is what I would like for it to do in assemblies.
> 
> I have tried to use what was stated above could not get it to do what I wanted.

Hello, I have the same problem. How did you manage to have the right quantity ?

---

<div class="post-metadata">

**Author:** ![DLZ\_SWX\_User](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/d/e36b37/32.png) [@DLZ\_SWX\_User](https://forum.cadmunity.com/u/DLZ_SWX_User)\
**Post date:** [August 1, 2024, 12:33pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/8 "2024-08-01T12:33:45Z")

</div>

> [@](#):
>
> Hello, I have the same problem. How did you manage to have the right quantity ?

Since we are a custom welding shop & do a lot of prototyping & building one off machines & parts it was not a big issue. For the issue with the table mentioned we changed the quantity of the part in the part file to 4 instead of 1. This worked in this case as that leg is only used on 2 tables & is always use 4 per table, never less, never more. We also build custom truck toppers with multiples of the same door on a topper & do the same for these assemblies. This also worked on other parts & we used configurations just to change quantities.

In other instances I have created a multi bodied part with multiples of the same part in the proper locations for the assembly. This works if the part does not need to move in relation to the assembly. (This would have worked for the above mentioned table leg). Sorry I don’t have a better answer.

Also remember that BOM’s can show incorrect quantities also using the above scenario’s, if your not careful.

Hope this helps. I have not searched to see if maybe someone may have updated this macro or found another fix.

---

<div class="post-metadata">

**Author:** ![user6](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/u/f1d935/32.png) [@user6](https://forum.cadmunity.com/u/user6)\
**Post date:** [August 22, 2024, 2:27pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/9 "2024-08-22T14:27:31Z")

</div>

The Macro “Omur DXF Export.swp” works perfectly. Is there any way to also save .Step files together while saving DXF’s ?

---

<div class="post-metadata">

**Author:** ![user6](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/u/f1d935/32.png) [@user6](https://forum.cadmunity.com/u/user6)\
**Post date:** [August 22, 2024, 4:39pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/10 "2024-08-22T16:39:13Z")

</div>

@Ömür Tokman - Thanks a lot for such awesome code.  
Is it also possible to insert text inside part in DXF from custom property ? In my case i have Part engraving number in custom property which I have to manually insert as Text (yellow layer) in DXF everytime. Which later on laser marked on Part as “Part number”.  
This consume lot of time to open every DXF and insert text.  
Can you please check if this will be possible ?

---

<div class="post-metadata">

**Author:** ![Omur\_Tokman](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/omur_tokman/32/39_2.png) [@Omur\_Tokman](https://forum.cadmunity.com/u/Omur_Tokman)\
**Post date:** [August 25, 2024, 12:11pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/11 "2024-08-25T12:11:18Z")

</div>

> [@](#):
>
> @Ömür Tokman - Thanks a lot for such awesome code.  
> Is it also possible to insert text inside part in DXF from custom property ? In my case i have Part engraving number in custom property which I have to manually insert as Text (yellow layer) in DXF everytime. Which later on laser marked on Part as “Part number”.  
> This consume lot of time to open every DXF and insert text.  
> Can you please check if this will be possible ?

I’ll try this during the week.

---

<div class="post-metadata">

**Author:** ![Omur\_Tokman](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/omur_tokman/32/39_2.png) [@Omur\_Tokman](https://forum.cadmunity.com/u/Omur_Tokman)\
**Post date:** [August 26, 2024, 9:24am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/12 "2024-08-26T09:24:09Z")

</div>

> [@](#):
>
> The Macro “Omur DXF Export.swp” works perfectly. Is there any way to also save .Step files together while saving DXF’s ?

Remember that I am an amateur,  
you should try it before real use.  
macro can extract step files to dxf or step folder. But it is related to codes. you can move this feature to the form.

It is currently set to extract to the same folder, pay attention to the codes!  
2024-08-26\_12-16-38.png  
in the same folder  
 ![2024-08-26_12-16-38.png](https://forum.cadmunity.com/uploads/default/original/2X/c/c879fa3f8a54356c6700932b41e23e478b4e4c78.png)  
creates different folders.  
 ![2024-08-26_12-16-16.png](https://forum.cadmunity.com/uploads/default/original/2X/5/507889599ab520edd7f3801cec873c6a81ee26cc.png)  
 ![2024-08-26_12-09-48.png](https://forum.cadmunity.com/uploads/default/original/2X/4/4e7ac828603e4ad5849bef989831c49fa1439c54.png)  
[SheetMetal\_to\_DXF - R2.swp](https://forum.cadmunity.com/uploads/short-url/mriLzffYrLW5n95lF7HnEc263uz.swp) (164 KB)

---

<div class="post-metadata">

**Author:** ![user6](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/u/f1d935/32.png) [@user6](https://forum.cadmunity.com/u/user6)\
**Post date:** [August 26, 2024, 9:42pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/13 "2024-08-26T21:42:02Z")

</div>

Hi Ömür, Your code works amazing. Thank you very much!! I saw it was downloaded 25 times insingle day, so this helped many users in need.

I have few more request if you can help with your expertise -

1. In my case i do not need any userform, by default 2nd & 3rd options are applicable.
2. i want to save the exported files directly on my desktop C:\Users\Desktop\Production\Project\drawing.…  
In path, Can the name of folder “Project” defined from custom properties “Projectno.”.  
In path Can the name of folder “drawing” be defined from custom properties “drawingno.” In custom property value of this field is in format example “xxxxx-12a” but i want to have drawing folder name with left 5 characters (only “xxxxx”. Is it possible ?
3. As previously requested - Is it also possible to insert text inside part in DXF from custom property (while exporting DXF) ? In my case i have Part engraving number in custom property which I have to manually insert as Text (yellow layer) in DXF everytime. Which later on laser marked on Part as “Part number”. text position can be at 0,0,0 (height 10)

Once again many thanks for all the help & time you provided to resolve my problem.

---

<div class="post-metadata">

**Author:** ![Omur\_Tokman](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/omur_tokman/32/39_2.png) [@Omur\_Tokman](https://forum.cadmunity.com/u/Omur_Tokman)\
**Post date:** [August 27, 2024, 8:13am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/14 "2024-08-27T08:13:21Z")

</div>

> [@](#):
>
> Hi Ömür,

2 and 3 will be selected, if you don’t want the form I will leave it to you to remove it.  
2024-08-27\_11-02-12.png  
2024-08-27\_10-54-29.png  
It will create a folder on the desktop with the first 5 characters in your project and save the files there.  
2024-08-27\_10-52-55.png  
2024-08-27\_10-54-52.png  
2024-08-27\_10-59-47.png  
 ![2024-08-27_10-52-55.png](https://forum.cadmunity.com/uploads/default/original/2X/7/756400d63f0097b18935a15ed475ba8e28e23490.png)  
I don’t think it will work, maybe there is an autocad macro, I don’t know and I can’t help you with that.  
[SheetMetal\_to\_DXF - R3.swp](https://forum.cadmunity.com/uploads/short-url/1fZTyckvYMCYiBPf2bLAf2G3IJs.swp) (307 KB)

---

<div class="post-metadata">

**Author:** ![user6](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/u/f1d935/32.png) [@user6](https://forum.cadmunity.com/u/user6)\
**Post date:** [September 2, 2024, 8:56am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/15 "2024-09-02T08:56:53Z")

</div>

Thank you very much for your help. I will try to adjust the code as you suggested.

---

<div class="post-metadata">

**Author:** ![user6](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/u/f1d935/32.png) [@user6](https://forum.cadmunity.com/u/user6)\
**Post date:** [September 3, 2024, 11:13pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/16 "2024-09-03T23:13:31Z")

</div>

Hi Omur, The code works fine and create folder with “firstfivechars” when I run it on single part. But when i Run it on an assembly then it miss to create folder with “firstfivechars”. In my case every sheetmetal part in assembly has an engraving no. in custom property for eg. part 1 has engraving no. “12345-1a”, Part 2 has engraving no. “12345-2a” etc.

Can you please check why the code does not create folder when it run on assembly.

I used below code

Sub main()

Set swApp = Application.SldWorks  
try\_:  
On Error GoTo hata:  
'Get the folder name from custom properties.  
Dim swModel As SldWorks.ModelDoc2  
Set swModel = swApp.ActiveDoc  
Set swModelDocExt = swModel.Extension  
Set swCustProp = swModelDocExt.CustomPropertyManager(“”)  
bool = swCustProp.Get4(“Engraving”, False, val, valout)  
firstFiveChars = Left(val, 5) 'get first 5 characters

PROJECT\_NAME = “\<$PRP:ProjectNo\>_\<$PRP:ProjectName\>"  
FLAT\_PATTERN\_OPTIONS = SheetMetalOptions\_e.ExportFlatPatternGeometry + ExportFormingTools  
OUT\_NAME\_TEMPLATE = “Temp\DXF” & "" & PROJECT\_NAME & "" & firstFiveChars & “\DXFs\<FileName\>.dxf”  
OUT\_NAME\_TEMPLATE = “Temp\DXF” & "" & PROJECT\_NAME & "" & firstFiveChars & “\STEPs\<FileName\>.STEP”_  
   
   
_If CheckBox3.Value = True Then  
OUT\_NAME\_TEMPLATE = "Temp\DXF" & PROJECT\_NAME & "" & firstFiveChars & "\DXFs\<$PRP:Engraving\>_\<$PRP:MOC\>_\<$PRP:Thickness\>mm\_Qty-\<$PRP:Required\>x.dxf"  
OUT\_NAME\_TEMPLATE1 = "Temp\DXF" & PROJECT\_NAME & "" & firstFiveChars & "\STEPs\<$PRP:Engraving\>_\<$PRP:MOC\>\_\<$PRP:Thickness\>mm\_Qty-\<$PRP:Required\>x.STEP” 'extracted to the same folder.

End If

* * *

ALso if I run with only option 2 selected i get msg “Some sheet metal drawings have multibody or extruded bodies”.  
image.png  
whereas when i select option 2 & 3 the program run fine.

Thank you

---

<div class="post-metadata">

**Author:** ![Omur\_Tokman](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/omur_tokman/32/39_2.png) [@Omur\_Tokman](https://forum.cadmunity.com/u/Omur_Tokman)\
**Post date:** [September 5, 2024, 4:42am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/17 "2024-09-05T04:42:15Z")

</div>

> [@](#):
>
> OUT\_NAME\_TEMPLATE = "Temp\DXF" & PROJECT\_NAME & "" & firstFiveChars & “\DXFs\<$PRP:Engraving\>_\<$PRP:MOC\>_\<$PRP:Thickness\>mm\_Qty-\<$PRP:Required\>x.dxf”

What do you want to do? Can you explain what you want to do with this code?

You create a DXF folder in temp, inside that you create a folder called project name, 5 characters, and DXFs, inside that you create the DXF file.

Am I understanding correctly?

---

<div class="post-metadata">

**Author:** ![user6](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/u/f1d935/32.png) [@user6](https://forum.cadmunity.com/u/user6)\
**Post date:** [September 5, 2024, 12:15pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/18 "2024-09-05T12:15:47Z")

</div>

Hi Omur,  
With this code i am trying to separate items in project folder. the “Fistfivechars” is actually the item number. So,  
I already have a folder “DXF” inside “Desktop/temp” defined ..I want when i run the code, the code should check & if not existing then create New folder “Project\_Name”. Inside this folder there should be a new folder with “FirstfiveChars” of custom property “Engraving” (This folder is for item number). & then inside this folder there will be DXF & Step files for this model.  
Next when i will run the code on the next item from same project, then this will create a new folder inside same project with new Item no. (“FirstfiveChars”) & all the DXF & step files will be saved in this.  
Also see attachment. let me know if above explaination is clear.  
trail.jpg

---

<div class="post-metadata">

**Author:** ![Omur\_Tokman](https://forum.cadmunity.com/user_avatar/forum.cadmunity.com/omur_tokman/32/39_2.png) [@Omur\_Tokman](https://forum.cadmunity.com/u/Omur_Tokman)\
**Post date:** [September 16, 2024, 6:06am UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/19 "2024-09-16T06:06:07Z")

</div>

> [@](#):
>
> Hi Omur,  
> trail.jpg

Is this what you’re talking about?  
2024-09-16\_09-02-58.png  
[SheetMetal\_to\_DXF - R4.swp](https://forum.cadmunity.com/uploads/short-url/qLouYzizHX1YeewBpocn7dMzoTN.swp) (307 KB)  
 ![2024-09-16_09-02-58.png](https://forum.cadmunity.com/uploads/default/original/2X/a/abe408725c30406a0a52ec5b4d6f7b3df21646fa.png)

---

<div class="post-metadata">

**Author:** ![user6](https://forum.cadmunity.com/letter_avatar_proxy/v4/letter/u/f1d935/32.png) [@user6](https://forum.cadmunity.com/u/user6)\
**Post date:** [September 18, 2024, 5:32pm UTC](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817/20 "2024-09-18T17:32:05Z")

</div>

Hi Omur,

I tried implementing this, but it doesn’t seem to work with my assembly the way it does with yours. I’m not sure what the issue is. In my case, the assembly itself doesn’t have a custom property for engraving—only the individual parts within the assembly do. This might be the reason, but I can’t say for certain.

Regardless, your help has been invaluable, and I really appreciate your support.

Thank you again!

[Next page](https://forum.cadmunity.com/t/adding-quantity-and-thickness-to-the-name-while-saving-the-file/817.md?page=2)
