Results 1 to 9 of 9

Thread: Distance from circle to circle

  1. #1
    Member
    Join Date
    2008-03
    Posts
    9

    Question 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

    Attached Files Attached Files
    Last edited by Opie; 2008-04-23 at 04:05 PM. Reason: [CODE] tags added, see Moderator Note

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043

    Default 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. #3
    I could stop if I wanted to
    Join Date
    2003-11
    Posts
    277

    Default 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
    Quote Originally Posted by Brian.164262 View Post
    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. #4
    Member
    Join Date
    2008-03
    Posts
    9

    Default 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. #5
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043

    Default Re: Distance from circle to circle

    Quote Originally Posted by Brian.164262 View Post
    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.


    Quote Originally Posted by Brian.164262 View Post
    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. #6
    Member
    Join Date
    2008-03
    Posts
    9

    Smile 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"))
      )  
    )
    Last edited by Opie; 2008-04-23 at 04:05 PM. Reason: [CODE] tags added, see Moderator Note

  7. #7
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043

    Default 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. #8
    Member
    Join Date
    2008-03
    Posts
    9

    Default 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. #9
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043

    Default Re: Distance from circle to circle

    Quote Originally Posted by Brian.164262 View Post
    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

    Quote Originally Posted by Brian.164262 View Post
    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.

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

    Quote Originally Posted by Brian.164262 View Post
    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.

    Quote Originally Posted by Brian.164262 View Post
    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.

Similar Threads

  1. How to Constrain circle with another circle
    By ljupadhyay in forum Revit Architecture - Families
    Replies: 10
    Last Post: 2010-10-05, 03:12 PM
  2. Dimension from face of circle to face of circle?
    By ljlange in forum Revit Architecture - General
    Replies: 1
    Last Post: 2009-10-18, 04:45 PM
  3. How to determine linear distance of a divided circle
    By roxford in forum AutoCAD Map 3D - General
    Replies: 2
    Last Post: 2006-12-06, 03:12 AM
  4. Circle Polyline (ie Circle with Width)
    By johan d in forum AutoCAD General
    Replies: 4
    Last Post: 2006-02-03, 10:16 PM
  5. CIRCLE.SHX
    By JAY.69561 in forum CAD Management - General
    Replies: 5
    Last Post: 2005-05-24, 05:01 PM

Posting Permissions

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