+ Reply to Thread
Results 1 to 6 of 6
  1. #1
    Super Member
    Using
    Civil 3D 2015
    Join Date
    Aug 2015
    Posts
    508

    Default Change text color for multileader

    Registered forum members do not see this ad.

    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.
    Code:
    (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?

  2. #2
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Win 7 Pro / Win 10 Pro / Linux Mint
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2018
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,600

    Default

    You could change the TextColor property of the corresponding MLeader Style, e.g.:
    Code:
    (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.
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

    With Mathematics there is the possibility of perfect rigour, so why settle for less?

  3. #3
    Super Member
    Discipline
    Multi-disciplinary
    Using
    AutoCAD 2015
    Join Date
    Nov 2013
    Posts
    1,478

    Default

    Quote Originally Posted by Lee Mac View Post
    You could change the TextColor property of the corresponding MLeader Style, e.g.:
    ..
    I like your suggestion.

  4. #4
    Super Member
    Using
    Civil 3D 2015
    Join Date
    Aug 2015
    Posts
    508

    Default

    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.

  5. #5
    Senior Member
    Discipline
    Electrical
    Using
    AutoCAD 2015
    Join Date
    Jul 2015
    Location
    Egypt
    Posts
    126

    Default

    here a one i used from afralisp.com


    Code:
    (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

  6. #6
    Forum Newbie
    Using
    AutoCAD 2016
    Join Date
    Oct 2015
    Posts
    1

    Default

    Registered forum members do not see this ad.

    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.1
    (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")))

Similar Threads

  1. Change color of text on an attributed block
    By Efeezy in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 20th Sep 2015, 07:19 pm
  2. change attribute text by color
    By Jessica28 in forum AutoCAD General
    Replies: 9
    Last Post: 15th Apr 2014, 03:21 pm
  3. change text color according to text height in a given range
    By Astro in forum AutoLISP, Visual LISP & DCL
    Replies: 3
    Last Post: 4th Oct 2013, 10:24 am
  4. Change justification of leader of multileader text
    By Organic in forum AutoCAD Beginners' Area
    Replies: 3
    Last Post: 10th Jan 2012, 04:41 pm
  5. Text Color Change Makes Text Move??
    By geocad in forum AutoCAD General
    Replies: 2
    Last Post: 29th Dec 2011, 09:50 pm

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts