Jump to content

Request for extension of existing lisp


Organic

Recommended Posts

A while back I modified the following lisp by Jimmy Bergmark

 

;;; By Jimmy Bergmark
;;; Copyright (C) 1997-2006 JTB World, All Rights Reserved
;;; Website: www.jtbworld.com
;;; E-mail: info@jtbworld.com
;;; rotate selected text objects to specified angle

(defun c:txtrot (/ sset i ed ang)
 (if (setq sset (ssget '((-4 . "<OR")
                         (0 . "MTEXT")
                         (0 . "TEXT")
                         (-4 . "OR>")
                        )
                )
     )
   (progn
     (setq ang (getangle "Specify rotation angle <0>: "))
     (if (null ang)
       (setq ang 0)
     )
     (repeat (setq i (sslength sset))
       (setq ed (entget (ssname sset (setq i (1- i)))))
       (entmod (subst (cons 50 ang)
                      (assoc 50 ed)
                      ed
               )
       )
     )
   )
 )
 (princ)
)

into

 

(defun c:txtrotmod
      
      (/ sset i ed ang)

 (if (setq sset (ssget '((-4 . "<OR")
                         (0 . "MTEXT")
                         (0 . "TEXT")
                         (-4 . "OR>")
                        )
                )
     )

   (progn
     (setq ang (getorient "Specify rotation angle: "))     ;; getorient always takes EAST as 0 degrees  
                               ;; regardless of the base angle direction in the 
                               ;; drawing file
     (if (null ang)
       (setq ang 0)
     )

     (repeat (setq i (sslength sset))
       (setq ed (entget (ssname sset (setq i (1- i)))))
       (entmod (subst (cons 50 ang)
                      (assoc 50 ed)
                      ed
               )
       )
     )
   )
 )

 (princ)

The lisp rotates text to have the same rotation angle as the angle between two picks made. My hack to fix the rotation and ensure it always rotates correctly is about the limit of my lisp skills (or lack of), so I am hoping someone can help me with the following separate extensions of the second lisp:

 

Extension 1: The user selects two points like normal and the text is rotated, although if those points are part of a line/polyline/arc, the lisp should then get the endpoints of the entity and place the text above (offset 0.1 distance above etc) it.

 

Extension 2 (separate lisp): The user selects two points like normal although the text is not only rotated, although also placed halfway between the selected points and placed slightly above the imaginary line connecting those two points (offset 0.1 distance above etc).

 

If anyone has time and feels like trying to extend the second lisp above to achieve those extensions it would be much appreciated :)

 

Cheers,

Organic

Edited by Organic
Link to comment
Share on other sites

For the first one:

 

2n668vt.jpg

 

I think the justification of the text/mtext would need to be changed to middle centre or similar first? Then the X distance could be from the perpendicular of the line to the centre of the text? The text is placed halfway along the entity (a line in this case).

 

For the second one:

 

28hj5og.jpg

 

where Y is the distance between the two pick points (not necessarily snapped to an entity like a line as shown in the picture) and the text is then placed halfway between the two pick points, while still being offset X distance from the chord between the two pick points.

Link to comment
Share on other sites

Would it be possible to code this in VBA or would it only be possible in lisp? I know a little VBA so might try that if it is doable :)

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