Jump to content

Recommended Posts

Posted

I have a hopfully easy question. I have a simple lisp that catch the current drawing name then strips out all but the last two characters. Which is the way are database is setup the last to character reprensent a discipline (example Xx01a1 is architectural first floor plan, Xx01e1 would be Lighing plan etc...) and we have a custom commands (A1, A2, E1, E2....) so when we re-file building floor back into are main database they all setup the same. My lisp works until I try call up the setq as a command it says "unknown command" "A1". Which if I type A1 into the command prompt it will run A1. Hopfully this makes sence.

 

(defun c:test ()
(setq names (vl-filename-base (getvar "dwgname"))) ;returns just name 
(setq name (substr names 5)) ;returns just the last 2 characters of drawing name
(command name))

 

Thanks

Posted

Those commands are AutoLISP routines? If affirmative, then you should call them as:

(c:a1)

Therefore your code become:

(eval (read (strcat "(c:" name ")")))

Posted

Hey MSasu, Thank you very much. That did it.

 

Thanks again

Posted

You're welcome!

 

Another comment, you can extract the type in a much flexible way:

(setq names (vl-filename-base (getvar "DWGNAME")))
(setq name (substr names (1- (strlen names))))

Posted

If I may ask. How is this more flexible?

Posted

That will retrive the last two characters from file's name, no matter how long is that name.

Posted

Another crazy way of doing that, for the fun of it. :)

 

(setq names
          (vl-filename-base
                (substr (setq names (getvar "DWGNAME"))
                        (1- (vl-string-position 46 names nil t)))))

 

Edited for filenames with "."

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