jwhitens Posted December 7, 2011 Posted December 7, 2011 I've currently taken on the task of updating my organization's title blocks. I'm utilizing Fields in the title block in conjunction with system and sheet set manager variables. I've noticed in the Field Dialog Box there is a CreateDate field choice to display the date the file was created. My question is, is there - or is it possible to create - a system variable that is capable of retrieving the Windows login name of the user who created the file? There are multiple workstations at my organization and former users capable of creating AutoCAD files. I would like to be able to retrieve their Windows login name (eg. jwhitens) of the user who created the file to display as the "Drawn By" field in my title block. Any help would be greatly appreciated. Thanks! Quote
JGA Posted December 8, 2011 Posted December 8, 2011 How about setting the user name to Joe Bloggs in the Options - System tab. Then point a field to the USERNAME system variable? The disadvantage to doing this is when Wendy Biggins opens up the drawing & she is noted as the author in the dialogue box. In windows, the way of listing the login name is by using %username%, but I don't know how you can transfer this to AutoCAD. LISP could probably get the info, but it's above my head! Quote
JGA Posted December 8, 2011 Posted December 8, 2011 ...or Field category PLOT - Login - Bingo! Please note that this will change depending upon the login that has opened the drawing. I don't know of a way of fixing the original field entry. Quote
BIGAL Posted December 9, 2011 Posted December 9, 2011 Using lisp etc you can get current user but you would be better assigning an attribute this value not as a field so it stays as one value only. have a look at setvar ? * you will see yourself there multiple times now %username% where is it ? Not it but close (GETENV "computername") 2nd go Why didn't I think of it (GETENV "username") Quote
BlackBox Posted December 9, 2011 Posted December 9, 2011 (edited) Did you mean: (getvar 'loginname) ...? I started to write a .NET LispFunction for AutoCAD ("GetOwner"?) that would accept a single argument, a file path as a string, that would use System.IO.File Class to return the file's owner... Busy week, just haven't gotten around to finishing it... Maybe tomorrow? *shrug* Edited December 9, 2011 by BlackBox Quote
BlackBox Posted December 9, 2011 Posted December 9, 2011 Not that this is the only way to obtain the file owner per-se; I just enjoyed this little challenge.. My first complete .NET offering "GetOwner" Simply NETLOAD the .DLL into your session of AutoCAD, then use as needed at the command line, or within the VLIDE. Example: (GetOwner (findfile "acad.pgp")) ** Notes - Code compiled to .NET framework 3.5, using Kean's plug-in wizard, and tested on Civil 3D 2011 (.NET 3.5), and Civil 3D 2012 (.NET 4.0). Enjoy! GetOwner.zip Quote
jwhitens Posted December 9, 2011 Author Posted December 9, 2011 Just netloaded the .dll into acaddoc.lsp and it works great when I key in the code in the Command line, Thanks! Any ideas on how to utilize this LispFunction so it can be used in a Field such as a LispVariable or DieselExpression? I'd like to create the Field in my Title Block Template file that will extract the Owner's info from the DWG file that I am inserting the Title Block into. Quote
BIGAL Posted December 11, 2011 Posted December 11, 2011 "Owner's info from the DWG file that I am inserting the Title Block into" you would be far better of having your title block as a template rather than inserting a Title block into a dwg. You need maybe a script that opens your template and then runs a lisp that populates a certain attribute value with owners name it should not be a field, as fields are there to continuously update . You can also create start up lisp that will run when you open a new drawing. Create a menu command that is a "NEW" you can edit the original menu also and patch the default NEW to do something different or even remove it forcing users to create new drawings in the correct manner. The suggestion above are telling you how do what you want do you have any lisp skills ? Insert dwg ? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.