Save as triggers iLogic rule before "Save as" in stead of after.

Save as triggers iLogic rule before "Save as" in stead of after.

Anonymous
Not applicable
948 Views
2 Replies
Message 1 of 3

Save as triggers iLogic rule before "Save as" in stead of after.

Anonymous
Not applicable

Hello,

 

I'm currently creating an iLogic rule that automaticly creates a .pdf file whenever I save my .idw drawing file. So far so good, using the normal "save" option works like a charm and it does everything its supposed to.

 

Now the problem is, whenever I use the "save as" function, the iLogic rule activates itself on the old filename instead of the newly created one. To describe the situation, if I want to create a revision of lets say "Example.idw" and call it "Example A.idw". As soon as I used save as to create "Example A.idw", it saves the .pdf file as the old extension ("Example.idw") instead of the newly created one.

 

To avoid the problem of the Event Triggers, Yes i did post my rule in the "After Save Document" section of the event triggers that's why I don't get why on save as, it saves before I saved my file. 

 

Heres my code, included with comments on what everyting currently does.

 

file_path = ThisDoc.Path 
file_name = ThisDoc.FileName(False) 
file_name_path = file_path & "\" & file_name 

If file_path & "\" & ThisDoc.FileName(True) = (file_name_path & ".idw") Then 'Checks if the current file extension is an idw or not. Because I only have to create a pdf when my file is an idw.
	If System.IO.File.Exists(file_name_path & ".pdf") Then 'Checks if theres already an existing .pdf file on the current idw file.
		vraag=MessageBox.Show("Wilt u het bestand overschrijven?", "Opslaan in PDF",MessageBoxButtons.YesNo) 'Message box that asks if you want to overwrite the current file yes or no.
			If vraag = vbYes Then 
				System.IO.File.Delete(file_name_path & ".pdf") 'Deletes the old pdf file, i couldn't find another solution to overwrite an existing pdf file.
				ThisDoc.Document.SaveAs(file_name_path & ".pdf", True) 'Newly saves the pdf file to have an updated version
			Else 
				MessageBox.Show("Er zijn geen wijzigingen toegepast aan het PDF bestand.", "Voltooid") 'If chosen no, it just gives a messages that no changes have been made to the pdf file.
			End If	
	Else 'If the system doesn't detect a pdf file it creates a pdf file and gives me a message that it created a pdf.
		ThisDoc.Document.SaveAs(file_name_path & ".pdf", True)
		MessageBox.Show("Het PDF bestand is opgeslagen", "Voltooid")
	End If
End If

You could compare my problem to the following older thread post. But I don't see the solution to the problem in there.

 

I hope someone can help. Thanks!

0 Likes
949 Views
2 Replies
Replies (2)
Message 2 of 3

johnsonshiue
Community Manager
Community Manager

Hi! I am not an iLogic expert. I know a little bit to be dangerous. Please bear with me if I don't make sense. I played around with your code. The rule itself seems Ok. The problem is with the trigger. The issue here is that the rule you run is always in the old file. You probably need to add a trigger to "After Open", so that the pdf file is exported after you save it to a new file and the new file is opened.

 

Many thanks!

 



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 3

Anonymous
Not applicable

Okay that's clear and it does work to save the new file using save as, but this brings up something else.

 

Due to my rule being needed after save has been pressed I need to keep it in the event listener "After Save Document". And it does work having my rule in both "After Open Document" and "After Save Document", which doesn't change that it still wants to save the old file. Also when I open a random document I instantly get a pop-up if I want to overwrite my pdf.

 

Long story short, It is a sort of solution, but it's not ideal. 

 

Thank you for the help though!

0 Likes