AutoLisp help - condition statement utilizing filename

AutoLisp help - condition statement utilizing filename

Anonymous
Not applicable
967 Views
3 Replies
Message 1 of 4

AutoLisp help - condition statement utilizing filename

Anonymous
Not applicable

Hi,

 

I'm trying to create an autolisp that has a cond to look at the file name and wblock out to a certain location and file name based off of that filename.  Is this possible?  I'm very new to Autolisp and I have no idea how to tell it to look at the filename.

 

for example if file name is oregon-FBL I want it to wblock to oregon-POR in a different specified folder

if filename is Ireland-FBL I want it to wblock to Ireland-POR in a different specified folder 

etc.

 

Thanks! Smiley Very Happy

0 Likes
Accepted solutions (3)
968 Views
3 Replies
Replies (3)
Message 2 of 4

john.uhden
Mentor
Mentor
Accepted solution

Maybe only an IF will do.  The wcmatch function might help you a great deal, e.g.

 

(if (wcmatch dwgname "*-FBL.DWG")
  ;; then do your thing.
)

Of course if you have more suffixes to deal with other than "-FBL" then you might need to set up a condition for each.

John F. Uhden

Message 3 of 4

john.uhden
Mentor
Mentor
Accepted solution

I didn't answer your primary question... how to get the dwgname.

 

We used to get the full name by concatenation...

 

(strcat (getvar :dwgprefix")(getvar "dwgname"))

but I always got confused whether the dwgprefix ended with a path delimiter, so then I would check for it and have code to add the delimiter if not present.

Since the advent of Vital Lisp, now Visual Lisp, we can get the full name in one shot...
(vl-load-com) ;; to load the ActiveX extensions (once per drawing is good enough)
(setq fullname (vlax-get (vlax-get (vlax-get-acad-object) 'Activedocument) 'Fullname))

John F. Uhden

Message 4 of 4

Anonymous
Not applicable
Accepted solution

This made it work.

 

(cond ((wcmatch (getvar "DWGNAME") "yourfilename.dwg") (command "whatever command you want"))
          ((wcmatch (getvar "DWGNAME") "yourfilename.dwg") (command "whatever command you want"))
)

0 Likes