View Full Version : Using entmake to create (redefine) Blocks
melkor
2005-01-26, 10:07 PM
I want to use entmake to create (redefine) blocks. Does anyone have a snippet of example code?
thanks
stig.madsen
2005-01-26, 11:16 PM
Sure. Here's a little snippet:
(defun makeBlock (blockname)
;; create BlockBegin entity
(cond ((entmake
(list '(0 . "BLOCK")
'(100 . "AcDbEntity")
'(100 . "AcDbBlockBegin")
;; ^ code 100's not needed for BlockBegin but nice to have
;; for future reference
(cons 2 blockname)
'(70 . 0)
'(10 0.0 0.0 0.0)
)
)
;; create some line art (block subentities)
(entmake '((0 . "LINE") (10 0.0 0.0 0.0) (11 10.0 10.0 0.0)))
(entmake '((0 . "LINE") (10 10.0 10.0 0.0) (11 -10.0 10.0 0.0)))
(entmake '((0 . "LINE") (10 -10.0 10.0 0.0) (11 0.0 0.0 0.0)))
(entmake '((0 . "LINE") (10 0.0 10.0 0.0) (11 0.0 20.0 0.0)))
(entmake '((0 . "LINE") (10 0.0 20.0 0.0) (11 50.0 20.0 0.0)))
;; create BlockEnd entity
(entmake (list '(0 . "ENDBLK") '(100 . "AcDbBlockEnd")))
;; ^code 100 for BlockEnd not needed either but still good
;; to have for reference
)
)
)
If you want to include attributes, just put them in as ATTDEF's before the AcDbBlockEnd (and add 2 to group 70 for AcDbBlockBegin).
melkor
2005-01-27, 12:51 AM
great, thanks, I will give it a try.
vBulletin® v3.6.7, Copyright ©2000-2009, Jelsoft Enterprises Ltd.