TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: tedg on August 04, 2021, 01:23:43 PM

Title: is there a way for "if path nil, use this path"?
Post by: tedg on August 04, 2021, 01:23:43 PM
Hello all, been a while since I posted here..
Hoping this is an easy fix or there's maybe an easier way.
 

I /we have a custom "revcloud" routine that we use, that inserts a rev triangle block (delta with attributes) from the same location that the lisp routine lives on our server.
The issue is, with most of us working remotely, and we use Dropbox as our virtual server when away from the office, the path isn't the same as if in the office.
The office computers don't/won't have Dropbox loaded, as I've been told.


(example)
Code: [Select]
(command "-insert" "C:\\Dropbox\\CADD\\Symbols\\Revision") ;;dropbox location
;;vs
(command "-insert" "Y:\\Symbols\\Revision") ;;office server





So is there a way to force which drive in gets the dwg file from depending on where the routine lives?
Any other ideas?
I'm trying to make it idiot-proof for people using the routine no matter where they are working, and avoid having duplicates of the routine with different names (which may be my option B).
Thanks
Title: Re: is there a way for "if path nil, use this path"?
Post by: mhupp on August 04, 2021, 01:36:40 PM
Code: [Select]
(if (not (findfile (setq path "C:\\Dropbox\\CADD\\Symbols\\Revision")))
  (setq path "Y:\\Symbols\\Revision")
)
(vl-cmdf "-insert" path)
Title: Re: is there a way for "if path nil, use this path"?
Post by: tedg on August 04, 2021, 02:31:20 PM
Code: [Select]
(if (not (findfile (setq path "C:\\Dropbox\\CADD\\Symbols\\Revision")))
  (setq path "Y:\\Symbols\\Revision")
)
(vl-cmdf "-insert" path)


Thanks mhupp, this helped!
Title: Re: is there a way for "if path nil, use this path"?
Post by: ronjonp on August 05, 2021, 10:11:38 AM
Can also be written like this:
Code - Auto/Visual Lisp: [Select]
  1. (setq path (cond ((findfile "C:\\Dropbox\\CADD\\Symbols\\Revision"))
  2.                  ((findfile "Y:\\Symbols\\Revision"))
  3.            )
  4. )