Jump to content

How to create a lisp program displaying coordinates


Recommended Posts

Posted

Nearly got it!!!! Thanks!!!

 

Last thing..... Need an arrow pointing to the point which the coordinate states

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

  • bharthts01

    24

  • Lee Mac

    11

  • MSasu

    7

  • Tiger

    3

Posted

It is good to re-invent the wheel every now and again, but for the more idle amongst us, this thread seemed to cover the current topic several years ago. :D

Posted

How about simply:

 

(defun c:dimo ( / p )
   (while (setq p (getpoint "\nSpecify Point <Exit>: "))
       (command "_.dimordinate" "_non" p "_T" (strcat "X=" (rtos (car p)) "\\XY=" (rtos (cadr p))) "\\")
   )
   (princ)
)

Posted
How about simply:

 

(defun c:dimo ( / p )
   (while (setq p (getpoint "\nSpecify Point <Exit>: "))
       (command "_.dimordinate" "_non" p "_T" (strcat "X=" (rtos (car p)) "\\XY=" (rtos (cadr p))) "\\")
   )
   (princ)
)

 

Is that the full code?

Posted

Is that the full code I.e

Copy and paste that into notepad? Or is there more to that?

Posted

(defun c:ne( / oldOsmode e-x n-y ne1 prmt tx-ht vx vy x-ht xx yy )
(defun go_ne()
 ;(setvar "luprec" 2)
 (setq prmt (strcat "Enter TEXT HEIGHT<" (rtos tx-ht) ">: "))
 (princ prmt)
 (setq x-ht (getreal))
 (if (= x-ht nil)
  (setq x-ht tx-ht)
 )
 (setq tx-ht x-ht)
 (setq e-x (car ne1))
 (setq xx (rtos e-x 2 0))
 (setq n-y (cadr ne1))
 (setq yy (rtos n-y 2 0))
 (tx-f)
)

(defun tx-f()
 (setq vx (strcat " E " xx))
 (setq vy (strcat " N " yy))
 (command "_.TEXT" "_J" "_ML" ne1 x-ht 0.0 (strcat vx " / " vy))
)

(setq tx-ht 0.5)
(setq oldOsmode (getvar "OSMODE"))
(setvar "osmode" 427)
(setq ne1 (getpoint "\nPick point..."))
(setvar "osmode" 0)
(if (/= ne1 nil)
 (go_ne)
 (princ "\nInvalid Location !")
)
(setvar "OSMODE" oldOsmode)
(princ)
)

 

This is the code I'm using.

 

monday.jpg

 

This is what it looks like (highlighted with the red bubble).

 

I'm after one last thing, which is the 'line/point' which the coordinate is stating.

As shown on the left.

Posted
Did you try my code?

 

What command is it?

Posted

Right thanks for that. Would be possible for it to show only 9 digits and increase the spacing between x and y?

monday_2.jpg

 

Being a bit picky here, but would look neater if it all was on 1 line. X 430254889 Y 434123122 (random numbers)

Posted

My program simply uses the DimOrdinate command with a custom text string.

 

The string is constructed using the following expression:

(strcat "X=" (rtos (car p)) "\\XY=" (rtos (cadr p)))

The "\\X" places the subsequent text beneath the dimordinate dimension line.

 

The units and precision are controlled by your settings of LUNITS & LUPREC; MSasu has already shown you how to modify rtos expressions.

Posted
My program simply uses the DimOrdinate command with a custom text string.

 

The string is constructed using the following expression:

(strcat "X=" (rtos (car p)) "\\XY=" (rtos (cadr p)))

The "\\X" places the subsequent text beneath the dimordinate dimension line.

 

The units and precision are controlled by your settings of LUNITS & LUPREC; MSasu has already shown you how to modify rtos expressions.

 

I've no idea what you just wrote.

Posted

Possible to get the coordinates to 9 digits please?

 

Edit: And make them all on 1 line?

Posted

Thanks for the Code Btw Lee Mac, but I'm quite happy with this one. It's a lot 'neater' just need the 'line' adding to it that's all.

 

(defun c:ne( / oldOsmode e-x n-y ne1 prmt tx-ht vx vy x-ht xx yy )
(defun go_ne()
 ;(setvar "luprec" 2)
 (setq prmt (strcat "Enter TEXT HEIGHT<" (rtos tx-ht) ">: "))
 (princ prmt)
 (setq x-ht (getreal))
 (if (= x-ht nil)
  (setq x-ht tx-ht)
 )
 (setq tx-ht x-ht)
 (setq e-x (car ne1))
 (setq xx (rtos e-x 2 0))
 (setq n-y (cadr ne1))
 (setq yy (rtos n-y 2 0))
 (tx-f)
)

(defun tx-f()
 (setq vx (strcat " E " xx))
 (setq vy (strcat " N " yy))
 (command "_.TEXT" "_J" "_ML" ne1 x-ht 0.0 (strcat vx " / " vy))
)

(setq tx-ht 0.5)
(setq oldOsmode (getvar "OSMODE"))
(setvar "osmode" 427)
(setq ne1 (getpoint "\nPick point..."))
(setvar "osmode" 0)
(if (/= ne1 nil)
 (go_ne)
 (princ "\nInvalid Location !")
)
(setvar "OSMODE" oldOsmode)
(princ)
)

Posted
I've no idea what you just wrote.

 

I would suggest you carefully read it again and at least put a little effort into trying to understand what the code is doing, instead of expecting everything to be handed to you on a plate.

Posted
I would suggest you carefully read it again and at least put a little effort into trying to understand what the code is doing, instead of expecting everything to be handed to you on a plate.

 

I have read it, I don't follow you. No need to get big headed.

Posted
I have read it, I don't follow you. No need to get big headed.

 

Which parts specifically do you not understand?

 

If you do not understand my explanations, I would expect you to ask questions for clarification, not bluntly dismiss the explanation out of hand.

 

I'll choose to ignore the immature comment while you reconsider which one of us is asking for help.

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