sadhu Posted August 27, 2010 Share Posted August 27, 2010 (edited) I get error while adding an attribute to a block using ENTMAKE "attdef". What am I doing wrong ? ;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 Edited August 27, 2010 by sadhu Quote Link to comment Share on other sites More sharing options...
Michaels Posted August 27, 2010 Share Posted August 27, 2010 It woks fine. Can you paste the error reply please ? Regards Quote Link to comment Share on other sites More sharing options...
David Bethel Posted August 27, 2010 Share Posted August 27, 2010 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 Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 27, 2010 Author Share Posted August 27, 2010 After the block is inserted in dwg I type "ATTEDIT" and select the block - there are no attributes to edit. Command: atteditSelect block reference: That block has no editable attributes. Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 27, 2010 Author Share Posted August 27, 2010 Thanks David - most of the code is from your post in the SWAMP. fixed entmake block : (cons 70 2) Still have to get the attributes working. Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 27, 2010 Author Share Posted August 27, 2010 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? (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) ) Quote Link to comment Share on other sites More sharing options...
lpseifert Posted August 27, 2010 Share Posted August 27, 2010 try this (entmake (list (cons 0 "ATTDEF") (cons 8 0) etc... (cons 3 [i]variable[/i]);variable should be string etc. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted August 27, 2010 Share Posted August 27, 2010 This should perhaps point you in the right direction: (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") ) ) ) Quote Link to comment Share on other sites More sharing options...
sadhu Posted August 30, 2010 Author Share Posted August 30, 2010 Thanks Lee, I will try it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.