monk Posted March 12, 2012 Share Posted March 12, 2012 Hello, I have written a lisp which changes paths under the "Files" tab of the options box. I have 3 sections which I change; template, support paths and miscellaneous (CTB path, temp drawing path and tool palettes) My question is: With "PageSetupOverridesTemplateFile" and "qnewtemplatefile" how easy is it to write in IF "LOGINNAME" is on list1 put path1, if on list2 put path2 etc. We have 3 or 4 template files depending on what building you work in. I want to have one routine that puts the right path for the right person. I was thinking of having some LOGINNAME .txt files and the routine will look in each on and then do an appropriate action. Hope that made sense! (This could be tackled another way buy i wanted to look into this route for my own learning! Any pointers helpful!) Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 12, 2012 Share Posted March 12, 2012 If you have more than 2 cases you should look to COND statement. Regards, Mircea Quote Link to comment Share on other sites More sharing options...
monk Posted March 12, 2012 Author Share Posted March 12, 2012 Ok I shall do that thanks. I am busy at work at the moment but just want to discuss my thought process: For example I have the main routine plus 2 other files called USERS1 and USERS2 The main routine says IF LOGINNAME = something on USERS1 put PATH1 in "qnewtemplatefile" and of course if LOGINNAME = something on USERS 2 put PATH2 in "qnewtemplatefile" This way we can perhaps stick whoever we want on each list and their CAD will be configured accordingly. In the meantime i will look into COND Quote Link to comment Share on other sites More sharing options...
MSasu Posted March 12, 2012 Share Posted March 12, 2012 May do also something like this: (setq UserAndTemplates '(("User1" . "Template1") ("User2" . "Template2") ("User3" . "Template3"))) ([i]SetTemplateFunction[/i] (cdr (assoc (getvar "LOGINNAME") UserAndTemplates))) Regards, Mircea Quote Link to comment Share on other sites More sharing options...
Stefan BMR Posted March 12, 2012 Share Posted March 12, 2012 If you want a different Settings in Option->File tab for each user, you can do it this way: 1). Create a custom Profile for each user and set each one as you need 2). Create separate shortcut to Autocad on your desktop 3). Use /p switch in shortcut to force Autocad to load a specific Profile, like "C:\Program Files\Autodesk\AutoCAD 2012\acad.exe" /p "User1" and rename the shortcut accordingly. Autocad Structural Detailing does this at installation time: one shortcut for plain Acad and another one for Structural Detailing. Of course, if "user" means Windows user, you can keep a single shortcut on desktop for each user. Quote Link to comment Share on other sites More sharing options...
monk Posted March 12, 2012 Author Share Posted March 12, 2012 At the moment All CAD users have a startup lisp load. This is something I can then change. for example the startup lisp loads another lisp that can control settings. This means in seconds I can change s support path across the board. We are currently looking at turning off one of our network drives, the R: drive. This means our CAD setup will no longer be able to find the files and everyone will scream. What I can now do is enter a couple of lines of code and it will tell everyones machine to look in the new location. What I am trying to do is not have to go around to everyones machine and change things. Nor do I want to be creating bespoke profiles. I think this is quite a quick way of doing things. We have 4 offices some distance apart and for simply changing R:\example to S:\example i think my routine handles it pretty easily. Quote Link to comment Share on other sites More sharing options...
monk Posted March 12, 2012 Author Share Posted March 12, 2012 EXAMPLE.zip Attached my current version of what i am discussing. The mainlisp controls everything and loads up all subroutines needed. Credits go to LeeMac as I used his support path routine which i hope he doesn't mind! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 12, 2012 Share Posted March 12, 2012 Credits go to LeeMac as I used his support path routine which i hope he doesn't mind! Not at all, I'm glad you can make use of them - thank you for the courtesy of acknowledgement. Quote Link to comment Share on other sites More sharing options...
monk Posted March 12, 2012 Author Share Posted March 12, 2012 Very useful, even if it was just to learn other ways of writing the same thing. I initially wrote one that just added the paths you tell it, but it didn't retrieve the current support paths and so if the user added paths of their own they would be lost. Your routine sticcks a path onto the current list. Nifty! I shall "buy you a beer" when i get round to it! Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 12, 2012 Share Posted March 12, 2012 Thanks monk! Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 13, 2012 Share Posted March 13, 2012 We use this when making a new box but you could easily add in if statements etc ; This sets a reference to the install path of your product ; the gets are their for info maybe other use (vl-load-com) ; make temp directory ;(vl-mkdir "c:\\ACADTEMP") (setq *files* (vla-get-files (vla-get-preferences (vlax-get-acad-object)))) ; savepath ;(vla-get-AutoSavepath *files*) (vla-put-AutoSavepath *files* "C:\\ACADTemp") ; custom icons ;(vla-get-CustomIconPath *files*)) (vla-put-CustomIconPath *files* "S:\\Autodesk\\ICONS") ; printers config ;(vla-get-PrinterConfigPath *files*) (vla-put-PrinterConfigPath *files* "S:\\AutoDESK\\Plotting\\Plot Styles 2011") ; printers style sheet ;(vla-get-PrinterStyleSheetPath *files*) (vla-put-PrinterStyleSheetPath *files* "S:\\AutoDESK\\Plotting\\Plot Styles") ; printer drv's ;(vla-get-PrinterDescPath *files*) (vla-put-PrinterDescPath *files* "S:\\AutoDESK\\Plotting\\Drv") ; print spooler ;(vla-get-PrintSpoolerPath *files*) (vla-put-PrintSpoolerPath *files* "C:\\ACADTemp\\") ; template location ;(vla-get-QnewTemplateFile *files*) (vla-put-QnewTemplateFile *files* "S:\\Autodesk\\c3d Templates\\cogg.dwt") ;make new support paths exist + new (setq paths (vla-get-SupportPath *files*)) (setq mygpaths "S:\\autodesk\\supportfiles; S:\\autodesk\\lisp; S:\\autodesk\\fonts; S:\\autodesk\\hfs fonts;" ) (setq newpath (strcat mygpaths paths)) (vla-put-SupportPath *files* newpath) ; Tempdirectory ;(vla-get-TempFilePath *files*)) (vla-put-TempFilePath *files* "C:\\ACADTemp\\") ; template path ;(vla-get-TemplateDwgPath *files*) (vla-put-TemplateDwgPath *files* "S:\\Autodesk\\c3d Templates") ; xref temp path ;(vla-get-TempXrefPath *files*)) (vla-put-TempXrefPath *files* "C:\\ACADTemp\\") ; end use of *files* (vlax-release-object *files*) ; exit quitely (princ "All Done") Quote Link to comment Share on other sites More sharing options...
monk Posted March 13, 2012 Author Share Posted March 13, 2012 Looks good BIGAL. I think we achieve the same thing just with different ways of doing it I am mainly looking at remote administration and gaining feedback via the log file creator. Thanks. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted March 14, 2012 Share Posted March 14, 2012 Not sure if you are aware but you can get login name from within Autocad (GETENV "username")you may be able to do 1 batch file that checks username and then copys correct profile as you start Autocad you would edit the command line in your Autocad desktop Icon. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 14, 2012 Share Posted March 14, 2012 Not sure if you are aware but you can get login name from within Autocad (GETENV "username") Also, (getvar 'LOGINNAME) Quote Link to comment Share on other sites More sharing options...
monk Posted March 14, 2012 Author Share Posted March 14, 2012 I use this: (getvar "LOGINNAME") What does the >> ' (getvar 'LOGINNAME) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 14, 2012 Share Posted March 14, 2012 In LISP, the apostrophe means "do not evaluate this expression" and so any expression preceded with an apostrophe is taken at face-value. Now look at the documentation for the getvar function (equally for setvar): getvar Retrieves the value of an AutoCAD system variable. (getvar varname) Arguments varname A string or symbol that names a system variable. Return Values The value of the system variable; otherwise nil, if varname is not a valid system variable. Quote Link to comment Share on other sites More sharing options...
monk Posted March 14, 2012 Author Share Posted March 14, 2012 Awesome I understand Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted March 14, 2012 Share Posted March 14, 2012 Good stuff Quote Link to comment Share on other sites More sharing options...
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.