Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Automate to fill Custom Properties? 2

Status
Not open for further replies.

MFDO

Mechanical
Joined
Aug 10, 2005
Messages
217
Location
CA
Is it possible to fill automatically the Custom Properties such as “DrawnDate”(=current date short) and "DrawnBy" (=Login Name) in a NEW part/assembly/drawing

If they are already populated, then they should not change.

SWX2007SP2.1 x64

 
Code:
Dim Today as String
Today = CStr(Month(Now)) & "/" & CStr(Day(Now)) & "/" & Right(CStr(Year(Now)), 2)
Part.CustomInfo2("", "DrawnDate") = Today

[bat]Honesty may be the best policy, but insanity is a better defense.[bat]
-SolidWorks API VB programming help
 
Thanks Matt,
Is there a way of inserting the login name?
 
Login name is something you would have to get from the Windows system. I think it requires Windows API calls. < I've done it, but I would have to go look it up all over again. That means that I'm not going to and it will be faster for you to.[poke]
 
If you are using your own custom property editor, I would suggest just having an external .ini that lists the contributors. I have a sample property editor on my site that provides a quick and dirty method for this within the macro - no external references -( Problem with using login names is that they tend not to be in human understandable terms. (does jsenji mean "J. Senji", "Jsenji" or "Jsenj I."?)

Matt
CAD Engineer/ECN Analyst
Silicon Valley, CA
 
You can get login name from an environment variable "USERNAME" that holds the Windows login information:

Dim myUserName as String

myUserName = environ("USERNAME")
 
Please bear with me; I’m not good in API or any programming.

Is it possible to run these macros automatically when making new drawings?
 
I mean these macros to be part of the drawing templates!
 
Yes, but it's not convenient, and not necessary. You'll need to make an overall SolidWorks add-in that will keep track and active the necessary function at the right now. Very hard. Just assign keystrokes to them. Much easier and lets the user control when to use them.

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

Part and Inventory Search

Sponsor

Back
Top