Jump to content

IF statements on a list within an external text file.


monk

Recommended Posts

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!)

Link to comment
Share on other sites

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 :)

Link to comment
Share on other sites

May do also something like this:

(setq UserAndTemplates '(("User1" . "Template1")
                        ("User2" . "Template2")
                        ("User3" . "Template3")))
([i]SetTemplateFunction[/i] (cdr (assoc (getvar "LOGINNAME") UserAndTemplates)))

Regards,

Mircea

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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")

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...