×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Time stamp on Plots

Time stamp on Plots

Time stamp on Plots

(OP)
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.
www.forcedesign.biz

RE: Time stamp on Plots

I have seen this sometimes as a part of the print driver.  See if there's anything there.

RE: Time stamp on Plots

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

RE: Time stamp on Plots

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

RE: Time stamp on Plots

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

RE: Time stamp on Plots

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

Craig Sink
Mechanical Engineer
Force Design, Inc.
www.forcedesign.biz

RE: Time stamp on Plots

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

RE: Time stamp on Plots

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.
www.paul-flores.com/macros/stamp.zip

SW07 SP2.0

Flores

RE: Time stamp on Plots

(OP)
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.
www.forcedesign.biz

RE: Time stamp on Plots

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

RE: Time stamp on Plots

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
http://sw.fcsuper.com/index.php

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources