Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Darkforce_the_ilogic_guy
356 Views, 3 Replies

why does this ilogic code not work?

I am running an ilogic code after save. I want to set som properties if this is the first time it have been save

 

my problem is that it does not change the properties .. but it seems that the code is running as it should

 

Nulstill SaveAs og Save and replace file
Sub Main()
Dim oDoc As Document =ThisApplication.ActiveDocument 'ThisDoc.Document 'ThisApplication.ActiveDocument
oDoc.DisplayName = ""

If oDoc.FileSaveCounter > 1 Then
	debug("Have been Save more Then one time")
	'Return
ElseIf oDoc.FileSaveCounter = 1 Then
	debug("Save For the first Time " & ThisDoc.FileName(True))
	ExcelPath  = "C:\Working Folder\CAD\Kallesoe\Kallesoe iLogic\PDFLOg.xlsx"
	ExcelSheet = "LastSaveFile"
	GoExcel.Open(ExcelPath, ExcelSheet)
	Dim LastFileNavn = GoExcel.CellValue(ExcelPath, ExcelSheet, "C3") 
	Dim Emtry =GoExcel.CellValue(ExcelPath, ExcelSheet, "C4")
	GoExcel.Save
	GoExcel.Close

'Test code reset SaveAs
debug(LastFileNavn &" was Save Last")
If LastFileNavn <> Emtry Then
	debug("1")
	'oDoc.DisplayName = ""
	debug("1.1")
oTime = Now.ToShortDateString
debug("1.2")
iProperties.Value("Project", "Creation Date") = oTime
debug("1.3")
Try
	debug("1.4")
iProperties.Value("Custom", "Surface") = ""
debug("1.5")
Catch
	debug("1.6")
End Try
oNAME = ThisApplication.GeneralOptions.UserName
debug("1.7")
iProperties.Value("Project", "Designer") = oNAME
debug("1.8")
iProperties.Value("Project", "Revision Number") = 0
'oDoc
'iProperties.Value(docFName, "Project", "Revision Number") = 0
debug("1.9")
'Test code end
iLogicVb.UpdateWhenDone = True

Else
	debug("2")
End If 
Try
ThisApplication.CommandManager.StartCommand(CommandIDEnum.kFileSaveCommand)
Catch
	

End Try
	'Run the remainder of your code
	GoExcel.Open(ExcelPath, ExcelSheet)
	GoExcel.CellValue(ExcelPath, ExcelSheet, "C3") =""
	GoExcel.Save
	GoExcel.Close
	End If

End Sub

Public Sub debug(txt As String)
	Trace.WriteLine("NTI : " & txt)
End Sub

 

Revision Number are not been set to 0 and Designer are not been set to oNAME even if after the debug code are running 1.7 ,1.8 and 1.9 are running.

 

how can this be ?

 

 

Hi,

 

Use FileSaveCounter = 0

Nulstill SaveAs og Save and replace file
Sub Main()
Dim oDoc As Document =ThisApplication.ActiveDocument 'ThisDoc.Document 'ThisApplication.ActiveDocument
oDoc.DisplayName = ""

If oDoc.FileSaveCounter > 0 Then
	debug("Have been Save more Then one time")
	'Return
ElseIf oDoc.FileSaveCounter = 0 Then

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !

the problem is not that it do not trigger , but it trigger on the old file.

 

I want to reset the some properties on the new files create when you do a save as or use the copy ryeplace ... I am almost 100% sure that it work before ...on a earlier version of this code ... but After I up date to 2020.2.1 I have could not get the new or the old code to work ..but I might just been fools by an addin program we have .. can´t be 100% sure

Tags (1)

Could you send the file in question?

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations:

Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:Drawing List!|Toggle Drawing Sheet!|Workplane Resize!|Drawing View Locker!|Multi Sheet to Mono Sheet!|Drawing Weld Symbols!|Drawing View Label Align!|Open From Balloon!|Model State Lock!
Posts and Ideas:Dimension Component!|Partlist Export!|Derive I-properties!|Vault Prompts Via API!|Vault Handbook/Manual!|Drawing Toggle Sheets!|Vault Defer Update!


! For administrative reasons, please mark a "Solution as solved" when the issue is solved !