Nikon Posted April 22 Posted April 22 Using this line (mapcar 'print (tblsearch "dimstyle" "ISO-25")) for the text style "ISO-25", the command line outputs (147 . 1.2) this is the offset of the text from the dimension line. I want to change the text's offset from the dimension line - (147 . 0.425). But I can't do it, the change is not happening, how can I fix it, please... (defun c:Ch-DimTxtOff ( / ss entData) (setq ss (ssget '((0 . "DIMENSION")))) (if (and dim (= (cdr (assoc 0 (entget dim))) "DIMENSION")) (progn (setq entData (entget dim)) (setq entData (subst (cons 147 0.425) (assoc 147 entData) entData)) (entmod entData) ) ) (princ) ) DIMENSION-147.dwg Quote
hosneyalaa Posted April 22 Posted April 22 TRY https://help.autodesk.com/view/OARX/2022/ENU/?guid=GUID-E39FFEDE-FF81-4071-81E9-02D9C376D918 1 Quote
Nikon Posted April 22 Author Posted April 22 1 hour ago, hosneyalaa said: TRY It's hard for me to figure out what needs to be fixed in the code... Quote
GLAVCVS Posted April 22 Posted April 22 (edited) (defun c:Ch-DimTxtOff ( / ss entData n) (setq ss (ssget '((0 . "DIMENSION")))) (while (and (setq dim (ssname ss (setq n (if n (1+ n) 0)))) (= (cdr (assoc 0 (entget dim))) "DIMENSION")) (progn (setq entData (entget dim)) (setq entData (subst (cons 147 0.425) (assoc 147 entData) entData)) (entmod entData) ) ) (princ) ) I just added the code to define 'dim' I haven't checked anything else. Edited April 22 by GLAVCVS 1 Quote
Nikon Posted April 22 Author Posted April 22 16 minutes ago, GLAVCVS said: I just added the code to define 'dim' I haven't checked anything else. It doesn't work for some reason... Quote
GLAVCVS Posted April 22 Posted April 22 Okay I guess it was also necessary to update from 'if' to 'while' I edited that a few minutes ago, too. 1 Quote
Nikon Posted April 22 Author Posted April 22 4 minutes ago, GLAVCVS said: Okay I guess it was also necessary to update from 'if' to 'while' I edited that a few minutes ago, too. And it didn't solve the problem... Quote
GLAVCVS Posted April 22 Posted April 22 The problem is that there's no DXF code 147 to control the text gap. That's controlled directly from the coordinate associated with code 11. From VLA, you can control the gap using the "TextGap" property. 1 Quote
GLAVCVS Posted April 22 Posted April 22 You just need to replace the entire block under 'progn' with (vlax-put-property (vlax-ename->vla-object dim) "TextGap" 0.425) 1 Quote
GLAVCVS Posted April 22 Posted April 22 Like This (defun c:Ch-DimTxtOff ( / ss entData n) (setq ss (ssget '((0 . "DIMENSION")))) (while (and (setq dim (ssname ss (setq n (if n (1+ n) 0)))) (= (cdr (assoc 0 (entget dim))) "DIMENSION")) (vlax-put-property (vlax-ename->vla-object dim) "TextGap" 0.425) ) (princ) ) 1 Quote
Nikon Posted April 22 Author Posted April 22 21 minutes ago, GLAVCVS said: Like This (defun c:Ch-DimTxtOff ( / ss entData n) (setq ss (ssget '((0 . "DIMENSION")))) (while (and (setq dim (ssname ss (setq n (if n (1+ n) 0)))) (= (cdr (assoc 0 (entget dim))) "DIMENSION")) (vlax-put-property (vlax-ename->vla-object dim) "TextGap" 0.425) ) (princ) ) Now this code works very well. Thank you very much! 1 Quote
Nikon Posted April 22 Author Posted April 22 (edited) You can also change the text colors to red. There may be errors in the code, but the code works... ;; Added a text color change to red for resized text... ;; Thanks GLAVCVS 22.04.2025 ;; https://www.cadtutor.net/forum/topic/97558-change-the-texts-offset-from-the-dimension-line/ (defun c:Ch-DimTxtOffCol ( / ss entData n oldGap) (setq ss (ssget '((0 . "DIMENSION")))) (while (and (setq dim (ssname ss (setq n (if n (1+ n) 0)))) (= (cdr (assoc 0 (entget dim))) "DIMENSION")) (setq entData (entget dim)) (setq oldGap (cdr (assoc 0 entData))) (if (not (equal oldGap 0.425)) (progn (vlax-put-property (vlax-ename->vla-object dim) "TextGap" 0.425) (vlax-put-property (vlax-ename->vla-object dim) "TextColor" 1) ) (vlax-put-property (vlax-ename->vla-object dim) "TextGap" 0.425) ) ) (princ) ) Edited April 22 by Nikon Quote
GLAVCVS Posted April 22 Posted April 22 3 hours ago, Nikon said: You can also change the text colors to red. There may be errors in the code, but the code works... ;; Added a text color change to red for resized text... ;; Thanks GLAVCVS 22.04.2025 ;; https://www.cadtutor.net/forum/topic/97558-change-the-texts-offset-from-the-dimension-line/ (defun c:Ch-DimTxtOffCol ( / ss entData n oldGap) (setq ss (ssget '((0 . "DIMENSION")))) (while (and (setq dim (ssname ss (setq n (if n (1+ n) 0)))) (= (cdr (assoc 0 (entget dim))) "DIMENSION")) (setq entData (entget dim)) (setq oldGap (cdr (assoc 0 entData))) (if (not (equal oldGap 0.425)) (progn (vlax-put-property (vlax-ename->vla-object dim) "TextGap" 0.425) (vlax-put-property (vlax-ename->vla-object dim) "TextColor" 1) ) (vlax-put-property (vlax-ename->vla-object dim) "TextGap" 0.425) ) ) (princ) ) If 'oldGap' is '(cdr (assoc 0 entData)))' then it will always be different from 0.425 because oldGap= "DIMENSION" If you want to get the current value of "TextGap" from the object contained in 'dim' you should call '(vlax-get-property (vlax-ename->vla-object dim) "TextGap")' But not '(cdr (assoc 0 entData))' 1 Quote
BIGAL Posted April 23 Posted April 23 Just a comment in this situation these two do the same task. (vlax-put-property (vlax-put Another "Textgap" 'Textgap 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.