hunszab Posted July 19, 2010 Posted July 19, 2010 Hi everyone! I'd like to write an autolisp function, to insert a specific block. So: Insert-> Block-> "myblock" + ENTER. That's what I want to do from code, because it has to do 1000 times.... Thanks any help! (it has to do somehow with "_insert" command... ) Quote
profcad Posted July 19, 2010 Posted July 19, 2010 Give us some specifics. 1. Name of Block 2. Scale factor 3. Rotation angle 4. Any specific layer you want them inserted on. Quote
hunszab Posted July 19, 2010 Author Posted July 19, 2010 Give us some specifics. 1. Name of Block 2. Scale factor 3. Rotation angle 4. Any specific layer you want them inserted on. For example: 1. Name of Block: myblock 2. Scale factor: Specify on screen 3. Rotation: Specify on screen or scale factor: 1 , 1 , 1 rotation: 0.0 Quote
alanjt Posted July 19, 2010 Posted July 19, 2010 For example:1. Name of Block: myblock 2. Scale factor: Specify on screen 3. Rotation: Specify on screen or scale factor: 1 , 1 , 1 rotation: 0.0 Quickie example... (defun _InsertBlock (block x y / x y) ;; block - name of block ;; x - X scale for block (nil for on-screen prompt) ;; y - Y scale for block (nil for on-screen prompt) ;; Alan J. Thompson, 07.19.10 (if (or (tblsearch "BLOCK" block) (findfile (strcat block ".DWG"))) (if (and (or x (setq x (cond ((getdist "\nSpecify X value <1.0>: ")) (1.) ) ) ) (or y (setq y (cond ((getdist (strcat "\nSpecify Y value <" (rtos x) ">: "))) (x) ) ) ) ) (command "_.-insert" block "_X" x "_Y" y) ) (alert (strcat "Block: \"" block "\" cannot be found!")) ) (princ) ) (defun c:Test1 (/) (_InsertBlock "P6" nil nil) (princ)) (defun c:TEst2 (/) (_InsertBlock "P6" 1. 1.) (princ)) (defun c:TEst3 (/) (_InsertBlock "P6" 1. nil) (princ)) Quote
hunszab Posted July 19, 2010 Author Posted July 19, 2010 Thanks a lot! Could you give me some advice, where can I found some information about "_.-insert" command. I've just found "_insert"... And how can I wait for user input from Lisp code? Thanks!!! Quickie example... (defun _InsertBlock (block x y / x y) ;; block - name of block ;; x - X scale for block (nil for on-screen prompt) ;; y - Y scale for block (nil for on-screen prompt) ;; Alan J. Thompson, 07.19.10 (if (or (tblsearch "BLOCK" block) (findfile (strcat block ".DWG"))) (if (and (or x (setq x (cond ((getdist "\nSpecify X value <1.0>: ")) (1.) ) ) ) (or y (setq y (cond ((getdist (strcat "\nSpecify Y value <" (rtos x) ">: "))) (x) ) ) ) ) (command "_.-insert" block "_X" x "_Y" y) ) (alert (strcat "Block: \"" block "\" cannot be found!")) ) (princ) ) (defun c:Test1 (/) (_InsertBlock "P6" nil nil) (princ)) (defun c:TEst2 (/) (_InsertBlock "P6" 1. 1.) (princ)) (defun c:TEst3 (/) (_InsertBlock "P6" 1. nil) (princ)) Quote
alanjt Posted July 19, 2010 Posted July 19, 2010 Thanks a lot! Could you give me some advice, where can I found some information about "_.-insert" command. I've just found "_insert"... And how can I wait for user input from Lisp code? Thanks!!! _ ignores language change . ignores redefined command - issue commandline version of command (if available) Actually, this may suite you better... (defun _InsertBlock (block x y r / x y r) ;; block - name of block ;; x - X scale for block (nil for on-screen prompt) ;; y - Y scale for block (nil for on-screen prompt) ;; r - rotation of block (nil for on-screen prompt) [MUST BE IN RADIANS] ;; Alan J. Thompson, 07.19.10 (if (or (tblsearch "BLOCK" block) (findfile (strcat block ".DWG"))) (if (and (or x (setq x (cond ((getdist "\nSpecify X value <1.0>: ")) (1.) ) ) ) (or y (setq y (cond ((getdist (strcat "\nSpecify Y value <" (rtos x) ">: "))) (x) ) ) ) ) (progn (command "_.-insert" block "_X" x "_Y" y) (and r (command "_r" (angtos r))) ) ) (alert (strcat "Block: \"" block "\" cannot be found!")) ) (princ) ) (defun c:Test1 (/) (_InsertBlock "P6" nil nil nil) (princ)) (defun c:TEst2 (/) (_InsertBlock "P6" 1. 1. nil) (princ)) (defun c:TEst3 (/) (_InsertBlock "P6" nil nil pi) (princ)) Quote
hunszab Posted July 20, 2010 Author Posted July 20, 2010 Hi! I want to iterate this command , so how can I wait for the user input? Specificly: I want to insert my blocks, until the user say OK, its enough. Quote
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.