LIU Posted April 14 Posted April 14 hi , which should be done first ? first create block then add attribute to it. ? OR create attribute first then include it in block ? thanks Quote
CyberAngel Posted April 14 Posted April 14 As far as I know, it's okay to do it either way. The only difference is, when you add an attribute to an existing block, you'll need to run ATTSYNC or BATTMAN to update the block definition. 1 Quote
BIGAL Posted April 14 Posted April 14 If using lisp to make the block rather than BEDIT, this example may be helpful. ; bubble pt num ; BY ALAN H AUG 2014 (defun make_circle () (entmake (list (cons 0 "CIRCLE") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 40 3.25) ; rad (cons 210 (list 0 0 1)) (cons 62 256) (cons 39 0) (cons 6 "BYLAYER") ) ) ) ; DEFUN (defun make_sq () (setq vertexList (list (list -3.25 -3.25 0.) (list 3.25 -3.25 0.) (list 3.25 3.25 0.) (list -3.25 3.25 0.) )) (entmake (append (list '(0 . "LWPOLYLINE") '(100 . "AcDbEntity") '(100 . "AcDbPolyline") (cons 90 (length vertexList)) (cons 70 1) ; 1 closed : 0 open (cons 8 "0") (cons 38 0.0) (cons 210 (list 0.0 0.0 1.0)) ) (mapcar '(lambda (pt) (cons 10 pt)) vertexList) ) ) ) ; defun (defun Make_bubble ( ) (entmake (list (cons 0 "BLOCK") (cons 2 Blkname) (cons 70 2) (cons 10 (list 0 0 0)) (CONS 8 "0") )) (if (= rb1 "1") (make_circle) (make_sq) ) (entmake (list (cons 0 "ATTDEF") (cons 8 "0") (cons 10 (list 0 0 0)) (cons 1 "1") ; default value (cons 2 blkname) ; nblock name (cons 3 "Ptnum") ; tag name (cons 6 "BYLAYER") (cons 7 "STANDARD") ;text style (cons 8 "0") ; layer (cons 11 (list 0.0 0.0 0.0)) ; text insert pt (cons 39 0) (cons 40 3.5) ; text height (cons 41 1) ; X scale (cons 50 0) ; Text rotation (cons 51 0) ; Oblique angle (cons 62 256) ; by layer color (cons 70 0) (cons 71 0) ;Text gen flag (cons 72 1) ; Text Justify hor 1 center (cons 73 0) ; field length (cons 74 2) ; Text Justify ver 2 center (cons 210 (list 0 0 1)) )) (entmake (list (cons 0 "ENDBLK"))) (princ) ) (defun C:bub (/ ptnum ptnumb pt pt2 oldsnap chrnum sc curspace fo fname) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line "Ptnumbub : dialog {" fo) (write-line " label = \"Pt num bubble\" ;" fo) (write-line " : row {" fo) (write-line " : boxed_radio_column {" fo) (write-line " label = \"Circle or square \" ;" fo) (write-line " width = 28 ;" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb1\" ;" fo) (write-line "label = \"Circle\"; " fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " : radio_button {" fo) (write-line "key = \"Rb2\" ;" fo) (write-line "label = \"Square\" ;" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " }" fo) (write-line ": boxed_column {" fo) (write-line ": edit_box {" fo) (write-line " key = \"key1\" ;" fo) (write-line " label = \"eg 1 a A \" ;" fo) (write-line " edit_width = 5;" fo) (write-line " edit_limit = 4;" fo) (write-line " is_enabled = true ;" fo) (write-line " allow_accept=true ;" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line ": edit_box {" fo) (write-line " key = \"key2\" ;" fo) (write-line " label = \"Scale \" ;" fo) (write-line " edit_width = 5;" fo) (write-line " edit_limit = 4;" fo) (write-line " is_enabled = true ;" fo) (write-line " allow_accept=true ;" fo) (write-line " }" fo) (write-line " }" fo) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line " ok_only;" fo) (write-line " }" fo) (close fo) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "Ptnumbub" dcl_id)) (exit) ) (set_tile "Rb1" "1") (set_tile "key1" "1") (set_tile "key2" "100") (action_tile "accept" "(setq rb1 (get_tile \"Rb1\"))(setq rb2 (get_tile \"Rb2\")) (setq ptnum (get_tile \"key1\")) (setq sc (atof (get_tile \"key2\")))(done_dialog)") (action_tile "cancel" "(setq ah:cancel \"Yes\")(done_dialog)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (if (= rb1 "1") (setq blkname "SETOUT_POINT_NO") (setq blkname "SETOUT_POINT_NOSQ") ) (setq att (getvar 'attdia)) (setvar 'attdia 0) (if (tblsearch "BLOCK" blkname) (PRINC "FOUND") ; block exists (Make_bubble) ) (if (or (/= 1 (getvar 'cvport))(= "Model" (getvar 'ctab))) (setq sc (/ sc 1000.0 )) (setq sc 1.0) ) (setq oldsnap (getvar "osmode")) (setvar "textstyle" "standard") (setq chrnum (ascii (substr ptnum 1 1))) ; 1st character is number (if (< chrnum 58) (setq ptnumb (atof ptnum)) ;convert back to a number ) (while (setq pt (getpoint "\Pick point or Enter to exit")) (setq pt2 (polar pt (/ pi 2.0) 3.25)) (setvar "osmode" 0) (if (< chrnum 58) (progn (command "-insert" blkname pt sc "" 0 (rtos ptnumb 2 0) ) (setq ptnumb (+ ptnumb 1)) ) (progn (command "-insert" blkname pt sc "" 0 (chr chrnum) ) (setq chrnum (+ chrnum 1)) ) ) ; (command "move" "L" "" pt pt2) ; (setvar "osmode" 1) ) (setvar "osmode" oldsnap) (princ) ) ;;;;;; ; program starts here (alert "Type Bub to repeat\n\nYou can do alpha's or numbers\n \nSquare or circles") (C:BUB) Quote
LIU Posted April 15 Author Posted April 15 On 4/14/2025 at 5:08 PM, CyberAngel said: As far as I know, it's okay to do it either way. The only difference is, when you add an attribute to an existing block, you'll need to run ATTSYNC or BATTMAN to update the block definition. THANKS Quote
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.