See the top rated post in this thread. Click here

Page 1 of 2 12 LastLast
Results 1 to 10 of 11

Thread: Match text coordinate and rotation

  1. #1
    Active Member
    Join Date
    2011-10
    Posts
    83
    Login to Give a bone
    0

    Default Match text coordinate and rotation

    Dear all,

    I would like to ask for your help. I would like to match text by X or Y coordinates and text rotation.
    I have a lot of texts (not mtext) in autocad drawing with differernt rotation and coordinates, I need to match one text with proper another texts, another text with another proper textes and so on... It's not like selecting all and typing rotation angle and X or Y coordinate in properties for all... I wish...

    I imagine it works like this: run lisp (for eg. command: 'maX' for X coordinate and 'maY' for Y), select sourse text and select target text.
    Routine matches by one coordinate and rotation.

    Thanks in advane for any help...

    Regards.

  2. #2
    Certifiable AUGI Addict
    Join Date
    2001-03
    Location
    Tallahassee, FL USA
    Posts
    3,667
    Login to Give a bone
    0

    Default Re: Match text coordinate and rotation

    Are you looking for a text stacking routine where you select the first text the all other selections are placed on lines below it?

  3. #3
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Match text coordinate and rotation

    I would like to understand your question better...

    Can you write a flow chart list (series of steps) for your routine?

    Like...

    Flow Chart List
    Select source text object
    Get insertion point and rotation
    Select target text object
    Change X or Y coordinate of target text to match source text
    (Q: How do you decide which coordinate to match?)
    (Q:Is this to align text with other text objects?)
    Change rotation of target text to match source

    P=
    AutomateCAD

  4. #4
    Active Member
    Join Date
    2011-10
    Posts
    83
    Login to Give a bone
    0

    Default Re: Match text coordinate and rotation

    Hi,

    sorry for my not clear english
    (Q: How do you decide which coordinate to match?)
    different commands
    (Q:Is this to align text with other text objects?)
    yes, it is.
    Change rotation of target text to match source
    That's right.

    Steps:
    1) type command to run lisp: eg. MAX ('MA' - match, 'X' - x coordinate)
    2) select source text (information needed: text rotation, X cordinate)
    3) select target texts
    4) ENTER (as finish )

    Result:
    1. Source text - stays as was.
    2. Target texts - the same text rotation and X (or Y - according to selectect option "MAX" or "MAY" commands) coordinate as source text.

    The same steps for Y coordinates, about different command, eg. MAY.

    Thanks in advance.

  5. #5
    Active Member
    Join Date
    2011-10
    Posts
    83
    Login to Give a bone
    0

    Default Re: Match text coordinate and rotation

    Quote Originally Posted by Tom Beauford View Post
    Are you looking for a text stacking routine where you select the first text the all other selections are placed on lines below it?
    Something like this, but my target texts are placed not only below, but also over, on right or left, depends which coordinate I want to match... for X cordinate, all target texts will be over or below, for Y - on the right or left...

  6. #6
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    1

    Default Re: Match text coordinate and rotation

    Something like this?

    P=

    Code:
    ; Function to transfer the rotation of a selected text and the maximum x value to selected text
    
    (defun C:Max (/ lstAreas 
                    lstInsertion
                    lstInsertions
                    lstObjects 
                    lstSelections 
                    objSource 
                    sngMax 
                    sngRotation 
                    ssSelections)
     (if (and
          (print "Select Source Text first and text to change after: ")
          (setq ssSelections  (ssget  (list (cons 0 "text"))))
          (setq lstSelections (SelectionSetToList ssSelections))
          (setq lstObjects    (mapcar 'vlax-ename->vla-object lstSelections))
          (setq objSource     (car lstObjects))
          (setq sngRotation   (vla-get-rotation objSource))
          (setq lstObjects    (cdr lstObjects))
          (setq lstInsertions (mapcar '(lambda (X)(vlax-get X "insertionpoint")) lstObjects))
          (print (length lstObjects))
          (setq lstInsertion  (vlax-get objSource "insertionpoint"))
          (setq sngMax        (car lstInsertion))
          ;(setq sngMax       (apply 'max (mapcar 'car lstInsertions)))
    
         )
      (apply 'and (mapcar '(lambda (X)(textfix X sngRotation (list sngMax nil nil))) lstObjects))
     )
    )
    
    ; Function to change the rotation and set the x coordinate to be a specified value
    
    (defun TextFix (objText sngRotation lstMaximas / lstInsertion)
     (and
      (errortrap (quote (vla-put-rotation objText sngRotation))) 
      (setq lstInsertion (vlax-get objText "insertionpoint"))
      (setq lstInsertion (mapcar 'OrValue lstMaximas lstInsertion))
      (errortrap (quote (vlax-put objText "insertionpoint" lstInsertion)))
     )
    )
    
    ; Function for substituting a value for a nil in a pair of lists
    
    (defun OrValue (sngValue1 sngValue2)
     (if sngValue1 sngValue1 sngValue2)
    )
    
    ;Function to convert a lisp selection set into a list of entities
    
    (defun SelectionSetToList (ssSelections / intCount entSelection lstSelections)
     (repeat (setq intCount (sslength ssSelections))
      (and
       (setq intCount      (1- intCount))  
       (setq entSelection  (ssname ssSelections intCount))
       (setq lstSelections (cons entSelection lstSelections))  
      )
     )
     lstSelections
    )
    
    ; Function to trap lisp errors
    
    (defun ErrorTrap (symFunction / objError result)
     (if (vl-catch-all-error-p
          (setq objError (vl-catch-all-apply
                         '(lambda (X)(set X (eval symFunction)))
                          (list 'result))))
      nil
      (if result result 'T)
     )
    )
    
    
    (vl-load-com)
    Attached Files Attached Files
    Last edited by peter; 2015-02-18 at 04:42 PM.
    AutomateCAD

  7. #7
    Active Member
    Join Date
    2011-10
    Posts
    83
    Login to Give a bone
    0

    Default Re: Match text coordinate and rotation

    Almost...
    this lisp is looking for maximum X value, I would like to have X value from source text...

  8. #8
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    0

    Default Re: Match text coordinate and rotation

    Ok I changed the code to use the X coordinate of the source text.

    See Above.

    P=
    AutomateCAD

  9. #9
    Active Member
    Join Date
    2011-10
    Posts
    83
    Login to Give a bone
    0

    Default Re: Match text coordinate and rotation

    Brilliant, thanks!
    Can you advise how to convert it into y coodinate. I tryied to do it, but faild... I am to even weak in lisp... I change x -> y in routine but I think it is not enough...

  10. #10
    Past Vice President / AUGI Volunteer peter's Avatar
    Join Date
    2000-09
    Location
    Honolulu HI
    Posts
    1,109
    Login to Give a bone
    1

    Default Re: Match text coordinate and rotation

    Change this line

    Code:
          
     (setq sngMax        (car lstInsertion)); <-First Item in list is the X coordinate
    to

    Code:
          
     (setq sngMax        (cadr lstInsertion)); <-Second Item in list is the Y coordinate
    change

    Code:
          
     (apply 'and (mapcar '(lambda (X)(textfix X sngRotation (list sngMax nil nil))) lstObjects))
    to

    Code:
          
     (apply 'and (mapcar '(lambda (X)(textfix X sngRotation (list nil sngMax nil))) lstObjects))
    and of course change the name.
    AutomateCAD

Page 1 of 2 12 LastLast

Similar Threads

  1. Match Text Properties Without Affecting Rotation
    By BILLYJOW in forum AutoLISP
    Replies: 8
    Last Post: 2015-07-29, 04:05 PM
  2. Match Text
    By Wish List System in forum AutoCAD Wish List
    Replies: 0
    Last Post: 2012-06-17, 04:27 AM
  3. Replies: 3
    Last Post: 2009-08-10, 11:40 PM
  4. Replies: 4
    Last Post: 2007-11-26, 10:22 PM
  5. AutoCAD - DWF output rotation doesn't match sheet rotation
    By ttaylor.62786 in forum AutoCAD Plotting
    Replies: 3
    Last Post: 2007-02-16, 12:24 AM

Posting Permissions

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