Jump to content

Recommended Posts

Posted

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)
)

 

Posted

Hi Nikon
It's probably because the text color in the dimension style is set to "bylayer."

  • Agree 1
Posted

You might need to post a sample drawing, perhaps a before and after too

 

This is what I got with a quick check:

 

image.png.b94f177383efb232c961e2f8462e3d22.png

  • Thanks 1
Posted

Try changing vla-put-color  to  vla-put-textColor

  • Like 1
Posted (edited)

If you also want to change the lines, add
(vla-put-ExtensionLineColor obj 1)

(vla-put-DimensionLineColor obj 1)

Edited by GLAVCVS
  • Like 2
Posted
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!

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...