Assembly to PDF with a twist

Programming and macros
User avatar
zwei
Posts: 701
Joined: Mon Mar 15, 2021 9:17 pm
Answers: 18
Location: Malaysia
x 185
x 599

Assembly to PDF with a twist

Unread post by zwei »

Creating this post on behalf of Simon Roberts
This is a continuation of the discussion from the old forum
https://r1132100503382-eu1-3dswym.3dexp ... zSsjBfBzNA
Hey all

am looking for a macro which can create separate pdf's of each part or assembly drawing, from a assembly model.

The twist is to separate the pdf into different folders where the part has a custom property see below snip for example
Hi Zhen, Managed to get around to play with this code works a well thanks, would there be way to export the file names into spreadsheet, which is arranged by the suffix name like PC or MA etc also the title of the drawing (name) e.g 411-001-001 Mounting bracket
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
User avatar
zwei
Posts: 701
Joined: Mon Mar 15, 2021 9:17 pm
Answers: 18
Location: Malaysia
x 185
x 599

Re: Assembly to PDF with a twist

Unread post by zwei »

Hi Zhen, Managed to get around to play with this code works a well thanks, would there be way to export the file names into spreadsheet, which is arranged by the suffix name like PC or MA etc also the title of the drawing (name) e.g 411-001-001 Mounting bracket
One way to get this to work is by recording the file name when it is transversing and exporting the PDF

As i have a hard time figuring out my own reply on the old forum, i will just post some pseudo code for now (i also cant find my own archive folder as they remove the old forum thread number which i use to archive my reply :twisted: )

The idea is to concatenating vbNEwLine with the file name and the custom property to produce a txt/csv file at the end of macro that can be imported using excel.

At the start of macro (before transversing the assembly), add the following code
you could adjust the txt name to use the hla name too

Code: Select all

Dim Log			As String
Dim fsW			As Object
Dim tsW			As Object
Dim TxtName		As String
Dim LogPath		As String
Log = "Files Exported: " & vbNewLine
TxtName = "Log.txt" 
After SaveAs command (before transversing to the next component), add the following code
You can further adjust the code to create a comma separated file,

Code: Select all

Log = Log & [FileName] &","& [CustomProperty]& vbNewLine
After finishing all export (before ending the macro), add the following code

Code: Select all

LogPath = [logPathFolder] & TxtName
Set fsW = CreateObject("Scripting.FileSystemObject")
Set tsW = fsW.CreateTextFile(LogPath, True)
tsW.writeline (Log)
tsW.Close
syntax in [bracket] need to be adjusted to the appropriate variable used in the macro
Far too many items in the world are designed, constructed and foisted upon us with no understanding-or even care-for how we will use them.
Post Reply