use ilogic on new files create by save and replace or save as ?

use ilogic on new files create by save and replace or save as ?

Darkforce_the_ilogic_guy
Advisor Advisor
1,043 Views
3 Replies
Message 1 of 4

use ilogic on new files create by save and replace or save as ?

Darkforce_the_ilogic_guy
Advisor
Advisor

It is possible to make an ilogic that run the first time a file is save ?.. I want it to work then I make a new file with save and replace.. but not want the code to run again the second time I save it.

 

and do not what to add custom properties to the file. how can i do this ?

0 Likes
Accepted solutions (2)
1,044 Views
3 Replies
Replies (3)
Message 2 of 4

WCrihfield
Mentor
Mentor
Accepted solution

Perhaps something like the following would work for you.

Dim oDoc As Document = ThisApplication.ActiveDocument
If oDoc.FileSaveCounter > 1 Then
	Return
ElseIf oDoc.FileSaveCounter < 1 Then
	'Run the remainder of your code
End If

It could be fired by standard Event Triggers "Before Save Document" or "After Save Document", but it won't effect anything if the FileSaveCounter doesn't check out.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

Message 3 of 4

Darkforce_the_ilogic_guy
Advisor
Advisor
Accepted solution

I did a lillte change to your code . And add it to after save. This way make if look after I save it if it only have been save one time . And make it change the designer navn , reset Revision Number and an custom properties that we use .... a lillte like you can do with copy design in vault .. but somthing it just easy to use command like Save and Replace. 

 

Save before did not work sind it still look at the old file at this point in the saving processe..and I change ThisApplication.ActiveDocument to ThisDoc.Document sind my code not always are running on the Active document but an subcompoment of the AtiveDocument .. but your code give my the inspiration I did to find my way 

 

 

 

Dim oDoc As Document = ThisDoc.Document 'ThisApplication.ActiveDocument


If oDoc.FileSaveCounter > 1 Then
	
	'Return
ElseIf oDoc.FileSaveCounter = 1 Then


'Test code reset SaveAs

booleanParam = InputRadioBox("Is this an new files " + iProperties.Value("Project", "Part Number"), "Ja", "Nej", booleanParam, Title := "Title") 
If booleanParam = True Then



	oDoc.DisplayName=""
oTime = Now.ToShortDateString
iProperties.Value("Project", "Creation Date") = oTime
MessageBox.Show(iProperties.Value("Project", "Part Number") & "Reset Surface ", "Title")


iProperties.Value("Custom", "Surface") = ""
oNAME = ThisApplication.GeneralOptions.UserName
iProperties.Value("Project", "Designer") = oNAME
iProperties.Value(docFName, "Project", "Revision Number") = 0
'Test code end
iLogicVb.UpdateWhenDone = True
ThisApplication.CommandManager.StartCommand(CommandIDEnum.kFileSaveCommand)
	'Run the remainder of your code
	
	End If
End If

..  

0 Likes
Message 4 of 4

WCrihfield
Mentor
Mentor

Glad to have been of service.

As an additional tip, when you're setting the date to todays date in iLogic, you can simply type in Today like this.

iProperties.Value("Project", "Creation Date") = Today

Because it has exactly the same result.  Try the following to see for yourself.

MessageBox.Show(Today)
MessageBox.Show(Now.ToShortDateString)

Happy coding. 🙂

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes