Jump to content

Change text color for multileader


broncos15

Recommended Posts

So I am trying to have the ability to change the text color of mulitleaders from bylayer to red (it is part of a QC routine). After looking through all the properties, the only way I can figure out how to do it is by doing a workaround where I basically just copy and paste the text back into the multileader.

(vla-put-TextString obj (strcat "{\\C" (itoa txtcol) ";" txtstring "}"))

The issue is that this will override if there are any fields within the text. Is there some other workaround that I am not thinking of?

Link to comment
Share on other sites

You could change the TextColor property of the corresponding MLeader Style, e.g.:

(defun c:test ( / aci col sel sty )
   (if (and (setq sel (ssget "_+.:E:S" '((0 . "MULTILEADER")))) (setq aci (acad_colordlg 1 nil)))
       (progn
           (setq sty
               (vla-item
                   (vla-item
                       (vla-get-dictionaries
                           (vla-get-activedocument
                               (vlax-get-acad-object)
                           )
                       )
                       "acad_mleaderstyle"
                   )
                   (vla-get-stylename (vlax-ename->vla-object (ssname sel 0)))
               )
               col (vla-get-textcolor sty)
           )
           (vla-put-colorindex col aci)
           (vla-put-textcolor  sty col)
       )
   )
   (princ)
)
(vl-load-com) (princ)

Note that this will affect all MLeaders referencing the Style however.

Link to comment
Share on other sites

Lee thank you so much for the help! I thought about changing the style, but the problem is that the work flow goes, a person manually checks an mtext or multileader, corrects anything that is incorrect, then turns the text red to indicate that it is correct and has been checked. Then after everything has been checked, I place them back on the bylayer. It isn't a huge deal, I might just add a check into the command so that the user can't select objects that have fields in it.

Link to comment
Share on other sites

here a one i used from afralisp.com

 

 

(defun c:colorchange ( / ssg)
(setq ssg (ssget))
(chc ssg 1) ;;; 1 for red color
)

(defun chc (sset color)
;load the visual lisp extensions
(vl-load-com)

;check for selection

   ;set up the counter
   (setq ctr 0)

   ;count the number of entities and loop
   (repeat (sslength sset)

       ;extract the entity name
       (setq item (ssname sset ctr))

       ;convert to vl object
       (setq item (vlax-ename->vla-object item))

         ;check if the entity has a color property
       ;and it can be updated
       (setq check (vlax-property-available-p item "Color" T))

       ;if it can
       (if check

           ;change it's color
           (vlax-put-property item 'Color color)

       );if

       ;increment the counter
       (setq ctr (1+ ctr))

   );repeat


);defun

Link to comment
Share on other sites

  • 11 months later...

I'm trying to set the text color of the mleaderstyle using the following with no luck... but it seems you may be able to help me...

 

 

(progn

(setq *doc* (vla-get-activedocument (vlax-get-acad-object)))

(setq mldrdict (vla-item (vla-get-dictionaries *doc*) "ACAD_MLEADERSTYLE"))

(setq newldrstyle (vlax-invoke mldrdict 'addobject "Standard" "AcDbMLeaderStyle"))

(vlax-put-property newldrstyle 'AlignSpace 0.18)

(vlax-put-property newldrstyle 'Annotative -1)

(vlax-put-property newldrstyle 'ArrowSize 0.125)

(vlax-put-property newldrstyle 'BlockConnectionType 0)

(vlax-put-property newldrstyle 'BlockRotation 0.0)

(vlax-put-property newldrstyle 'BlockScale 1.0)

(vlax-put-property newldrstyle 'BreakSize 0.125)

(vlax-put-property newldrstyle 'ContentType 2)

(vlax-put-property newldrstyle 'Description "Standard")

(vlax-put-property newldrstyle 'DoglegLength 0.125)

(vlax-put-property newldrstyle 'DrawLeaderOrderType 0)

(vlax-put-property newldrstyle 'DrawMLeaderOrderType 1)

(vlax-put-property newldrstyle 'EnableBlockRotation -1)

(vlax-put-property newldrstyle 'EnableBlockScale -1)

(vlax-put-property newldrstyle 'EnableDogleg -1)

(vlax-put-property newldrstyle 'EnableFrameText 0)

(vlax-put-property newldrstyle 'EnableLanding -1)

(vlax-put-property newldrstyle 'FirstSegmentAngleConstraint 0)

(vlax-put-property newldrstyle 'LandingGap 0.125)

(vlax-put-property newldrstyle 'LeaderLineType 1)

(vlax-put-property newldrstyle 'LeaderLineTypeId "ByLayer")

(vlax-put-property newldrstyle 'LeaderLineWeight -1)

(vlax-put-property newldrstyle 'MaxLeaderSegmentsPoints 0)

(vlax-put-property newldrstyle 'name "Standard")

(vlax-put-property newldrstyle 'ScaleFactor 1.0)

(vlax-put-property newldrstyle 'SecondSegmentAngleConstraint 0)

(vlax-put-property newldrstyle 'TextAlignmentType 0)

(vlax-put-property newldrstyle 'TextAngleType 1)

(vlax-put-property newldrstyle 'TextHeight 0.09375)

(vlax-put-property newldrstyle 'TextColor Yellow)

(vlax-put-property newldrstyle 'TextLeftAttachmentType 1)

(vlax-put-property newldrstyle 'TextRightAttachmentType 1)

(vlax-put-property newldrstyle 'TextString "")

(vlax-put-property newldrstyle 'TextStyle (getvar "textstyle")))

Link to comment
Share on other sites

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