Use Last modified Date in ilogic code .. to only run if fil is modified later

Use Last modified Date in ilogic code .. to only run if fil is modified later

Darkforce_the_ilogic_guy
Advisor Advisor
1,494 Views
11 Replies
Message 1 of 12

Use Last modified Date in ilogic code .. to only run if fil is modified later

Darkforce_the_ilogic_guy
Advisor
Advisor

I need to make a ilogic code that only runs if the Last Modified Date is aften "20-03-2018 10:41:47". how do i do that ?

0 Likes
Accepted solutions (1)
1,495 Views
11 Replies
Replies (11)
Message 2 of 12

bradeneuropeArthur
Mentor
Mentor
Last midified date of what?
The file.
The code.
Or what?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 3 of 12

Of all IPT or IAM files.

 

What i need it to add a  custom properties to all 3d inventor files .. but only to thoes that are form about 3 Mount ago or later... I want inter to stop asking for the porperties when i open a drawing older then that date i pick

0 Likes
Message 4 of 12

Use timespan in .net

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 5 of 12

bradeneuropeArthur
Mentor
Mentor
Accepted solution
Like this.

Dim startTime As DateTime = New DateTime(2013, 6, 12, 22, 45, 0)
Dim endTime As DateTime = New DateTime(2013, 6, 12, 22, 50, 0)
Dim span As TimeSpan = endTime - startTime

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 6 of 12

bradeneuropeArthur
Mentor
Mentor

This will do what you need I think:

 

Private Sub Main()
Dim fromDate As Variant
fromDate = "01-Jan-11 00:00:00"

Dim toDate As Variant
toDate = "01-Jan-10 23:59:00"

MsgBox ("Line 1 : " & DateDiff("yyyy", fromDate, toDate))
MsgBox ("Line 2 : " & DateDiff("q", fromDate, toDate))
MsgBox ("Line 3 : " & DateDiff("m", fromDate, toDate))
MsgBox ("Line 4 : " & DateDiff("y", fromDate, toDate))
MsgBox ("Line 5 : " & DateDiff("d", fromDate, toDate))
MsgBox ("Line 6 : " & DateDiff("w", fromDate, toDate))
MsgBox ("Line 7 : " & DateDiff("ww", fromDate, toDate))
MsgBox ("Line 8 : " & DateDiff("h", fromDate, toDate))
MsgBox ("Line 9 : " & DateDiff("n", fromDate, toDate))
MsgBox ("Line 10 : " & DateDiff("s", fromDate, toDate))
End Sub

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 7 of 12

I am not sure how to use that ...

 

I need somthing like this

 

if ( lastmodifieddate > (2018, 3, 20, 22, 45, 0)) Then

my code

end if.

 

 

how would that look like with ?

0 Likes
Message 8 of 12

What is this kind of format "2018, 3, 20, 22, 45, 0"?
This is no date format!
How did you define this format?

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 9 of 12

bradeneuropeArthur
Mentor
Mentor

@Darkforce_the_ilogic_guy

This is a correct date format:

 

Private Sub Main()
Dim fromDate As Variant
fromDate = "2018-3-20 22:45:0"

Dim toDate As Variant
toDate = "2018-3-20 22:45:0"

MsgBox ("Line 1 : " & DateDiff("yyyy", fromDate, toDate))
MsgBox ("Line 2 : " & DateDiff("q", fromDate, toDate))
MsgBox ("Line 3 : " & DateDiff("m", fromDate, toDate))
MsgBox ("Line 4 : " & DateDiff("y", fromDate, toDate))
MsgBox ("Line 5 : " & DateDiff("d", fromDate, toDate))
MsgBox ("Line 6 : " & DateDiff("w", fromDate, toDate))
MsgBox ("Line 7 : " & DateDiff("ww", fromDate, toDate))
MsgBox ("Line 8 : " & DateDiff("h", fromDate, toDate))
MsgBox ("Line 9 : " & DateDiff("n", fromDate, toDate))
MsgBox ("Line 10 : " & DateDiff("s", fromDate, toDate))
End Sub

Regards,

Autodesk Software: Inventor Professional 2018 | Vault Professional 2018 | Autocad Mechanical 2018
Programming Skills: Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
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 ! 

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


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:
My 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 !


 


EESignature

0 Likes
Message 10 of 12

I use this code and if the runScript Boolean is true it will run the rest of the ilogic code 🙂

Udklip.PNG

0 Likes
Message 11 of 12

I use this code and if the runScript Boolean is true it will run the rest of the ilogic code 🙂 Sub Main() '------------------------Read Me ---------------------------------------- ' Tjekker om der kommer surface på Sheet Metal, Part, Assembly og welded '------------------------Read Me --------------------------------------- Dim strFileName As String Dim oFS As Object Dim oDate1 As DateTime Dim oDate2 As DateTime Dim runScript As Boolean = True strFileName = ThisDoc.Document.FullFileName If strFileName IsNot "" oFS = CreateObject("Scripting.FileSystemObject") 'Dato for hvornår den sidste er blevet ændret oDate1 = oFS.GetFile(strFileName).DateLastModified 'Dato for hvornår man skal sætte surface på oDate2 = New DateTime (2018, 3, 20, 22, 45, 0) End If If oDate1 < oDate2 Then runScript = False debug("Filen er ældre og vil derfor ikke få surface på") 'MessageBox.Show("old" & oDate1, "Title") Else runScript = True debug("Filen er nyrer og skal derfor få surface på") 'MessageBox.Show("Ny" & oDate1 &">" &"20-03-2018 10:41:47" , "Title") End If

0 Likes
Message 12 of 12

chandra.shekar.g
Autodesk Support
Autodesk Support

@Darkforce_the_ilogic_guy,

 

Try below iLogic code to compare dates.

 

Sub Main()
	
	Dim strFileName As String = ThisDoc.Document.FullFileName 
	Dim oDate1 As Date 
	Dim oFs As Object 
	oFs = CreateObject("Scripting.FileSystemObject")	
	oDate1 =  oFs.GetFile(strFileName).DateLastModified  
	MsgBox(oDate1, 0, "File Access Info")

	Dim oDate2 As Date = New Date(2018, 3, 20, 22, 45, 0)
	MsgBox(oDate2, 0, "File Access Info")

	Dim result As Integer = DateTime.Compare(oDate1, oDate2)
	Dim relationship As String

	If result < 0 Then
	 relationship = "is earlier than"
	ElseIf result = 0 Then
	 relationship = "is the same time as"         
	Else
	 relationship = "is later than"
	End If
	MsgBox(relationship, 0, "File Status Info")
	
End Sub

Please feel free to contact if there is any queries.

 

If solves problem, click on "Accept as solution" / give a "Like".

 

Thanks and regards,


CHANDRA SHEKAR G
Developer Advocate
Autodesk Developer Network



0 Likes