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.
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.
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
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.
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)
SolidWorks 2003 World User Conference Exhibitor Booth #407
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.
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
Sub main() Set ThisLibrary.swApp = Application.SldWorks End Sub
3) then Paste this code in Solidworks Objects/ThisLibraryDim 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
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.