PDA

View Full Version : Block with attrib using entmake



vlee
2004-06-29, 10:48 PM
Can someone give me an example on how to create a block with attributes using entmake.
I can create a block, but when I entmake to create the attribute, it returns nil.
I am not sure which dotted pair is required for the (0 . "ATTRIB")

Any assistance would be appreciated

David.Hoole
2004-06-30, 07:50 AM
Hi vlee

Here's a very simple example which creates a block called "revmk", with a single attribute. Make sure the text style called by the attribute derfinition (romans in this case) exists in the drawing before running the code.

;code start

(entmake '((0 . "block")
(2 . "revmk")
(10 0.0 0.0 0.0)
(70 . 2)
)
)
(entmake '((0 . "attdef")
(8 . "revision")
(10 0.0 0.0 0.0)
(40 . 2.5)
(41 . 0.8)
(72 . 4)
(73 . 2)
(1 . "rev")
(7 . "romans")
(3 . "Enter revision")
(2 . "rev")
(70 . 4)
)
)
(entmake '((0 . "line")
(8 . "revision")
(62 . 1)
(10 -3.5 -2.0207 0.0)
(11 3.5 -2.0207 0.0)
)
)
(entmake '((0 . "line")
(8 . "revision")
(62 . 1)
(10 3.5 -2.0207 0.0)
(11 0.0 4.0415 0.0)
)
)
(entmake '((0 . "line")
(8 . "revision")
(62 . 1)
(10 0.0 4.0415 0.0)
(11 -3.5 -2.0207 0.0)
)
)
(entmake '((0 . "endblk")))
;code end

peter
2004-06-30, 02:45 PM
Just for the other way of doing this...



(defun C:AddNewBlock (/ objNewBlock)
(setq objNewBlock (vla-add
(vla-get-blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
)
(vlax-3d-point (list 0.0 0.0 0.0))
"MyNewBlock"
)
)
(print "x")
(vla-addattribute objNewBlock
(/ (getvar "dimscale") 10.0)
8
"UserPrompt"
(vlax-3d-point (list 0.0 0.0 0.0))
"UserTagString"
"UsertTextValue"
)
)


Peter Jamtgaard

vlee
2004-06-30, 03:00 PM
Thank you for you responses. Works great.