Jump to content

Recommended Posts

Posted

I am wondering if one of you beautiful people can point me toward the right direction!

 

I have this code:

 

(defun C:TEST ( / )

(setq LNAME (strcase (GETVAR "LOGINNAME")))

(COND 
((= "MONK1" LNAME) (princ "WOOOOOO"))
((= "MONK2" LNAME) (princ "BOOOOO!!!!"))
(t (princ "EPIC FAIL"))
)
(princ)
)

 

I want to have it so that in a single = statement i can have LNAME compared against a list of "LOGINNAME" and do the action required.

 

Not sure how to get it to look at a list.

 

i.e.

((= "MONK2","MONK3","MONK4" LNAME) (princ "BOOOOO!!!!"))

 

Thanks in advance.

Posted
 
(cond
      ((member LNAME '("MONK2" "MONK2" "MONK3"))(princ "WOOOOOO"))
      ((member LNAME '("MONK4" "MONK5" "MONK6"))(princ "BOOOOO!!!!"))
            )

Posted

Another ... :)

 

(cond ((vl-position LNAME '("MONK2" "MONK3" "MONK4")) (princ "\n Wawwwwwww"))
     (t (princ "\n Booooo "))
)

Posted

Another:

 

(cond
   (   (wcmatch (getvar 'loginname) "MONK[234]")
       (princ "\nSuccess!")
   )
   (   (princ "\nFailure."))
)

Posted

I have changed my approach.

 

Instead of loginname im going to use getenv computername

 

We have 4 offices I need to change a load of paths and do a CAD setup as IT want to move some of our networked information. So I am going to have:

 

(defun C:TEST ( / )

(setq CNAME (strcase (GETENV "COMPUTERNAME")))

(COND 
((member CNAME '("W7072" "W7038"))("load up lisp routine A")) ;;OFFICE 1
((member CNAME '("W7011" "W7012"))("load up lisp routine B")) ;;OFFICE 2
(t (princ "EPIC FAIL"))
)
(princ)
)

 

where W7*** is a computer workstation name. It will load a routine which changes the (vla-get-Files(vla-get-Preferences(vlax-get-acad-object))) section with values i tell it.

 

Any thoughts on streamlining?

Posted

Another alternative to consider, is that you could technically use the same LISP routine to load the appropriate *Files* conditionally, pseudo code:

 

(vl-catch-all-apply
 'vla-put-supportpath
 (list
   oFilesPreferences
   (cond
     ;; OFFICE 1
     ((vl-position
        (setq cname (setq cname (strcase (getenv "COMPUTERNAME"))))
        '("W7072" "W7038"))
      ;; <- File paths, set A
      )

     ;; OFFICE 2
     ((vl-position cname '("W7011" "W7012"))
      ;; <- File paths, set B
      )
     (t (princ "EPIC FAIL")))
   )
 )

Posted

My process is as follows:

 

1. startup.lsp - This determines what building / department (using computername) which then loads a lisp accordingly.

 

2. a main "building type.lsp" routine is loaded - this loads subroutines to read and write to the vla-xxx-files etc. In this file the paths are written to the appropriate settings per building.

 

3. Files tab is updated and a log file (.txt) created. Job done.

 

It works at the moment but I wanted to add stage one above in. To allow a lot more flexibility.

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...