Truski Posted May 10, 2021 Posted May 10, 2021 Hello everyone, I wanted to know if there is any way to change a diesel expression of a field that appears in multiple files without having to change it by hand in each block that appears. The diesel expression is this: $(substr,$(getvar,dwgname),1,7) What I want is to be able to change the number of characters that I take from the file name, in this case change the number 7. Thank you very much. Quote
steven-g Posted May 10, 2021 Posted May 10, 2021 Unfortunately not in LT, unless of course it is just multiple copies of the same block. You stiil need to open each individual drawing and each block definition that contains that field in each of those drawings. Of course depending on you setup you could just try updating the blocks in one drawing and then inserting this new block definition(s) into each drawing and pick the 'update block definition' each time and see if that works (attributes can be difficult). Quote
Truski Posted May 10, 2021 Author Posted May 10, 2021 I imagined that in LT you couldn't. In AutoCAD what would it be like? Quote
steven-g Posted May 10, 2021 Posted May 10, 2021 No idea I only use LT. I would imagine that someone could automate the process using Lisp, after all thats why the full version costs 4 times more than LT. Quote
Truski Posted May 10, 2021 Author Posted May 10, 2021 I hope someone can help me. Thank you anyway. Quote
steven-g Posted May 10, 2021 Posted May 10, 2021 Your profile says you are using LT ? Do you have access to full Autocad and Lisp? Quote
tombu Posted May 10, 2021 Posted May 10, 2021 For me the path and drawing name are part of the title block (not an attribute) as it didn't seem to be anything that would ever need to be modified. If I wanted to change that I'd modify it and update the title block for each of those drawings. How you need to modify it is up to where it is. Quote
Truski Posted May 10, 2021 Author Posted May 10, 2021 Is there a way to automate the change using Lisp? That it will ask you how many characters you want it to take from the beginning of the file name or to show up to a certain character that you tell it. Quote
tombu Posted May 10, 2021 Posted May 10, 2021 Change what? Is it a portion of a random text, mtext, or attribute? Is it part of a title block or is it an editable attribute of the title block? Without an attached drawing or a link to one or a very specific description of what you're looking for nobody's going to be able to help you. Quote
Truski Posted May 10, 2021 Author Posted May 10, 2021 (edited) It is an editable attribute of the title block The diesel expression is this: $(substr,$(getvar,dwgname),1,7) I need to change the number of characters that it takes from the beginning of the file name (it is the number of the plane) Edited May 10, 2021 by Truski Quote
tombu Posted May 10, 2021 Posted May 10, 2021 Guessing there's more than one attribute so lisp would need the block name and attribute tag name to start with. Just no way to modify an object without a way to identify it first. Going to need what method you want to create a selection of drawings to be modified next. Just current directory? Going home now but if you provide enough information someone here may be willing to help you. Quote
Lee Mac Posted May 10, 2021 Posted May 10, 2021 Consider the following example - the selection could be automated if the target block/attribute tag is known, or alternatively, it could search every block attribute for the target field expression and perform a replacement: (defun c:test ( / e n x ) (setq n "$(substr,$(getvar,dwgname),1,3)") (while (progn (setvar 'errno 0) (setq e (car (nentsel "\nSelect field: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null e) nil ) ( (not (wcmatch (cdr (assoc 0 (setq x (entget e)))) "TEXT,MTEXT,ATTRIB,MULTILEADER,*DIMENSION")) (princ "\nInvalid object selected.") ) ( (not (and (setq x (cdr (assoc 360 x))) (setq x (dictsearch x "ACAD_FIELD")) (setq x (dictsearch (cdr (assoc -1 x)) "TEXT")) (setq x (cdr (assoc 360 x))) (setq x (entget x)) (= "FIELD" (cdr (assoc 0 x))) (= "AcDiesel" (cdr (assoc 1 x))) ) ) (princ "\nThe selected object does not contain a DIESEL field expression.") ) ( (entmod (subst (cons 2 (strcat "\\AcDiesel " n)) (assoc 2 x) (subst (cons 1 n) (assoc 1 (member (assoc 6 x) x)) x) ) ) (command "_.regenall") ) ) ) ) (princ) ) 1 Quote
Truski Posted May 11, 2021 Author Posted May 11, 2021 Hello, here is the block in question ... 2.5.1.3.dwg Quote
Truski Posted May 11, 2021 Author Posted May 11, 2021 Hi @Lee Mac, I have tested your lisp and it works great. I want to automate the change in many plans and layouts. Can it be done without having to select the block? Thank you. 9 hours ago, Lee Mac said: Consider the following example - the selection could be automated if the target block/attribute tag is known, or alternatively, it could search every block attribute for the target field expression and perform a replacement: (defun c:test ( / e n x ) (setq n "$(substr,$(getvar,dwgname),1,3)") (while (progn (setvar 'errno 0) (setq e (car (nentsel "\nSelect field: "))) (cond ( (= 7 (getvar 'errno)) (princ "\nMissed, try again.") ) ( (null e) nil ) ( (not (wcmatch (cdr (assoc 0 (setq x (entget e)))) "TEXT,MTEXT,ATTRIB,MULTILEADER,*DIMENSION")) (princ "\nInvalid object selected.") ) ( (not (and (setq x (cdr (assoc 360 x))) (setq x (dictsearch x "ACAD_FIELD")) (setq x (dictsearch (cdr (assoc -1 x)) "TEXT")) (setq x (cdr (assoc 360 x))) (setq x (entget x)) (= "FIELD" (cdr (assoc 0 x))) (= "AcDiesel" (cdr (assoc 1 x))) ) ) (princ "\nThe selected object does not contain a DIESEL field expression.") ) ( (entmod (subst (cons 2 (strcat "\\AcDiesel " n)) (assoc 2 x) (subst (cons 1 n) (assoc 1 (member (assoc 6 x) x)) x) ) ) (command "_.regenall") ) ) ) ) (princ) ) 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.