bijoyvm Posted April 3, 2011 Share Posted April 3, 2011 hi, Is it possible to add Block Description while creating A new Block using LISP? eg. (defun c:OB(/ ssblk) (progn (setq ssblk (ssadd)) (command "_rectangle" (list -0.35 0.00 0.00)(list 0.35 0.70 0.00)) (setq ssblk (ssadd (entlast) ssblk)) (command "_Line" (list -0.35 0.00 0.00)(list 0.35 0.70 0.00)"") (setq ssblk (ssadd (entlast) ssblk)) (command "_Line" (list -0.35 0.70 0.00)(list 0.35 0.00 0.00)"") (setq ssblk (ssadd (entlast) ssblk)) (Command "CHPROP" ssblk "" "LA" "0" "") (command "-BLOCK" "BSO" (list 0 0 0) ssblk "") ) ) (princ) ) I like to add Block description ( Bottom Slab Opening ) in this block please help me... Thanks and regards bijoy Quote Link to comment Share on other sites More sharing options...
Ahankhah Posted April 3, 2011 Share Posted April 3, 2011 See these threads: http://www.cadtutor.net/forum/showthread.php?41041-Edit-Block-Description http://www.cadtutor.net/forum/showthread.php?37888-block-description-field http://www.cadtutor.net/forum/showthread.php?32877-Edit-Block-Description-Without-Exploding Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted April 3, 2011 Share Posted April 3, 2011 (edited) Some food for thought: (defun c:OB nil (if (or (tblsearch "BLOCK" "BSO") (progn (entmake (list (cons 0 "BLOCK") (cons 2 "BSO") (cons 8 "0") (list 10 0. 0. 0.) (cons 70 0) (cons 4 "Bottom Slab Opening") ) ) (entmake (list (cons 0 "LWPOLYLINE") (cons 100 "AcDbEntity") (cons 100 "AcDbPolyline") (cons 8 "0") (cons 90 4) (cons 70 1) (list 10 -0.35 0.0) (list 10 0.35 0.0) (list 10 0.35 0.7) (list 10 -0.35 0.7) ) ) (entmake (list (cons 0 "LINE") (cons 8 "0") (list 10 -0.35 0.0 0.0) (list 11 0.35 0.7 0.0) ) ) (entmake (list (cons 0 "LINE") (cons 8 "0") (list 10 -0.35 0.7 0.0) (list 11 0.35 0.0 0.0) ) ) (entmake (list (cons 0 "ENDBLK") (cons 8 "0") ) ) ) ) (entmakex (list (cons 0 "INSERT") (cons 2 "BSO") (list 10 0. 0. 0.) ) ) ) (princ) ) Will create the block definition if not present in the drawing and insert a block at 0,0,0. For a reference of what all the DXF codes mean, see here. Or in Visual LISP: (defun c:OB ( / acdoc ) (vl-load-com) (setq acdoc (vla-get-activeDocument (vlax-get-acad-object))) (if (not (tblsearch "BLOCK" "BSO")) ( (lambda ( block / poly line1 line2 ) (vla-put-comments block "Bottom Slab Opening") (setq poly (vlax-invoke block 'addlightweightpolyline '(-0.35 0.0 0.35 0.0 0.35 0.7 -0.35 0.7) ) ) (vla-put-closed poly :vlax-true) (vla-put-layer poly "0") (setq line1 (vlax-invoke block 'addline '(-0.35 0.0 0.0) '(0.35 0.7 0.0))) (setq line2 (vlax-invoke block 'addline '(-0.35 0.7 0.0) '(0.35 0.0 0.0))) (vla-put-layer line1 "0") (vla-put-layer line2 "0") ) (vlax-invoke (vla-get-blocks acdoc) 'add '(0. 0. 0.) "BSO") ) ) (vlax-invoke (vlax-get-property acdoc (if (= 1 (getvar 'CVPORT)) 'Paperspace 'Modelspace) ) 'InsertBlock '(0. 0. 0.) "BSO" 1. 1. 1. 0. ) (princ) ) Edited April 3, 2011 by Lee Mac Quote Link to comment Share on other sites More sharing options...
bijoyvm Posted April 4, 2011 Author Share Posted April 4, 2011 Thank you so much lee & ahankhah and i would like to learn VISUAL LISP is their is any simple tutorial please let me know thanks & regards bijoy.v.m Quote Link to comment Share on other sites More sharing options...
Ahankhah Posted April 4, 2011 Share Posted April 4, 2011 A very good reference is here: http://lee-mac.com/tutorials.html Quote Link to comment Share on other sites More sharing options...
bijoyvm Posted April 4, 2011 Author Share Posted April 4, 2011 Thanks Ahankhah... 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.