# Thread: Distance from circle to circle

1. ## Distance from circle to circle

I am a newbie to autocad code. I can do the simple stuff but I cannot figure out how to get the distance from one center point to another center point. And from that display it with a leader format. Like I said I know the simple stuff does anybody know of a glossary of code functions that are out there?

I am attaching a sample of code that i tried. I want the distance from A to a circle and also B to a circle and give the distance on a leader.

My code goes
Code:
```	(setq a (getpoint "\nEnter First Point : "))
(setq b (getpoint "\nEnter Second Point : "))
(setq F1 (getpoint "\Enter Post location : "))
(setq di1 (command "distance" a f1 "")
(setq di2 (command "distance" b f1 "")```
I am obviously going wrong with the distance commands or I do not know how to display it. any help can you describe how you used that command so I know I really want to learn it!

I am also giving a drawing so you can see what I did by using leaders and lots of distance commands

2. ## Re: Distance from circle to circle

In the help it list all the built in functions that can be used with Lisp. To get the distance between two points use the 'distance' function. So instead of '(command "_.distance" ...)' you would use
(setq dis1 (distance a F1))
(setq dis2 (distance b F1))

3. ## Re: Distance from circle to circle

Hi Brian,
Your code just revised like this, and you can continoues your code again
Code:
```(defun c:test (/ a b f1 dis1 dis2)
(setq a (getpoint "\nEnter First Point : "))
(setq b (getpoint "\nEnter Second Point : "))
(setq F1 (getpoint "\Enter Post location : "))
(setq dis1 (distance a f1))
(setq dis2 (distance b f1))
;(setq di1 (command "distance" a f1 "")
;(setq di2 (command "distance" b f1 "")

; put here if you would continoues your code

(princ)
) ; defun```
Originally Posted by Brian.164262
I am a newbie to autocad code. I can do the simple stuff but I cannot figure out how to get the distance from one center point to another center point. And from that display it with a leader format. Like I said I know the simple stuff does anybody know of a glossary of code functions that are out there?

I am attaching a sample of code that i tried. I want the distance from A to a circle and also B to a circle and give the distance on a leader.

My code goes
(setq a (getpoint "\nEnter First Point : "))
(setq b (getpoint "\nEnter Second Point : "))
(setq F1 (getpoint "\Enter Post location : "))
(setq di1 (command "distance" a f1 "")
(setq di2 (command "distance" b f1 "")
I am obviously going wrong with the distance commands or I do not know how to display it. any help can you describe how you used that command so I know I really want to learn it!

I am also giving a drawing so you can see what I did by using leaders and lots of distance commands

4. ## Re: Distance from circle to circle

Thanks for the help do you guys know why when I load my program and run it through. When it is done it does the previous command before my program loaded?

And this is probably really dumb but in my program which is better? I make a leader with the distance A F1 and B F1. Do I make it a block that is inserted each time or a leader with mtext on it. It is going to have to be done multiple times within this program which is the better way to do it? I could increment the distance command and if I moved one of the points it would automatically update correct? Could I have it update a block or does it have to be a leader then?

5. ## Re: Distance from circle to circle

Originally Posted by Brian.164262
Thanks for the help do you guys know why when I load my program and run it through. When it is done it does the previous command before my program loaded?
This is usually caused by an extra enter being called within the lisp. An enter is a double quote ( "" ), so if you post the new code it will be easier for us to help you.

Originally Posted by Brian.164262
And this is probably really dumb but in my program which is better? I make a leader with the distance A F1 and B F1. Do I make it a block that is inserted each time or a leader with mtext on it. It is going to have to be done multiple times within this program which is the better way to do it? I could increment the distance command and if I moved one of the points it would automatically update correct? Could I have it update a block or does it have to be a leader then?
I'm not sure I totally understand what you are doing, but if you want the items to be edited after the program, then I would go with the leader route instead of the block route. Maybe if you break it down step by step we will be better able to help you build the routine you want.

6. ## Re: Distance from circle to circle

I HAVE DONE IT!!!! (first program) Thanks for the help I broke down and bought a book

I realized that I do not have to keep each leader text stored since my drawing is set in the location is has to be in.

But now that I have a nice program running I have a question. My varibles are stored as an integer wich is fine untill I want to display it on my screen. I want it in feet where can I change that setting. My units are already in feet but I have a feeling that doesn't matter to the program. How do I switch it to display as feet and the nearest inch.

Code:
```(defun C:stakeout ()
(setq A (getpoint "\nEnter A point"))
(setq B (getpoint "\nEnter B point"))
(setq f1 (getpoint "\nEnter Footer location"))
(while f1 1
(setq di1 (distance A f1))
(setq di2 (distance B f1))
(command "qleader" f1 pause di1 di2 "")
(setq f1 (getpoint "\Enter footer Location"))
)
)```

7. ## Re: Distance from circle to circle

If you are working with integers then look at 'itoa', if you are working with real numbers then look at 'rtos'.

Buying a book is not a problem. To me it means you are willing to learn, and are willing to do what it takes to make yourself better. Good luck with it.

8. ## Re: Distance from circle to circle

The book is pretty good but I think I need a programming specific book. It only had two chapters covering programming.

The one question I have is with my leader command. I have to set up my leader apperance in every drawing. I was looking to find out how to change that automatically when the program starts up.

I am trying to have the hook underline my output. And also have there be a maximum of two points. I have looked in help but I cannot find the varible settings how can I do that for any comand. Like (rtos x 4 2) or (osmode 4143).

I think it should go like (setvar "leader" 1 33 56) is something like that correct?

9. ## Re: Distance from circle to circle

Originally Posted by Brian.164262
The book is pretty good but I think I need a programming specific book. It only had two chapters covering programming.
You may want a book, or you can see what people have said here about web sites that teach people to program. The only one I know off hand is AfraLisp.net

Originally Posted by Brian.164262
The one question I have is with my leader command. I have to set up my leader apperance in every drawing. I was looking to find out how to change that automatically when the program starts up.
There are a lot of system variables that would need to be set up, and I don't handle that part of coding for my company (they set it up, and I use it), so I'm not sure what all you would need to do. Sorry I'm a great help there, but others may be.

Originally Posted by Brian.164262
I am trying to have the hook underline my output.
I think there is a system variable for that, but not sure, see above.

Originally Posted by Brian.164262
And also have there be a maximum of two points. I have looked in help but I cannot find the varible settings how can I do that for any comand. Like (rtos x 4 2) or (osmode 4143).
If you only want two points, then in the code only allow the user to select two points, and then feed those points to the 'qleader' command to draw your leader.

Originally Posted by Brian.164262
I think it should go like (setvar "leader" 1 33 56) is something like that correct?
I have no idea what this is trying to do, but I hope I answered it by answering one of your other questions.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•