
Registered forum members do not see this ad.
hi,
Is it possible to add Block Description while creating A new Block using LISP?
eg.
I like to add Block description ( Bottom Slab Opening ) in this block please help me...Code:(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) )
Thanks and regards
bijoy
Mehrdad Ahankhah مهرداد آهن خواه
www.IranCAD.com
Some food for thought:
Will create the block definition if not present in the drawing and insert a block at 0,0,0.Code:(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) )
For a reference of what all the DXF codes mean, see here.
Or in Visual LISP:
Code:(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) )
Last edited by Lee Mac; 3rd Apr 2011 at 03:13 pm.
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper

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
A very good reference is here:
http://lee-mac.com/tutorials.html
Mehrdad Ahankhah مهرداد آهن خواه
www.IranCAD.com

Registered forum members do not see this ad.
Thanks Ahankhah...
Bookmarks