Autorunning a LISP depening on string in file name?

Autorunning a LISP depening on string in file name?

Anonymous
Not applicable
1,301 Views
4 Replies
Message 1 of 5

Autorunning a LISP depening on string in file name?

Anonymous
Not applicable

basically, what I'm looking to do is add a routine I have for basic maintenance of a site plan drawing to the startup. every drawing is named with numbers and then siteplan as such:

######_SITEPLAN.dwg

 

Is there a way for me to check if SITEPLAN is in the file name, then run a specific command?

 

(setq dwgname (strcase (getvar "dwgname")))

(if (= dwgname "*SITEPLAN.DWG")

(C:AutoSiteScrub)

)

 

 

That's the best I've got. AutoSiteScrub is the name of the command I wish to run upon startup. I'm just not sure that the way I'm specifying the drawing name is correct.

0 Likes
Accepted solutions (1)
1,302 Views
4 Replies
Replies (4)
Message 2 of 5

Ranjit_Singh
Advisor
Advisor
Accepted solution

Maybe add a startup function to your acaddoc.lsp file. Something like below

(defun-q spstartup ()
 (if (wcmatch (getvar 'dwgname) "*SITEPLAN.dwg")
  (print "This will print.")); after testing replace (print "This will print.") with (c:autositescrub)
(princ)) (setq s::startup (append s::startup spstartup))
Message 3 of 5

Kent1Cooper
Consultant
Consultant

@KDAWG1213 wrote:

....  I'm just not sure that the way I'm specifying the drawing name is correct.


I wouldn't think it's necessary to define a startup function per se, but you should just be able to include that in acaddoc.lsp directly, and it will run at the opening of every drawing.  But you do need the one correction that @Ranjit_Singh included, namely that you need the (wcmatch) function rather than the (=) function when checking whether that wording is part of the drawing name.

Kent Cooper, AIA
Message 4 of 5

scot-65
Advisor
Advisor
You may also try:

(vl-load-com)
(vl-string-search "SITEPLAN" (strcase (getvar 'DWGNAME)))

I do not remember if this function observes case-sensitivity...

???

Scot-65
A gift of extraordinary Common Sense does not require an Acronym Suffix to be added to my given name.

0 Likes
Message 5 of 5

Anonymous
Not applicable

This works perfectly. Thank you!!

0 Likes