Jump to content

Recommended Posts

Posted (edited)

always I get a message "no function definition: VLA-PUT-BACKGROUNDFILLCOLOR" , but it works, what is the mistake ?

 

 

(defun c:ApplyMaskGreen (/ ss i ent txtObj)
  ;; Prompt the user to select text objects
  (setq ss (ssget '((0 . "TEXT,MTEXT"))))
  
  ;; Check if any text objects were selected
  (if ss
    (progn
      ;; Loop through each selected text object
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i))
        (setq txtObj (vlax-ename->vla-object ent))
        
        ;; Apply background mask properties
        (if (vlax-property-available-p txtObj 'BackgroundFill)
          (progn
            (vla-put-BackgroundFill txtObj :vlax-true)
            (vla-put-BackgroundFillColor txtObj 3)  ;; Green color (ACI color index 3)
            (vla-put-BackgroundFillGapFactor txtObj 1.0)  ;; Border offset factor = 1
            (vla-put-BackgroundFillUseDrawingBackgroundColor txtObj :vlax-false)  ;; Uncheck "Use drawing background color"
          )
          (princ "\nBackgroundFill property not supported for this object.")
        )
        
        ;; Increment counter
        (setq i (1+ i))
      )
      (princ "\nBackground mask applied to selected text.")
    )
    (princ "\nNo text objects selected.")
  )
  (princ)
)

 

Edited by SLW210
Added Code Tags!
Posted

Please use Code Tags in the future. (<> in the editor toolbar)

Posted

In these cases always write '(vl-load-com)' at the beginning, just in case.
I don't know all the methods available in Visual Lisp by heart, and even less so without a PC in front of me. But it's possible that the method isn't implemented.
Try setting the property using

(vlax-put-property txObj "BackGroundFillColor" 3)

 

Posted

TEXT entities don't have BackgroundFill property, but MTEXT have...

Here is my slight intervention to your code :

 

(defun c:ApplyMaskGreen ( / ss i ent txtObj )
  ;; Prompt the user to select text objects
  (setq ss (ssget '((0 . "TEXT,MTEXT"))))
  
  ;; Check if any text objects were selected
  (if ss
    (progn
      ;; Loop through each selected text object
      (setq i 0)
      (while (< i (sslength ss))
        (setq ent (ssname ss i))
        (setq txtObj (vlax-ename->vla-object ent))
        
        ;; Apply background mask properties
        (if (vlax-property-available-p txtObj 'BackgroundFill)
          (progn
            (vla-put-BackgroundFill txtObj :vlax-true)
            (setpropertyvalue ent "BackgroundFillColor" "3")
            ;; (vla-put-BackgroundFillColor txtObj 3)  ;; Green color (ACI color index 3)
            ;; (vla-put-BackgroundFillGapFactor txtObj 1.0)  ;; Border offset factor = 1
            ;; (vla-put-BackgroundFillUseDrawingBackgroundColor txtObj :vlax-false)  ;; Uncheck "Use drawing background color"
          )
          (princ "\nBackgroundFill property not supported for this object.")
        )
        
        ;; Increment counter
        (setq i (1+ i))
      )
      (princ "\nBackground mask applied to selected text.")
    )
    (princ "\nNo text objects selected.")
  )
  (princ)
)

 

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