Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Time stamp on Plots

Status
Not open for further replies.

cwsink

Automotive
Mar 22, 2006
163
Hello,

Is there a way to print a time stamp on all drawings? We've got a date stamp by putting an annotation in our drawing template sheet formats and inserting the SW-Date Document property. The problem is there is not a similar property for the time.

Is there a way to extract the time with the API or something like that?


Craig Sink
Mechanical Engineer
Force Design, Inc.
 
Replies continue below

Recommended for you

I have seen this sometimes as a part of the print driver. See if there's anything there.
 
You can create a custom property in your drawing template and run a quick macro. Call the property "Time" and copy the following and insert into a new macro:

Set swApp = CreateObject("SldWorks.Application")
Set DrawingDoc = swApp.ActiveDoc
MyString = Str(Time)
retval = DrawingDoc.DeleteCustomInfo("Time")
retval = DrawingDoc.AddCustomInfo("Time", "Text", Str(Time))
DrawingDoc.EditRebuild

This will update the property to your system time.

SolidWorks 2006 - SP3.0
UG NX3
Pro/Engineer Wildfire 2.0
 
Add a footer through the print dialog box (file>print) within solidworks.

Inside the print dialog, you will see document options header/footer. Inside the footer, you can add a time field. If you want to get this text to line up with a box in the title block, it may take a little futzing but you can probably do it.

-Shaggy
 
Got to "File/Print". In the print dialogue, there's a button for "HEADER/FOOTER". There you can add the current date and time....works like Word. You may have to play around with your titleblock and margins such that it doesn't overlap.

Jason

UG NX2.02.2 on Win2000 SP3
SolidWorks 2006 SP5.0 on WinXP SP2
SolidWorks 2007 SP2.0 on WinXP SP2

 
Thank you everyone! I'll investigate these options and see what I can come up with.



Craig Sink
Mechanical Engineer
Force Design, Inc.
 
Craig Sink,
We tried that header footer for awhile. When we changed format the text got large for some reason, so we quit. Now we put $PRP:"SW-Short Date" in the lower left corner. Great control and the font size never changes.

Bradley
SolidWorks 2007 SP2.0
 
If the above doesn't work, maybe this macro can be modified to work. It will put the date on it, but not the time. A guru here may be able to help you (if they're not all on vacation).

I found it on the web, but can't find the source anymore... my guess is Oklahoma SolidWorks User Group but their links are dead.

SW07 SP2.0

Flores
 
fcsuper,

Is there any way to call this macro when I print? Probably using the API which I'm not very adept at. Or maybe there's another approach?

Craig Sink
Mechanical Engineer
Force Design, Inc.
 
I don't believe SolidWorks has a print notification available in VBA, so there is no way to catch every print command and run code prior to the print. What you can do is remove the print button from your toolbar and replace it with a button linked to this macro. It's not totally idiot-proof, but it can help you keep from forgetting. You'll probably want to change fcsuper's code a bit to just skip adding the custom property rather than exiting the whole macro for documents other than parts. Modification could be:

Code:
Option Explicit

Public swApp As Object
Dim retval As Boolean
Dim bret As Boolean
Dim Doc As Object

Sub main()

  Dim swApp As Object
  Set swApp = CreateObject("SldWorks.Application")
  Set Doc = swApp.ActiveDoc
  
  ' Error handler for no document loaded
  If Doc Is Nothing Then MsgBox "No drawing loaded!", vbCritical: End
  
  ' Error handler for document not being a drawing
  If Doc.GetType = 3 Then

    ' Assign the current time and date to custom property
    retval = Doc.DeleteCustomInfo("Print Time")
    retval = Doc.AddCustomInfo("Print Time", "Text", Now)
    
    ' Refresh drawing display to show updated time and date
    retval = Doc.ForceRebuild3(False)
    
  End If
  ' Print
  bret = Doc.PrintOut2(0, 0, 1, False, 0, 0, False, 0)
  

End Sub
 
Good call, handleman. I was just thinking of printing a drawing only...but that is a good idea to make this the only way to print anything.

I was just thinking that you may also wish to add a line to the end that clears the value after printing so if someone does print via another method, it will appear blank on the drawing rather than providing a previously used date. Maybe just add "retval = Doc.DeleteCustomInfo("Print Time")" to the end after the bret line. Handleman, is there a cleaner way do to this?

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor