Jump to content

How to create a lisp program displaying coordinates


Recommended Posts

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

 

Ok my bad, my apologies for that ignorant comment.

 

Basically what you're trying to say is if I put a number after

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

 

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

 

This should then change the 'gap' between each of the x and y coordinates?

 

EDIT: No, it doesn't it just adds a number in front of the x and y coordinates.

 

The luprec and And lunits just confuse me, I put a number e.g. 3/4 and it adds fractions to the end of the coordinates.

  • Replies 49
  • Created
  • Last Reply

Top Posters In This Topic

  • bharthts01

    24

  • Lee Mac

    11

  • MSasu

    7

  • Tiger

    3

Posted
Basically what you're trying to say is if I put a number after

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

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

This should then change the 'gap' between each of the x and y coordinates?

 

EDIT: No, it doesn't it just adds a number in front of the x and y coordinates.

 

The luprec and And lunits just confuse me, I put a number e.g. 3/4 and it adds fractions to the end of the coordinates.

 

To explain further, the rtos function (as used in my code) converts the X & Y numerical coordinate values of the selected point into strings to be used with the DimOrdinate command.

 

The rtos function takes the following format:

(rtos <number> <units> <precision>)

If the units and precision parameters are not supplied, rtos will use the current values of the LUNITS and LUPREC System Variables.

 

To use specific Units and Precision, supply the rtos function with the units and precision parameters, hence, in my code:

 

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

becomes:

 

(strcat "X=" (rtos (car p) [color=red]2 0[/color]) "\\XY=" (rtos (cadr p) [color=red]2 0[/color]))

Here, 2=decimal and 0=zero decimal places.

 

The "\\X" part of the string:

 

(strcat "X=" (rtos (car p) [color=black]2 0[/color]) "[color=red]\\X[/color]Y=" (rtos (cadr p)[color=black] [/color][color=black]2 0[/color]))

 

forces the subsequent text ("Y=....") onto a new line beneath the dimordinate dimension line.

 

Removing the "\\X" from the string will keep everything on the same line:

 

(strcat "X=" (rtos (car p) [color=black]2 0[/color]) " Y=" (rtos (cadr p) [color=black]2 0[/color]))

Posted
:

 

(strcat "X=" (rtos (car p) [color=black]2 0[/color]) " Y=" (rtos (cadr p) [color=black]2 0[/color]))

 

 

I think I just about follow you on that one, I've done it so I've edited to the code out so it displays X and Y on the same line (like you've stated removal of "\\XY=" to just Y=.

 

I've done all that but when it comes to running the lisp I get this error "malformed list on input". I'm going to assume this means I've entered the code wrong.

 

 

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

 

If it helps this is the new code, I've edited out the xy so it shows the coordinates on the same line

Posted

I see I've sorted it now by simply adding 2 0 into the code it's changed it to 9 digits and put it on the same line.

Posted

Close...

 

The malformed list on input indicates that you are missing one or more closing parentheses ")"

 

You are also missing the pause for the final point, corrected:

 

(defun c:dimo ( / p )
   (while (setq p (getpoint "\nSpecify Point <Exit>: "))
       (command "_.dimordinate" "_non" p "_T" (strcat "X=" (rtos (car p) 2 0) " Y=" (rtos (cadr p) 2 0)[color=red]) "\\")[/color]
   )
   (princ)
)

Posted

Wow thought I'd never understand this Java language stuff. Thanks for the help mate. Really appreciated.

Posted

Annother way to do your workset without any lisp to look for oportonities with blocks. It´s very easy to learn. You make a block with two attributes and than you marks text from attributes an put right button of mouse. You can read textfield in tab an choice it. Than you give a charakter for textobject... Take a look on Lynn Allen´s explanation she´s done it only with text but you can also do the same with a attribute. (

).

 

You have to marke a object in a block and give properties for x&y coordinates.

Try it if you can´t understand Autolisp in the beginning.

 

cheers Dirk

  • 4 months later...
Posted

Hello

I am a setting out engineer just getting into Autocad. I am able to scale and localize the drawings at the minute. I am now looking to id points and note the eastings and northings by the points, so that I can print it off to take out on site. The lisp program here, when I run it, only gives me 2 decimal places (10's of mm) where I need 3 decimal places (mm accuracy).

Can anyone please change the code for 3 decimal places.

 

I have found mulitleader type lisps that give me 3 decimal places. However for some reason the co-ords come up in a massive size.

Posted

I have had a look at the thread and then a look at the lisp code.

 

I have changed "(defun go_ne ()(setvar "luprec" 2)" to "(defun go_ne ()(setvar "luprec" 3)" and this seems to work.

 

I have seen your name on a couple of other threads I repled to yesterday. (I have found other multileader lisps that do the same thing, but the text comes out massive compared to the dwg.)

 

Thankyou for your time.

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