wimal Posted January 17, 2018 Share Posted January 17, 2018 Please I need a code to change the font type of attributes.Can some one help me. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 18, 2018 Share Posted January 18, 2018 Why can you not use BEDIT and edit the block attributes. Quote Link to comment Share on other sites More sharing options...
wimal Posted January 18, 2018 Author Share Posted January 18, 2018 Why can you not use BEDIT and edit the block attributes. Thanks a lot It works. Quote Link to comment Share on other sites More sharing options...
Steven P Posted January 18, 2018 Share Posted January 18, 2018 I forget where I got this from, but to do this via a lisp you could change this about: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Changes Block Text (Block Change Text) ;;Changes block text attributes ;;Note this changes the block itself and not just the attributes (defun c:BlkChTxt (/ InsLst TxtStyl cTxtstyl TxtWidth TxtHeight) (setq InsLst (entget (car (entsel "\nPlease choose a Block: ")))) (while (/= (cdr (assoc 0 InsLst)) "INSERT") (setq InsLst (entget (car (entsel "\nWrong, choose a Block: ")))) ) (setq TxtStyl "" cTxtstyl (getvar "TEXTSTYLE") ) (while (not (tblsearch "STYLE" TxtStyl)) (initget 1) (setq TxtStyl (getstring (strcat "\nNew style name for block text (default is current text style) <" cTxtstyl ">:" ) ) ) (if (= TxtStyl "") (setq TxtStyl cTxtstyl) ) ) (initget 4) (setq TxtWidth (getreal "\nNew text width for block text(0 for no change)<0>: " ) ) (if (= TxtWidth nil) (setq TxtWidth 0) ) (initget 4) (setq TxtHeight (getreal "\nNew text height for block text(0 for no change)<0>: " ) ) (if (= TxtHeight nil) (setq TxtHeight 0) ) ($ChBlkTxt InsLst TxtStyl TxtWidth TxtHeight) ) (defun $ChBlkTxt (InsLst TxtStyl TxtWidth TxtHeight / x edata) (setq x (cdr (assoc -2 (cdr (tblsearch "BLOCK" (cdr (assoc 2 InsLst))))) ) ) (while x (if x (progn (setq edata (entget x)) (if (or (= (cdr (assoc 0 edata)) "TEXT") (= (cdr (assoc 0 edata)) "MTEXT") (= (cdr (assoc 0 edata)) "ATTDEF") ) (progn (if (/= TxtWidth 0) (setq edata (entmod (subst (cons 41 TxtWidth) (assoc 41 edata) edata ) ) ) ) (if (/= TxtHeight 0) (setq edata (entmod (subst (cons 40 TxtHeight) (assoc 40 edata) edata ) ) ) ) (setq edata (entmod (subst (cons 7 TxtStyl) (assoc 7 edata) edata ) ) ) ) ) ) ) (setq x (entnext x)) ) (if (getvar "DIMASSOC") (command "_ATTSYNC" "N" (cdr (assoc 2 InsLst))) ($attsync (cdr (assoc 2 InsLst)) TxtWidth TxtHeight TxtStyl) ) (command "REGEN") (princ) ) (defun $attsync (BlkName TxtWidth TxtHeight TxtStyl / ss1 i sh) (defun @attsync (sh / edata) (if (= (cdr (assoc 0 (entget sh))) "ATTRIB") (progn (setq edata (entget sh)) (if (/= TxtWidth 0) (setq edata (entmod (subst (cons 41 TxtWidth) (assoc 41 edata) edata ) ) ) ) (if (/= TxtHeight 0) (setq edata (entmod (subst (cons 40 TxtHeight) (assoc 40 edata) edata ) ) ) ) (setq edata (entmod (subst (cons 7 TxtStyl) (assoc 7 edata) edata ) ) ) (entupd sh) ) ) ) (setq ss1 nil ss1 (ssget "X" (list '(0 . "INSERT") '(66 . 1) (cons 2 BlkName) ) ) ) (setq i 0) (repeat (sslength ss1) (setq sh (ssname ss1 i)) (while (/= (cdr (assoc 0 (entget sh))) "SEQEND") (@attsync sh) (setq sh (entnext sh) ) ) (setq i (1+ i) ) ) (princ) ) ;;------------------------------------------------------------;; ;; End of File ;; ;;------------------------------------------------------------;; Quote Link to comment Share on other sites More sharing options...
wimal Posted January 24, 2018 Author Share Posted January 24, 2018 I forget where I got this from, but to do this via a lisp you could change this about: ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;Changes Block Text (Block Change Text) ;;Changes block text attributes ;;Note this changes the block itself and not just the attributes (defun c:BlkChTxt (/ InsLst TxtStyl cTxtstyl TxtWidth TxtHeight) (setq InsLst (entget (car (entsel "\nPlease choose a Block: ")))) (while (/= (cdr (assoc 0 InsLst)) "INSERT") (setq InsLst (entget (car (entsel "\nWrong, choose a Block: ")))) ) (setq TxtStyl "" cTxtstyl (getvar "TEXTSTYLE") ) (while (not (tblsearch "STYLE" TxtStyl)) (initget 1) (setq TxtStyl (getstring (strcat "\nNew style name for block text (default is current text style) <" cTxtstyl ">:" ) ) ) (if (= TxtStyl "") (setq TxtStyl cTxtstyl) ) ) (initget 4) (setq TxtWidth (getreal "\nNew text width for block text(0 for no change)<0>: " ) ) (if (= TxtWidth nil) (setq TxtWidth 0) ) (initget 4) (setq TxtHeight (getreal "\nNew text height for block text(0 for no change)<0>: " ) ) (if (= TxtHeight nil) (setq TxtHeight 0) ) ($ChBlkTxt InsLst TxtStyl TxtWidth TxtHeight) ) (defun $ChBlkTxt (InsLst TxtStyl TxtWidth TxtHeight / x edata) (setq x (cdr (assoc -2 (cdr (tblsearch "BLOCK" (cdr (assoc 2 InsLst))))) ) ) (while x (if x (progn (setq edata (entget x)) (if (or (= (cdr (assoc 0 edata)) "TEXT") (= (cdr (assoc 0 edata)) "MTEXT") (= (cdr (assoc 0 edata)) "ATTDEF") ) (progn (if (/= TxtWidth 0) (setq edata (entmod (subst (cons 41 TxtWidth) (assoc 41 edata) edata ) ) ) ) (if (/= TxtHeight 0) (setq edata (entmod (subst (cons 40 TxtHeight) (assoc 40 edata) edata ) ) ) ) (setq edata (entmod (subst (cons 7 TxtStyl) (assoc 7 edata) edata ) ) ) ) ) ) ) (setq x (entnext x)) ) (if (getvar "DIMASSOC") (command "_ATTSYNC" "N" (cdr (assoc 2 InsLst))) ($attsync (cdr (assoc 2 InsLst)) TxtWidth TxtHeight TxtStyl) ) (command "REGEN") (princ) ) (defun $attsync (BlkName TxtWidth TxtHeight TxtStyl / ss1 i sh) (defun @attsync (sh / edata) (if (= (cdr (assoc 0 (entget sh))) "ATTRIB") (progn (setq edata (entget sh)) (if (/= TxtWidth 0) (setq edata (entmod (subst (cons 41 TxtWidth) (assoc 41 edata) edata ) ) ) ) (if (/= TxtHeight 0) (setq edata (entmod (subst (cons 40 TxtHeight) (assoc 40 edata) edata ) ) ) ) (setq edata (entmod (subst (cons 7 TxtStyl) (assoc 7 edata) edata ) ) ) (entupd sh) ) ) ) (setq ss1 nil ss1 (ssget "X" (list '(0 . "INSERT") '(66 . 1) (cons 2 BlkName) ) ) ) (setq i 0) (repeat (sslength ss1) (setq sh (ssname ss1 i)) (while (/= (cdr (assoc 0 (entget sh))) "SEQEND") (@attsync sh) (setq sh (entnext sh) ) ) (setq i (1+ i) ) ) (princ) ) ;;------------------------------------------------------------;; ;; End of File ;; ;;------------------------------------------------------------;; Thanks a lot mr steval P 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.