Jump to content

Coordinate Readout from World UCS to Alternative UCS


Recommended Posts

Posted

I have a lisp routine that places a Northing and Easting Coordinate callout in paper space and it displays the coordinates in world UCS, but I need them to show in a different UCS that I have setup. Does anybody have any insight in how to make this happen?

Posted

Use the trans function on the output point before it is converted to a string.

 

If you're stuck, post the code.

Posted

This is a portion of the code that I have.

 

 
(setq pt1 (trans pt1 3 2))
) 
 
(setq x1 (car pt1))           ;Stores the x coord of the first point.
(setq y1 (cadr pt1))          ;Stores the y coord of the first point.
(setq z1 (caddr pt1))   ;stores the z coord of the first point. JAH
 
(setq xabs (abs x1))          ;Gets the absolute value of the x point.
(setq yabs (abs y1))          ;Gets the absolute value of the y point.
(setq zabs (abs z1))          ;Gets the absolute value of the z point. JAH
 
(setq x (rtos xabs (getvar "lunits") (+(getvar "luprec")0)))          ;Converts the x coord from real to string.
(setq y (rtos yabs (getvar "lunits") (+(getvar "luprec")0)))          ;Converts the y coord form real to string.
(setq z (rtos zabs (getvar "lunits") (+(getvar "luprec")0)))          ;Converts the z coord form real to string. JAH

Posted

It would depend on how 'pt1' is obtained - if getpoint is used, then the point will be in the UCS, so no transformation is needed.

 

Note that your code could be shortened to:

 

(mapcar 'set '(x y z) (mapcar 'rtos (mapcar 'abs pt1)))

Consider this code:

 

(defun c:mpt ( / _MText norm pt )
 ;; © Lee Mac 2010

 (defun _MText ( pt val norm )
   (entmakex
     (list
       (cons 0 "MTEXT")
       (cons 100 "AcDbEntity")
       (cons 100 "AcDbMText")
       (cons 10 pt)
       (cons 11 (getvar 'UCSXDIR))
       (cons 1  val)
       (cons 210 norm)
     )
   )
 )

 (setq norm (trans '(0. 0. 1.) 1 0 t))

 (terpri)

 (while (setq pt (getpoint "\rSpecify Point: "))    
   (_MText (trans pt 1 0)
     (apply 'strcat
       (mapcar 'strcat '("X = " "\nY = " "\nZ = ") (mapcar 'rtos pt))
     )
     norm
   )
 )

 (princ)
)

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