Re: Automatic date field on titleblock

Try this,

Make a macro for the users to create the parts fro them that will stuff a short date into a Custom Prop and then just read that when the drawing is created.

I currently have this statement ($PRP:"SW-File Name") in our "Drawing > #" field on the titleblock. Is there a statement like this that would > input the present date into the title block "Date" field. This date > would be the present date that the drawing is created on. I know that > this statement > (SW-Created Date) would do this, but it puts the date in the format > "Monday, July 14, 2003 4:13:51 PM". All I want is the date in > 07/14/03 format. The statement (SW-Short Date) cannot be used since > everytime the drawing gets updated, this field would be updated with > the current date. > > If anyone has any suggestions, I would appreciate it. Thanks. > > Also, if anyone has any links to titleblock templates, please post > them. Im always looking for good ideas. You can email them to me > also, snipped-for-privacy@spamgourmet.com > > Thanks.
Reply to
Guy Edkins
Loading thread data ...

Here's what we did. For the date example, set up the drawing template with a note for your title block "Date Created" entry that says $PRP:"DateOrig". Then create a custom property with the name "DateOrig" and fill in the proper date there. The advantage of putting it in a property is that we have our templates set up with 12 properties that propagate the title block. That way it's one-stop shopping.

WT

Reply to
Wayne Tiffany

Wayne, this still makes it a manual process, correct? I am looking for a way to make this automatic. Ex. Open up a new drawing, the "Date:" field automatically gets todays date in MM/DD/YY format.

Reply to
SW Monkey

Please try the following:

Link to property->Use custom properties from Current Document and from the dropdown list you can select either SW-LongDate or SW-ShortDate.

Best Regards,

-- Bob Hanson CEO Custom Programming Unlimited LLC SolidWorks Solution Partner in two categories (SW API training/consulting and SW PDM provider)

formatting link
website (Home of SW API Public Code snippets)

SolidWorks 2003 World User Conference Exhibitor Booth #407

Reply to
Robert V. Hanson

I figured out how to get this to run automatically everytime a new drawing doc is opened. That way nobody in engineering can forget to put their name and date on new drawings. If anyone wants to know how just ask.

Reply to
Corey Scheich

Sure, I'll take a look. We have a small program that puts in the user, date, time, etc., but the user must run the program manually.

WT

Reply to
Wayne Tiffany
1) Ok Create a macro in the same directory as the "swp" that inputs your info Name it "Events.swp" 2) Paste this code in the Module1 or Events1 whatever the module is

Sub main() Set ThisLibrary.swApp = Application.SldWorks End Sub

3) then Paste this code in Solidworks Objects/ThisLibrary

Dim VBEapp As VBE Public WithEvents swApp As SldWorks.SldWorks

Private Function swApp_FileNewNotify2(ByVal newDoc As Object, ByVal DocType As Long, ByVal templateName As String) As Long Dim part As ModelDoc2 Set part = swApp.ActiveDoc If part.GetType = 3 Then '3 it the enumerated value for a drawing document Dim ProjectPath As String Dim SplitPath As Variant Set VBEapp = Application.VBE

ProjectPath = VBEapp.VBProjects.Item(FindProjectByName("Events")).fileName

SplitPath = Split(ProjectPath, "\", -1, vbTextCompare) ProjectPath = Left(ProjectPath, Len(ProjectPath) - Len(SplitPath(UBound(SplitPath)))) swApp.RunMacro ProjectPath & "Date.swp", "Module1", "Main" 'where Date.swp is the name of the macro you want to run and Module1::Main is the function you want to run. End If End Function

Function FindProjectByName(ProjectName As String) As Long Dim Counter As Long Counter = 1 For Counter = 1 To VBEapp.VBProjects.Count If VBEapp.VBProjects.Item(Counter).Name = "Events" Then FindProjectByName = Counter Exit Function End If Next FindProjectByName = 0 End Function

This code will watch for events until stop is hit in the VBA editor. It can be restarted simply by playing main.

then to invoke the code upon startup paste this line in the shortcuts to SolidWorks.exe after "C:\Program Files\SolidWorks\sldworks.exe" put

/m "G:\users\cds\Working Macros\Events.swp"

If your Macro files are on the network all you have to do is paste this into the shortcuts on each machine.

Regards,

Corey

message

Reply to
Corey Scheich

PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.