Nikon Posted April 6 Posted April 6 (edited) Hello everyone! How can I change the code so that the color of the dimensional text changes only for sizes whose text has been changed manually? ; changes the color of the dimensional text by 1 (defun C:ChDimTxtCol1 (/ int sel ent obj DimTextColor) (vl-load-com) (setq DimTextColor 1) (and (setq int -1 sel (ssget '((0 . "*DIMENSION"))) ) (while (setq int (1+ int) ent (ssname sel int)) (setq obj (vlax-ename->vla-object ent)) (vla-put-TextColor obj DimTextColor) ) ) (princ) ) Edited April 6 by Nikon Quote
GLAVCVS Posted April 6 Posted April 6 On 4/6/2025 at 4:34 PM, Nikon said: Hello everyone! How can I change the code so that the color of the dimensional text changes only for sizes whose text has been changed manually? ; changes the color of the dimensional text by 1 (defun C:ChDimTxtCol1 (/ int sel ent obj DimTextColor) (vl-load-com) (setq DimTextColor 1) (and (setq int -1 sel (ssget '((0 . "*DIMENSION"))) ) (while (setq int (1+ int) ent (ssname sel int)) (setq obj (vlax-ename->vla-object ent)) (vla-put-TextColor obj DimTextColor) ) ) (princ) ) Expand You should simply condition the color change on the value of the 'TextHeight' property being different from '(getvar 'DIMTXT) Quote
GLAVCVS Posted April 6 Posted April 6 (defun C:ChDimTxtCol1 (/ int sel ent obj DimTextColor) (vl-load-com) (setq DimTextColor 1) (and (setq int -1 sel (ssget '((0 . "*DIMENSION"))) ) (while (setq int (1+ int) ent (ssname sel int)) (setq obj (vlax-ename->vla-object ent)) (if (/= (vla-get-textHeight obj) (getvar'DIMTXT)) (vla-put-TextColor obj DimTextColor)) ) ) (princ) ) 1 Quote
Nikon Posted April 6 Author Posted April 6 On 4/6/2025 at 5:18 PM, GLAVCVS said: (defun C:ChDimTxtCol1 (/ int sel ent obj DimTextColor) (vl-load-com) (setq DimTextColor 1) (and (setq int -1 sel (ssget '((0 . "*DIMENSION"))) ) (while (setq int (1+ int) ent (ssname sel int)) (setq obj (vlax-ename->vla-object ent)) (if (/= (vla-get-textHeight obj) (getvar'DIMTXT)) (vla-put-TextColor obj DimTextColor)) ) ) (princ) Expand thanks, but the text color hasn't changed... Quote
Tharwat Posted April 6 Posted April 6 WHY DID YOU REMOVE MY PROGRAM'S HEADER FROM THE CODES ? REMOVE MY CODES FROM YOUR THREAD Quote
Nikon Posted April 6 Author Posted April 6 On 4/6/2025 at 5:39 PM, Tharwat said: WHY DID YOU REMOVE MY PROGRAM'S HEADER FROM THE CODES ? REMOVE MY CODES FROM YOUR THREAD Expand I do not know your code, and I did not delete anything... Quote
GLAVCVS Posted April 6 Posted April 6 Is this an inherited drawing or did you create it yourself? If the DIMENSION objects were created with the same height as the DIMTXT value, and your modifications were made to the text from there, it should work. Quote
Nikon Posted April 6 Author Posted April 6 (edited) On 4/6/2025 at 6:11 PM, GLAVCVS said: Is this an inherited drawing or did you create it yourself? If the DIMENSION objects were created with the same height as the DIMTXT value, and your modifications were made to the text from there, it should work. Expand Why are you talking about the height of the text, I'm interested in the color. Sometimes there are dimensions in the drawings, the text of which has been changed, in order to find them, I want to use a color change. Edited April 6 by Nikon Quote
GLAVCVS Posted April 6 Posted April 6 (edited) Then I'm afraid I misunderstood. I thought you wanted to change the color of DIMENSION texts whose sizes have been changed after they were created. Did I misunderstand then? Edited April 6 by GLAVCVS Quote
Nikon Posted April 6 Author Posted April 6 (edited) On 4/6/2025 at 6:25 PM, GLAVCVS said: Then I'm afraid I misunderstood. I thought you wanted to change the color of DIMENSION texts whose sizes have been changed after they were created. misunderstand then? Expand Yes, I have such intentions - change the color of DIMENSION texts whose sizes have been changed after they were created.. Edited April 6 by Nikon Quote
Tharwat Posted Sunday at 07:24 PM Posted Sunday at 07:24 PM On 4/6/2025 at 5:53 PM, Nikon said: I do not know your code, and I did not delete anything... Expand Then where did you get the codes from ? Quote
Danielm103 Posted Sunday at 10:31 PM Posted Sunday at 10:31 PM add xdata to create a dimstyle override , in python it would be xd = [(1001, "ACAD"), (1000, "DSTYLE"), (1002, "{"), (1070, 178), (1070, 1), (1002, "}")] # add dim override @command def doit2(): ps, id, _ = Ed.Editor.entSel("\nSelect:", Db.Dimension.desc()) if ps != Ed.PromptStatus.eOk: return dim = Db.Dimension(id, Db.OpenMode.kForWrite) # todo check if there's aready a dimstyle override # 178 = dimclrt # 1 is red xd = [(1001, "ACAD"), (1000, "DSTYLE"), (1002, "{"), (1070, 178), (1070, 1), (1002, "}")] dim.setXData(xd) 1 Quote
BIGAL Posted Monday at 12:16 AM Posted Monday at 12:16 AM You can check has text been overidden. ; TextOverride = "<> ABC" ABC added ; TextOverride = "" this has not been cahnged (vlax-get obj 'textoveride) 1 Quote
aridzv Posted Monday at 09:01 AM Posted Monday at 09:01 AM (edited) see below: (defun c:ChDimTxtCol1 (/ i sel ent obj) (vl-load-com) (setq i 0) ;(setq DimTextColor 1) (if (setq sel (ssget '((0 . "*DIMENSION")))) (progn (repeat (sslength sel) (setq ent (ssname sel i)) (setq obj (vlax-ename->vla-object ent)) (if (/= (vlax-get obj 'textoverride) "") (vlax-put-property obj 'TextColor 1) ;(vlax-put-property obj 'TextColor DimTextColor) );if (setq i (+ i 1)) );end repeat );end progn (alert "No Dimensions selected") );end if sel (princ) );defun *EDIT: I removed the "DimTextColor" varaible because it is redandet and set the textcolor directly to 1 this way: (vlax-put-property obj 'TextColor 1) Edited Monday at 09:55 AM by aridzv 1 Quote
GLAVCVS Posted Monday at 09:02 AM Posted Monday at 09:02 AM I think the only way to know what's going on is if you attach an example drawing. Quote
Nikon Posted Monday at 09:17 AM Author Posted Monday at 09:17 AM On 4/7/2025 at 9:01 AM, aridzv said: see below: (defun c:ChDimTxtCol1 (/ i DimTextColor sel ent obj) (vl-load-com) (setq i 0) (setq DimTextColor 1) (if (setq sel (ssget '((0 . "*DIMENSION")))) (progn (repeat (sslength sel) (setq ent (ssname sel i)) (setq obj (vlax-ename->vla-object ent)) (if (/= (vlax-get obj 'textoverride) "") (vlax-put-property obj 'TextColor DimTextColor) );if (setq i (+ i 1)) );end repeat );end progn (alert "No Dimensions selected") );end if sel (princ) );defun Expand @aridzv I am very grateful to you! That's what I need! Good luck! 1 Quote
GLAVCVS Posted Monday at 09:17 AM Posted Monday at 09:17 AM @Nikon As for Tharwat's claim, I think he's pretty sure that this code is his. Perhaps this code reached you indirectly, and you didn't know who its author was. Therefore, it might be smart to mention @Tharwat somewhere. Quote
Nikon Posted Monday at 09:19 AM Author Posted Monday at 09:19 AM On 4/7/2025 at 9:02 AM, GLAVCVS said: I think the only way to know what's going on is if you attach an example drawing. Expand @GLAVCVS Thank you for participating! Quote
Steven P Posted Monday at 10:51 AM Posted Monday at 10:51 AM On 4/7/2025 at 9:17 AM, GLAVCVS said: @Nikon As for Tharwat's claim, I think he's pretty sure that this code is his. Perhaps this code reached you indirectly, and you didn't know who its author was. Therefore, it might be smart to mention @Tharwat somewhere. Expand however... quite aggressive asking for the credit here today. Nicer ways to go "Hey, this was originally my code, can you credit me" and perhaps if possible the link to the original code to help the OP out. Code gets shared, the links and credits lost. Always good practice to add links to the sources and credits in case there are thing you want to go back and understand more from any discussions. Having said that though, upload code, you have no control of it's use and I am not sure I'd want credited with a base code that is mine and then heavily modified, or just a snippet of my code included in something larger without me doing checks and testing. 5 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.