PDA

View Full Version : How to add Block Description



bijoyvm
3rd Apr 2011, 08:48 am
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

Ahankhah
3rd Apr 2011, 09:13 am
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

Lee Mac
3rd Apr 2011, 02:00 pm
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 (http://docs.autodesk.com/ACD/2011/ENU/filesDXF/WSfacf1429558a55de185c428100849a0ab7-5f35.htm).

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

bijoyvm
4th Apr 2011, 05:30 am
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

Ahankhah
4th Apr 2011, 06:08 am
A very good reference is here:
http://lee-mac.com/tutorials.html

bijoyvm
4th Apr 2011, 08:57 am
Thanks Ahankhah...