It woks fine.
Can you paste the error reply please ?
Regards


Registered forum members do not see this ad.
I get error while adding an attribute to a block using ENTMAKE "attdef".
What am I doing wrong ?
Code:;makes a block and inserts to drawing (defun C:test_blk() (setq x 4 y 4) (setq ot 0.3 ) (if (= ct nil) (setq ct 1)) (setvar "CMDECHO" 0) (and (not (tblsearch "BLOCK" (setq blk_nm (strcat "SP" (rtos ct 2 2))))) (entmake (list (cons 0 "BLOCK") (cons 2 blk_nm) (list 10 0 0 0) (cons 70 0))) (entmake (list (cons 0 "3DFACE")(cons 8 "0") (list 10 0 0 0) ;First corner (list 11 x 0 0) ;Second corner (list 12 x y 0) ;Third corner (list 13 0 y 0))) ; Fourth corner (entmake (list (cons 0 "TEXT") ;*** (cons 1 "P10") ;Default value (the string itself) (cons 6 "BYLAYER") (cons 7 "STANDARD") ;Text style name (cons 8 "0") (cons 10 (list (+ ot) ot 0.0)) ;First alignment point ;(cons 11 (list 0.0 0.0 0.0)) ;*** (cons 39 0.0) (cons 40 1.5) ;Text height (cons 41 1.0) ;Relative X scale factor (cons 50 0.0) ;Text rotation (cons 51 0.0) ;Oblique angle ( (cons 62 256) (cons 210 (list 0.0 0.0 1.0)))) ;;;(entmake (list (cons 0 "ATTDEF") ; ;;; (cons 8 "0") ;;; (cons 10 (list ot (+ y ot) 0)) ;Text start point ;;; (cons 40 2) ;Text height ;;; (cons 1 "55") ;Default value (string) ;;; (cons 2 "TAGNAME") ;Attribute tag (string; cannot contain spaces) ;;; (cons 70 0) ;;; (cons 73 0) ;;; (cons 50 0) ;Text rotation (optional; default = 0) ;;; (cons 41 1) ;Relative X scale factor ;;; (cons 51 0) ;;; (cons 7 "STANDARD") ;*** ;;; (cons 71 0) ;;; (cons 72 0) ;;; ;(cons 11 (list 0 0 0)) ;Alignment point ;;; (cons 210 (list 0 0 1));Extrusion direction. ;;; (cons 74 0) ;;; (cons 62 256) ;;; (cons 39 0) ;;; (cons 6 "BYLAYER"))) (entmake (list (cons 0 "ENDBLK")(cons 8 "0")))) (setq blk_rh (entlast)) (while (eq blk_rh (entlast)) (command "_.INSERT" blk_nm)) (setq ct (+ ct 1)) );defun
Last edited by sadhu; 27th Aug 2010 at 12:19 pm.
lost


It woks fine.
Can you paste the error reply please ?
Regards
Look into group 70 of the BLOCK header call. The 2 bit should be set if variable attributes follow.
Also, a decimal is an invalid block name character. ( rtos ct 2 2 ) includes a decimal.
Those are for starters at least. -David
R12 (Dos) - A2K


After the block is inserted in dwg I type "ATTEDIT" and select the block - there are no attributes to edit.
Command: attedit
Select block reference: That block has no editable attributes.
lost


Thanks David - most of the code is from your post in the SWAMP.
fixed entmake block :
Still have to get the attributes working.Code:(cons 70 2)
lost


Code below seems to work but it isn't satisfactory.
The ENTMAKE attdef code 3 asks for keyboard input while I want it to be a variable generated in LISP (a counter).
Is it possible with ENTMAKE or do I have to look for another solution?
Code:(defun c:test_blk () (setq x 4 y 4) (setq ot 0.3 ) (if (= ct nil) (setq ct 1)) ;BLOCK Header definition: (entmake '((0 . "BLOCK") (2 . "blk_nm") (70 . 2) (10 0.0 0.0 0.0))) ;POINT marker definition: (entmake '((0 . "POINT") (8 . "0") (10 0.0 0.0 0.0) (210 0.0 0.0 1.0) (50 . 0.0))) (entmake (list (cons 0 "3DFACE")(cons 8 "0") (list 10 0 0 0) ;First corner (list 11 x 0 0) ;Second corner (list 12 x y 0) ;Third corner (list 13 0 y 0))) ; Fourth corner ;Text ATTRIBUTE definition: (entmake '((0 . "ATTDEF") (8 . "0") (10 0.3 4.3 0.0 ) ;First alignment point (1 . "") (2 . "num");Tag string (cannot contain spaces) (3 . "number ??");Prompt string (40 . 2.0) (41 . 1.0) (50 . 0.0) (70 . 0) (71 . 0) (72 . 0) (73 . 2)) ) ;BLOCK's ending definition: (entmake '((0 . "ENDBLK"))) (command "_.INSERT" blk_nm) )
lost




try this
Code:(entmake (list (cons 0 "ATTDEF") (cons 8 0) etc... (cons 3 variable);variable should be string etc.
This should perhaps point you in the right direction:
Code:(defun GenerateBlock ( name pt ) (if (not (tblsearch "BLOCK" name)) (progn (entmake (list (cons 0 "BLOCK") (cons 2 name) (cons 70 2) (cons 10 '(0. 0. 0.)) ) ) (entmake (list (cons 0 "POINT") (cons 8 "0") (cons 10 '(0. 0. 0.)) ) ) (entmake (list (cons 0 "3DFACE") (cons 10 '(0. 0. 0.)) (cons 11 '(4. 0. 0.)) (cons 12 '(4. 4. 0.)) (cons 13 '(0. 4. 0.)) ) ) (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 '(0.3 4.3 0.0)) (cons 70 0) (cons 1 "") (cons 2 "NUM") (cons 3 "Number: ") (cons 40 2.0) ) ) (entmake (list (cons 0 "ENDBLK") (cons 8 "0") ) ) ) ) (entmake (list (cons 0 "INSERT") (cons 2 name) (cons 10 pt) (cons 66 1) ) ) (entmake (list (cons 0 "ATTRIB") (cons 10 pt) (cons 1 "YourCounter") (cons 2 "NUM") (cons 40 2.0) (cons 70 0) ) ) (entmake (list (cons 0 "SEQEND") ) ) )
Lee Mac Programming
With Mathematics there is the possibility of perfect rigour, so why settle for less?
Just another Swamper


Registered forum members do not see this ad.
Thanks Lee,
I will try it.![]()
lost
Bookmarks