CADZealot Posted June 21, 2019 Share Posted June 21, 2019 Hi Everyone, I have a three lisp to create layouts automatically for three different sheet size. (A1,A2 & A3). Right now I'm running the lisp separately for required sheet size. Instead of that can we run the lisp based on block name which i inserted for layout creation. For Ex. If i inserted A2 block, then lisp will check the block availability (A1,A2 & A3) A2 is available now...so lisp for creating A2 sheet should be run. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 21, 2019 Share Posted June 21, 2019 Hi, You can use instead the functions initget & getkword for a dynamic way. Hit THIS LINK. Quote Link to comment Share on other sites More sharing options...
CADZealot Posted June 21, 2019 Author Share Posted June 21, 2019 Hi Tharwat, Using that we can run the lisp from the options..but in that case we need to select the lisp based on inserted block. Is there any other way to run the lisp automatically by available block name. Thanks. Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 21, 2019 Share Posted June 21, 2019 What I meant with my previous reply is that you can have one program asks the user about the block name then insert it if that block name is existed into the same drawing otherwise an alert message to inform the user is that the block name is not available. (initget "A1 A2 A3") (setq blk (getkword "\nSpecify block name to insert [A1,A2,A3:")) (if (tblsearch "BLOCK" blk) ;;; then your stuff here to insert the desire block name once its available in drawing. ;; else alert a message to user. ) Quote Link to comment Share on other sites More sharing options...
CADZealot Posted June 21, 2019 Author Share Posted June 21, 2019 Thanks for the Explanation, I have checked that but i don't know exactly that how to modify that. could you please help me on this. (defun c:123(/) (initget "A1 A2 A3") (setq blk (getkword "\nSpecify block name to insert [A1,A2,A3]:")) (if (tblsearch "BLOCK" blk) (C:A1) (C:A2) (C:A3) ;;; then your stuff here to insert the desire block name once its available in drawing. ;; else alert a message to user. ;(alert "Hi") ) ) (defun c:A1 (/) (alert "A1 Here") ) (defun c:A2 (/) (alert "A2 Here") ) (defun c:A3 (/) (alert "A3 Here") ) Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 21, 2019 Share Posted June 21, 2019 Give this a go and let me know. (defun c:Test (/ blk) (initget "A1 A2 A3") (and (setq blk (getkword "\nSpecify block name to insert [A1,A2,A3]:")) (or (tblsearch "BLOCK" blk) (alert (strcat "Block name < " blk " > was not found in this drawing." ) ) ) (eval (nth (vl-position blk '("A1" "A2" "A3")) '((c:A1) (c:A2) (c:A3)) ) ) ) (princ) ) Quote Link to comment Share on other sites More sharing options...
ronjonp Posted June 21, 2019 Share Posted June 21, 2019 (edited) @Tharwat I did not read this whole thread but FWIW .. you could shorten up your eval code like so: (eval (read (strcat "(c:" blk ")"))) Edited June 21, 2019 by ronjonp Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 21, 2019 Share Posted June 21, 2019 Thanks Ron for your important note. Although that I recommended the OP just to have these three routines as one but apparently they have their reason to go with one. Quote Link to comment Share on other sites More sharing options...
CADZealot Posted June 21, 2019 Author Share Posted June 21, 2019 Thank you so much Ron and Tharwat, It's working perfectly now. Thanks Again Quote Link to comment Share on other sites More sharing options...
Tharwat Posted June 22, 2019 Share Posted June 22, 2019 9 hours ago, CADZealot said: Thank you so much Ron and Tharwat, It's working perfectly now. Thanks Again Good to hear that. You're welcome anytime. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.