Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

print date and time

15 REPLIES 15
Reply
Message 1 of 16
CAD-One
3483 Views, 15 Replies

print date and time

Hi,

In the drawing title block I would like to place a text reading the print, date and time. This should reflect the current system date and time. I would have this done on the template file so that all new drawings will have this feature builtin.



Is there a property that i can have the text to link to?

Is there any third party program for this?



Thanks in advance

C1
C1
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020
15 REPLIES 15
Message 2 of 16
msklein
in reply to: CAD-One

sketched symbols then text, under properties pick which properly you want then pick type use file name and path.

msk
Message 3 of 16
msklein
in reply to: CAD-One

sketched symbols then text, under properties pick which properly you want then pick type use file name and path.

msk
Message 4 of 16
karthur1
in reply to: CAD-One


As close as I can get you to what you want is by putting the SAVED time and date on the idw.



Copy and paste the code below into your idw template. When you save your idw, this macro will write the "SysDate" and "SysTime" to a custom property in the idw. You can use a text box to put these parameters on your drawing.



Attached here is a shot of my title block where I write them onto the drawing.





Public Sub AutoSave()



Call AddSysDateTime



End Sub

Public Sub AddSysDateTime()



On Error Resume Next



'Check if the active document is a Drawing

If ThisApplication.ActiveDocumentType = kDrawingDocumentObject Then



'Add a custom property "SysDate" with system date

Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

'As a workaround the property must be delete because it can not be changed

oPropSet.Item("SysDate").Delete

Call oPropSet.Add(Format(Date, "mmm-d-yy"), "SysDate")



'Add a custom property "SysTime" with system time

Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

'As a workaround the property must be delete because it can not be changed

oPropSet.Item("SysTime").Delete

Call oPropSet.Add(Format(Time, "h:mmam/pm"), "SysTime")



'Still having some problems that the last property does not update correct

Call RefreshProperties



End If



End Sub

Private Sub RefreshProperties()



Set oPropSet = ThisApplication.ActiveDocument.PropertySets("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}")

Call oPropSet.Add("", "MyDummy")

oPropSet.Item("MyDummy").Delete



End Sub








Message 5 of 16
CAD-One
in reply to: CAD-One

I see that there is no time stamp available directly through any property. I wish they did.
C1
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020
Message 6 of 16
CAD-One
in reply to: CAD-One

Karthur,

Thanks for your valuble macro. Is there a specofic name that I should save this macro as?

Thanks

C1
C1
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020
Message 7 of 16
karthur1
in reply to: CAD-One

In the VB Editor, you will see a "Autodesk Inventor 2009 Objects" folder. Under that folder is a "This document". Right-click on this and chose "View Code". Paste the macro here, exit the editor and save the idw.



Now edit the title block, you will have SysDate and SysTime under the Custom Properties - Drawing type.
Message 8 of 16
CAD-One
in reply to: CAD-One

Thanks a ton.
C1
Inventor Professional 2020
Vault Professional 2020
AutoCAD 2020
Message 9 of 16
JDMather
in reply to: CAD-One

>I see that there is no time stamp available directly through any property

Actually there is a Create Date but not a Plot Date.

-----------------------------------------------------------------------------------------
Autodesk Inventor 2019 Certified Professional
Autodesk AutoCAD 2013 Certified Professional
Certified SolidWorks Professional


The CADWhisperer YouTube Channel


EESignature

Message 10 of 16
-niels-
in reply to: CAD-One

Hello Karthur,



I've added your code to our templates and it works like a charm.

One question though:

Every time i start a new drawing from our templates now i get the following warning:

"Warning: You have a non-empty VBA project saved in your template file."

Is there a way to stop this message?



Also, if i only need the date and not the time, can i safely remove the "systime" block?



Regards,



Niels.

Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands

Message 11 of 16
karthur1
in reply to: CAD-One


Glad it works for you. I have been using this for several years and it does work great. Wish I could take the credit for it, but I got this from this forum many moons ago. ( I think it was from an adesk person)





To get rid of the warning message, can you not disable the message by selecting the "Never show this thing again" button. It is behind the promt button on the warning message. They added this sometime ago just to warn people if they have overblotted VBA code in the idw. I think there is a performance issue when you open several idws in the same session. I can have several idws open at the same time and I don't have an issue. But if I tried to open say 100 idws in the same session, it might get bogged down.



If you don't need the variable, just remove it from the code. If it was me, I would just leave it there, never know if you will need it later. I don't know what the difference is in file size with and without the systime written to the custom prop. I am sure it is a very small difference.

Message 12 of 16
-niels-
in reply to: CAD-One

Ok, thanks karthur.

I'll just "never show this message again" and be done with it 🙂



I don't think we'll need the timestamp anytime soon.

We've used the datestamp for quite a while through yippee pro but that got killed in 2010, so i was very glad to find this bit of code.

Niels van der Veer
Inventor professional user & 3DS Max enthusiast
Vault professional user/manager
The Netherlands

Message 13 of 16
Ktelang
in reply to: -niels-

Thanks karthur for sharing that code.. it's perfect !!! Smiley Happy

 

 

------------------------------------------------------------------------------
Config :: Intel (R) Xeon (R) CPU E31245 @ 3.30 GHz, 16.0 GB, 64bit win7
Inventor 2013 and Vault Basic 2013
-----------------------------------------------------------------------------
Message 14 of 16
JeffBoro
in reply to: karthur1

I know this is really old. I have been using this for many years now and it has worked great. Now it suddenly will no longer update the time and date when I save. I have tried to repast the code into VB but that has not changed anything. Anyone have any ideas.

 

I am still running XP and Inventor 8

Message 15 of 16
johnsonshiue
in reply to: JeffBoro

Hi Jeff,

 

I believe it should be working. I don't have Inventor R8 to test. Even if there was a bug, there isn't much I can do right now since it is too old and it is no longer a supported product on a discontinued platform. Could you upgrade to more recent release?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
Message 16 of 16
doug.johnston
in reply to: JeffBoro

Here is the code that I use for the date/time plot stamp (and it's ilogic, not VBA).

 

'' ilogic rule to automatically place and update plot date stamp to *idw sheets
'' created 04.dec.2017  --  DJ

'Gets the active document
Dim odrawdoc As DrawingDocument
odrawdoc = ThisApplication.ActiveDocument
'Gets the Inventor Property Set
Dim customPropertySet As PropertySet
customPropertySet = odrawdoc.PropertySets.Item("Inventor User Defined Properties")

'Declares date and time as string
Dim PlotDate As String
PlotDate = Now()

Try
	customPropertySet.Item("Plotdatestamp").Value = PlotDate
Catch
	customPropertySet.Add(PlotDate, "Plotdatestamp")	
End Try

InventorVb.DocumentUpdate()

I've been using it for approx. 1 year and have had no problems.  The code changes the time & date every time it is printed (maybe even every time it is saved).


---------------------------------------------------
It's not easy maintaining this level of insanity !!!!!

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

Post to forums  

Autodesk Design & Make Report