Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Before save event issue.

8 REPLIES 8
Reply
Message 1 of 9
aurel_e
408 Views, 8 Replies

Before save event issue.

aurel_e
Collaborator
Collaborator

Hi all,

I use the ilogic rule below to automatically export the drawings in PDF.

It was previously triggered with "after save" event, but that was causing problems with the Vault checking in.

Then I changed it to "before save" event. The issue now is with the first save, because the file and the path doesn't exist is giving error. Any suggestion how to solve it?

 

WorkspacePath = ThisDoc.WorkspacePath()
WorkspacePathLength = Len(WorkspacePath)
PathOnly = ThisDoc.Path
DirectoryPath = Strings.Right(PathOnly, PathOnly.Length - WorkspacePathLength)
PDFPath = "C:\Users\....\PDFs" & DirectoryPath
If (Not System.IO.Directory.Exists(PDFPath)) Then
	System.IO.Directory.CreateDirectory(PDFPath)
End If
ThisDoc.Document.SaveAs(PDFPath & "\" & ThisDoc.FileName(False) & ".pdf" , True)
0 Likes

Before save event issue.

Hi all,

I use the ilogic rule below to automatically export the drawings in PDF.

It was previously triggered with "after save" event, but that was causing problems with the Vault checking in.

Then I changed it to "before save" event. The issue now is with the first save, because the file and the path doesn't exist is giving error. Any suggestion how to solve it?

 

WorkspacePath = ThisDoc.WorkspacePath()
WorkspacePathLength = Len(WorkspacePath)
PathOnly = ThisDoc.Path
DirectoryPath = Strings.Right(PathOnly, PathOnly.Length - WorkspacePathLength)
PDFPath = "C:\Users\....\PDFs" & DirectoryPath
If (Not System.IO.Directory.Exists(PDFPath)) Then
	System.IO.Directory.CreateDirectory(PDFPath)
End If
ThisDoc.Document.SaveAs(PDFPath & "\" & ThisDoc.FileName(False) & ".pdf" , True)
8 REPLIES 8
Message 2 of 9
Michael.Navara
in reply to: aurel_e

Michael.Navara
Advisor
Advisor
0 Likes

Message 3 of 9
aurel_e
in reply to: Michael.Navara

aurel_e
Collaborator
Collaborator

My intent is to have the drawing saved as PDF automatically replicating the workspace folder tree.

I understand that the "before save" for the first save doesn't find the path and file name.

The "after save" would be the suitable trigger for that, but as I said in the first post, it messes with the Vault.

So I was wandering if someone has a solution for it, a different trigger or another way to achieve it.

Thanks.

0 Likes

My intent is to have the drawing saved as PDF automatically replicating the workspace folder tree.

I understand that the "before save" for the first save doesn't find the path and file name.

The "after save" would be the suitable trigger for that, but as I said in the first post, it messes with the Vault.

So I was wandering if someone has a solution for it, a different trigger or another way to achieve it.

Thanks.

Message 4 of 9
Michael.Navara
in reply to: aurel_e

Michael.Navara
Advisor
Advisor

If you use a Vault, use JobProcessor and publishing jobs.

0 Likes

If you use a Vault, use JobProcessor and publishing jobs.

Message 5 of 9
aurel_e
in reply to: Michael.Navara

aurel_e
Collaborator
Collaborator

I know... but I was trying to make them accessible for the people in shopfloor. They've got some Ipads, and I was saving the files on Idrive as the only place I know they can access (without involving IT people). The workflow was working until I discovered it was creating problems checking in.

I know... but I was trying to make them accessible for the people in shopfloor. They've got some Ipads, and I was saving the files on Idrive as the only place I know they can access (without involving IT people). The workflow was working until I discovered it was creating problems checking in.

Message 6 of 9
Michael.Navara
in reply to: aurel_e

Michael.Navara
Advisor
Advisor

You can copy file after job to any place, you can implement your own job, etc. In this case you can export PDF ony for approved documentation.

 

Hypothetical question: 

What happens when someone make a copy of drawing, make some changes (test, preview, ..) and save the file? Later on he can "undo changes" from Vault.

 

0 Likes

You can copy file after job to any place, you can implement your own job, etc. In this case you can export PDF ony for approved documentation.

 

Hypothetical question: 

What happens when someone make a copy of drawing, make some changes (test, preview, ..) and save the file? Later on he can "undo changes" from Vault.

 

Message 7 of 9
HermJan.Otterman
in reply to: aurel_e

HermJan.Otterman
Advisor
Advisor

is the name of the drawing/pdf related to name of the component (from the drawing) if so then you can use the name and path of the related component. you can use document.FileSaveCounter  to see how many times the file was saved. 0 means no document.FullFileName ...

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes

is the name of the drawing/pdf related to name of the component (from the drawing) if so then you can use the name and path of the related component. you can use document.FileSaveCounter  to see how many times the file was saved. 0 means no document.FullFileName ...

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Message 8 of 9
aurel_e
in reply to: aurel_e

aurel_e
Collaborator
Collaborator

Usually it is the same. 

I think I will click twice the save button for the first save.

0 Likes

Usually it is the same. 

I think I will click twice the save button for the first save.

Message 9 of 9
HermJan.Otterman
in reply to: aurel_e

HermJan.Otterman
Advisor
Advisor

so if you work with the mono darwing system, than only one part per drawing, so take the first drawing view and get the  referenced filename:

Dim drawdoc As DrawingDocument
        Dim filename = drawdoc.Sheets(1).DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName

then you can use this string to get the path and name for the drawing and/or PDF

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


0 Likes

so if you work with the mono darwing system, than only one part per drawing, so take the first drawing view and get the  referenced filename:

Dim drawdoc As DrawingDocument
        Dim filename = drawdoc.Sheets(1).DrawingViews(1).ReferencedDocumentDescriptor.FullDocumentName

then you can use this string to get the path and name for the drawing and/or PDF

 

 

If this answers your question then please select "Accept as Solution"
Kudo's are also appreciated Smiley Wink

Succes on your project, and have a nice day

Herm Jan


Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report