+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Senior Member ILoveMadoka's Avatar
    Using
    Solidworks 2013
    Join Date
    Oct 2008
    Posts
    332

    Embarrassed Question for Lee - Match Text Properties

    Registered forum members do not see this ad.

    Lee,

    In your Match Text Properties program you mention....
    the user has complete control over which properties are to be inherited by selected 'destination' objects. The list of properties located at the top of the program correspond to the ActiveX properties of Text, MText, Attribute or Attribute Definition VLA-Objects and may be edited to suit the user's requirements.
    Not sure HOW or WHERE to do this.

    Looking to do Height, StyleName, Scalefactor, Linespacing Factor.

    Program as written is not working on the drawing that I am trying to change.
    It was converted from VISIO if that matters.

    Please advise.



    Code:
    ;;---------------=={ Match Text Properties }==----------------;;
    ;;                                                            ;;
    ;;  Prompts for a selection of Text, MText, Attribute, or     ;;
    ;;  Attribute Definition object to use as property source,    ;;
    ;;  then proceed to match those properties listed for similar ;;
    ;;  objects selected thereafter.                              ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    
    (defun c:MTP nil (c:MatchTextProps))
    
    (defun c:MatchTextProps ( / *error* _StartUndo _EndUndo _GetTextInsertion _PutTextInsertion Props doc entity object ss )
      (vl-load-com)
      ;; © Lee Mac 2010
    
      (setq Props
       '(
         Alignment
         AttachmentPoint
         BackgroundFill
         Backward
         DrawingDirection
         Height
         Layer
         LineSpacingDistance
         LineSpacingFactor
         LineSpacingStyle
         Linetype
         LinetypeScale
         Lineweight
         ObliqueAngle
         Rotation
         ScaleFactor
         StyleName
        ; TextString
         Thickness
         UpsideDown
         Width
        )
      )
    
      (setq doc (vla-get-ActiveDocument (vlax-get-acad-object)))
    
      (defun *error* ( msg )
        (if doc (_EndUndo doc)) (if mutt (setvar 'NOMUTT mutt))
        (or (wcmatch (strcase msg) "*BREAK,*CANCEL*,*EXIT*")
            (princ (strcat "\n** Error: " msg " **")))
        (princ)
      )
    
      (defun _StartUndo ( doc ) (_EndUndo doc)
        (vla-StartUndoMark doc)
      )
    
      (defun _EndUndo ( doc )
        (if (= 8 (logand 8 (getvar 'UNDOCTL)))
          (vla-EndUndoMark doc)
        )
      )
    
      (defun _GetTextInsertion ( object )
        (vlax-get-property object
          (if
            (or
              (eq "AcDbMText" (vla-get-ObjectName object))
              (vl-position (vla-get-Alignment object)
                (list acAlignmentLeft acAlignmentFit acAlignmentAligned)
              )
            )
            'InsertionPoint
            'TextAlignmentPoint
          )
        )
      )
    
      (defun _PutTextInsertion ( object point )
        (vlax-put-property object
          (if
            (or
              (eq "AcDbMText" (vla-get-ObjectName object))
              (vl-position (vla-get-Alignment object)
                (list acAlignmentLeft acAlignmentFit acAlignmentAligned)
              )
            )
            'InsertionPoint
            'TextAlignmentPoint
          )
          point
        )
      )
    
      (if
        (and
          (setq entity
            (LM:Selectif
              (lambda ( x )
                (wcmatch (cdr (assoc 0 (entget x))) "TEXT,MTEXT,ATTRIB,ATTDEF")
              )
              nentsel "\nSelect Source Object: "
            )
          )
          (progn
            (setq mutt (getvar 'NOMUTT))
            (setvar 'NOMUTT 1)
            
            (princ (strcat "\nSelect Destination " (cdr (assoc 0 (entget entity))) " objects: "))
            (setq object (vlax-ename->vla-object entity)
              ss
               (ssget "_:L"
                 (list
                   (assoc 0 (entget entity))
                 )
               )
            )
            (setvar 'NOMUTT mutt) ss
          )
        )
        (
          (lambda ( i values / entity obj )
    
            (_StartUndo doc)
            
            (while (setq entity (ssname ss (setq i (1+ i))))
              (setq obj (vlax-ename->vla-object entity))
    
              (mapcar
                (function
                  (lambda ( prop value )
                    (if
                      (vl-catch-all-error-p
                        (vl-catch-all-apply
                          (function
                            (lambda nil
                              (if (and (vlax-property-available-p obj prop t) value)
                                (if (vl-position prop '(Alignment AttachmentPoint))
                                  (
                                    (lambda ( insertion )
                                      (vlax-put-property obj prop value)
                                      (_PutTextInsertion obj insertion)
                                    )
                                    (_GetTextInsertion obj)
                                  )
                                  (vlax-put-property obj prop value)
                                )
                              )
                            )
                          )
                        )
                      )
                      (princ (strcat "\n** Error Applying Property: " Prop " **"))
                    )
                  )
                )
                Props Values
              )
            )
    
            (_EndUndo doc)
          )
          -1
          (mapcar
            (function
              (lambda ( prop )
                (if (vlax-property-available-p object prop)
                  (vlax-get-property object prop)
                )
              )
            )
            Props
          )
        )
      )
      (princ)
    )
    
    ;;---------------------=={ Select if }==----------------------;;
    ;;                                                            ;;
    ;;  Continuous selection prompts until the predicate function ;;
    ;;  foo is validated                                          ;;
    ;;------------------------------------------------------------;;
    ;;  Author: Lee Mac, Copyright © 2010 - www.lee-mac.com       ;;
    ;;------------------------------------------------------------;;
    ;;  Arguments:                                                ;;
    ;;  foo - optional predicate function taking ename argument   ;;
    ;;  fun - selection function to invoke                        ;;
    ;;  str - prompt string                                       ;;
    ;;------------------------------------------------------------;;
    ;;  Returns:  selected entity ename if successful, else nil   ;;
    ;;------------------------------------------------------------;;
    
    (defun LM:Selectif ( foo fun str / e )
      ;; © Lee Mac 2010
      (while
        (progn (setq e (car (fun str)))      
          (cond
            ( (eq 'ENAME (type e))
    
              (if (and foo (not (foo e)))
                (princ "\n** Invalid Object Selected **")
              )
            )
          )
        )
      )
      e
    )
    Thanks Much!!
    Last edited by ILoveMadoka; 8th Jan 2014 at 02:28 pm. Reason: rev

  2. #2
    Senior Member Spaj's Avatar
    Computer Details
    Spaj's Computer Details
    Operating System:
    Win 7
    Motherboard:
    ASUS P5K
    CPU:
    Intel E8400
    RAM:
    4096Mb
    Graphics:
    MSI Nvidia GTX660 2GB
    Primary Storage:
    OCZ RevoDrive 128GB
    Secondary Storage:
    WD Black 1TB
    Monitor:
    Samsung 27" LCD
    Discipline
    Civil
    Using
    Civil 3D 2016
    Join Date
    Oct 2013
    Location
    South Africa
    Posts
    144

    Default

    Hi

    At a guess I would say that you need to comment out ( ; ) properties you do not wish to match in the list below, as it stand it looks as though all properties except the contents of the text string are matched. ie to not match LAYER place a ; in front of the variable layer.)


    I'm sure Lee will be along shortly to advise.

    Code:
    (setq Props    
      '(      
          Alignment
          AttachmentPoint
          BackgroundFill
          Backward
          DrawingDirection
          Height
          Layer
          LineSpacingDistance
          LineSpacingFactor
          LineSpacingStyle
          Linetype
          LinetypeScale
          Lineweight
          ObliqueAngle
          Rotation
          ScaleFactor
          StyleName
        ; TextString  <-- property not matched    
          Thickness      
          UpsideDown
          Width
         )
       )

  3. #3
    Senior Member ILoveMadoka's Avatar
    Using
    Solidworks 2013
    Join Date
    Oct 2008
    Posts
    332

    Default

    At a closer look, it is the font that is not changing
    but it appears that the font was changed outside of the style command.

    Artifacts from converted drawings are always a PITA!!


    New Question:

    Can the Source Objects font be forced upon the other selected text objects
    over-riding any settings?

  4. #4
    Senior Member Spaj's Avatar
    Computer Details
    Spaj's Computer Details
    Operating System:
    Win 7
    Motherboard:
    ASUS P5K
    CPU:
    Intel E8400
    RAM:
    4096Mb
    Graphics:
    MSI Nvidia GTX660 2GB
    Primary Storage:
    OCZ RevoDrive 128GB
    Secondary Storage:
    WD Black 1TB
    Monitor:
    Samsung 27" LCD
    Discipline
    Civil
    Using
    Civil 3D 2016
    Join Date
    Oct 2013
    Location
    South Africa
    Posts
    144

    Default

    Hi

    It looks like Lee's routine does match the font, or style at least (StyleName), but if you have individual text formatting overides it's a problem. Maybe try source StripMText.lsp. Does an excellent job of stripping out text formatting.

  5. #5
    Quantum Mechanic Lee Mac's Avatar
    Computer Details
    Lee Mac's Computer Details
    Operating System:
    Windows 7 Ultimate (32-bit)
    Discipline
    Multi-disciplinary
    Lee Mac's Discipline Details
    Discipline
    Multi-disciplinary
    Details
    Custom Programming / Software Customisation
    Using
    AutoCAD 2013
    Join Date
    Aug 2008
    Location
    London, England
    Posts
    19,359

    Default

    Registered forum members do not see this ad.

    To clarify, my old Match Text Properties program will only change the ActiveX properties for the selection of objects, and so where 'font' is concerned, the closest property you can change using my existing program is the stylename property, which will alter the Text Style assigned to the object.

    Since MText formatting which has been applied through the MText Editor is stored as formatting codes within the text content, this cannot be matched using this program without matching the entire content of the text (i.e. matching the textstring property).

    You have the option of removing the MText formatting overrides (using StripMText as suggested above, or otherwise) and using the Text Style to control the font applied to the entire annotation object; else you would need to write a program to extract the formatting codes surrounding the displayed text content and then insert these codes within the content of the 'destination' annotation object (assuming such object supported MText formatting).

    Lee
    Lee Mac ProgrammingTwitterExchange App StoreDropbox (500MB free)

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

Similar Threads

  1. Match Properties won't match Multileader Text in CAD 2010
    By Sengna in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 4
    Last Post: 27th Sep 2013, 05:10 am
  2. Match properties for Text issue
    By Sengna in forum AutoCAD 2D Drafting, Object Properties & Interface
    Replies: 16
    Last Post: 3rd Sep 2013, 08:53 am
  3. Match Properties Text
    By Ocron in forum AutoLISP, Visual LISP & DCL
    Replies: 14
    Last Post: 13th Oct 2010, 03:58 pm
  4. Block, Object/Match properties question.
    By p1nkninja in forum AutoCAD Beginners' Area
    Replies: 4
    Last Post: 12th Oct 2008, 03:22 am
  5. match properties w/text? is there a lisp
    By Chris H. in forum AutoLISP, Visual LISP & DCL
    Replies: 4
    Last Post: 29th May 2008, 02:10 pm

Tags for this Thread

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