Nikon Posted 19 hours ago Posted 19 hours ago (edited) There are several fields with 1 decimal place. Is there a way to convert selected fields with 1 decimal place into fields with 2 decimal places without losing the connection of fields with objects? The field is 1 decimal place %<\AcExpr (3.1416*%<\_FldPtr 1317270971888>%^2/4*0.0785*%<\_FldPtr 1317270971632>%*%<\_FldPtr 1317270971472>%/10000) \f "%lu2%pr1">% The field is 2 decimal places %<\AcExpr (3.1416*%<\_FldPtr 1317157078864>%^2/4*0.0785*%<\_FldPtr 1317157078096>%/10000) \f "%lu2%pr2">% fields.dwg Edited 25 minutes ago by Nikon Quote
Steven P Posted 15 hours ago Posted 15 hours ago "pr2" is precision - here 2 places, "pr1" at the end of the first expression is 1 decimal place 1 Quote
Nikon Posted 7 hours ago Author Posted 7 hours ago (edited) 15 hours ago, Steven P said: "pr2" is precision - here 2 places, "pr1" at the end of the first expression is 1 decimal place I have dozens of fields that need to be changed the precision. It will take a long time to edit each field... Edited 19 minutes ago by Nikon Quote
BIGAL Posted 5 hours ago Posted 5 hours ago (edited) If you can identify where the field strings are then you could update them, you can look for say "AcExpr" in the string then replace pr1. Maybe use Bedit and Attsync to update blocks. Similar for Mtext. Â So where are they ? Provide a sample dwg, You should be able to do something by now look at (Vlax-get obj 'textstring) Edited 5 hours ago by BIGAL Quote
Nikon Posted 5 hours ago Author Posted 5 hours ago 23 minutes ago, BIGAL said: So where are they ? Provide a sample dwg, The fields are in the text, not in the block. The sample fields.dwg is attached in the first post. The problem is that you need to change the accuracy of several fields at the same time. Quote
Tsuky Posted 2 hours ago Posted 2 hours ago You can try this. (vl-load-com) (defun c:change_prec ( / ss AcDoc Space n ename Obj value_string nbs tmp_nbs) (princ "\nSelect MText.") (while (null (setq ss (ssget (list '(0 . "*TEXT") (cons 67 (if (eq (getvar "CVPORT") 1) 1 0)) (cons 410 (if (eq (getvar "CVPORT") 1) (getvar "CTAB") "Model")) ) ) ) ) (princ "\nAren't MText or Text!") ) (setq AcDoc (vla-get-ActiveDocument (vlax-get-acad-object)) Space (if (= 1 (getvar "CVPORT")) (vla-get-PaperSpace AcDoc) (vla-get-ModelSpace AcDoc) ) ) (vla-startundomark AcDoc) (repeat (setq n (sslength ss)) (setq ename (ssname ss (setq n (1- n))) Obj (vlax-ename->vla-object ename) ) (setq value_string (vla-FieldCode Obj) nbs 0) (cond ((eq (substr (vla-FieldCode Obj) 1 3) "%<\\") (while nbs (if (setq nbs (vl-string-search "%pr2" value_string (setq tmp_nbs nbs))) (setq value_string (vl-string-subst "%pr1" "%pr2" value_string tmp_nbs) nbs (1+ nbs) ) ) ) (vlax-put Obj 'TextString value_string) ) ) ) (vla-endundomark AcDoc) (prin1) ) Â 2 Quote
Nikon Posted 1 hour ago Author Posted 1 hour ago 39 minutes ago, Tsuky said: You can try this. (vl-load-com) (defun c:change_prec @Tsuky thank you very much, your code changes the precision of the fields from 2 to 1. I replaced 2 lines in the code to change the precision from 1 to 2. (if (setq nbs (vl-string-search "%pr2" value_string (setq tmp_nbs nbs)))       (setq        value_string (vl-string-subst "%pr1" "%pr2" value_string tmp_nbs) * * * *  * * * *  * * * *  * * * *  (if (setq nbs (vl-string-search "%pr1" value_string (setq tmp_nbs nbs)))       (setq        value_string (vl-string-subst "%pr2" "%pr1" value_string tmp_nbs) * * * *  * * * *  * * * *  * * * * You've been very helpful!   1 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.