Jump to content

Recommended Posts

Posted

I have a lisp routine that prompts the user to "select a line".  It will then ask for a dimscale, it will multiply the dimscale by .09375 to get a text height.  It will then get the length of the selected line, and insert a piece of text with the line length.  It inserts the text (1) text height above the midpoint of the line.  For instance if I give it a dimscale of 96, (96 x .09375 = 9) it will set the text height to 9" and it will insert the text 9" above the mid point of the line.  The issue I am having is if the line is at an angle, lets say N74d12'35"E.  I would like for the text to be inserted at the same angle as the line and one text height above the line.  I have attached attached a sample drawing and the .lsp file to help.  I am not to proficient at lsip so i use AI to help solve issues, but that doesn't always work.  I still could not get the routine to work as intended.  

 

Thanks in advance

Drawing1.dwg LLT.lsp

Posted

Two comments,

 

If line is on an angle then this will be wrong, use polar and add (/ pi 2) to the angle of pt1 pt2.

 

  ;; Move the text up by the text height (add txtheight to the Y-coordinate of midpoint)
(setq txtpt (list (car txtpt) (+ (cadr txtpt) txtheight) (last txtpt)))

 

Get a copy of Lee-Mac text readable it will adjust the angle of the text to be always readable.

  • 2 weeks later...
Posted

Thanks for the help.  I looked on Lee-Mac website but could not find the "text readable" that you mentioned.

Posted

Hi Scotth

There are two considerations to keep in mind.
The first is that when the line isn't horizontal, the text placement point must take into account the angle defined by the line: '(setq a (angle pt1 pt2))'. To do this, you should use '(polar txtpt (+ a (/ pi 2)) txheight)'.

The second is what, I assume, brought you here: getting the text to adapt to the angle of the line. To do this, you'll need to update the text you created with the angle 'a' obtained previously.

Posted

There's also another consideration that we don't know if it's relevant:
What happens in cases where the text appears upside down because the x coordinate of pt1 is higher than that of pt2?

Posted

Try this there are a few variations out there but looks at a angle within a range.

 

;; Make Readable  -  Lee Mac
  ;; Returns a given angle corrected for text readability
(defun lm:makereadable (a)
    ((lambda (a)
       (if (and (< (* pi 0.5) a) (<= a (* pi 1.5)))
	 (+ a pi)
	 a
       )
     )
      (rem (+ a pi pi) (+ pi pi))
    )
)

 

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