Nikon Posted June 9 Posted June 9 Hello everyone. The code count the number of dimensions with the specified value and inserts the text into the drawing. Should also change the size color to red, but the color on the screen does not change, only in the properties. Please tell me how this can be fixed. (defun c:CountDimValueRed ( / doc ms val tol ss idx ent obj meas cnt inspt txtH txtObj) (vl-load-com) (setq val (getreal "Enter the required dimension value: ")) (if (null val) (progn (princ "The value is not entered.") (exit) ) ) ; tolerance 0.001 (setq tol 0.001) (setq ss (ssget '((0 . "DIMENSION")))) (setq cnt 0) (if ss (progn (setq idx 0 doc (vla-get-ActiveDocument (vlax-get-Acad-Object)) ms (vla-get-ModelSpace doc)) (while (< idx (sslength ss)) (setq ent (ssname ss idx) obj (vlax-ename->vla-object ent) meas (vla-get-Measurement obj)) ; accurate measurement (if (<= (abs (- meas val)) tol) (progn (setq cnt (1+ cnt)) ;; highlight in red (vla-put-Color obj 1) ) ) (setq idx (1+ idx)) ) ) (princ "Dimensions not found.") ) (setq txtH 250) (setq inspt (getpoint "Specify the quantity insertion point: ")) (if (null inspt) (princ "The point is not specified – the text has not been created.") (progn (setq txtObj (vla-AddText ms (strcat (itoa cnt) " pc.") (vlax-3d-point inspt) txtH)) (princ (strcat "Suitable dimension found: " (itoa cnt))) ) ) (princ) ) Quote
GLAVCVS Posted June 9 Posted June 9 Hi Nikon It's probably because the text color in the dimension style is set to "bylayer." 1 Quote
Steven P Posted June 9 Posted June 9 You might need to post a sample drawing, perhaps a before and after too This is what I got with a quick check: 1 Quote
GLAVCVS Posted June 9 Posted June 9 (edited) If you also want to change the lines, add (vla-put-ExtensionLineColor obj 1) (vla-put-DimensionLineColor obj 1) Edited June 9 by GLAVCVS 2 Quote
Nikon Posted June 10 Author Posted June 10 10 hours ago, GLAVCVS said: Try changing vla-put-color to vla-put-textColor Yes, this is how the text color changes, that's enough for me for now. Thank you! 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.