Rotate circle2 around circle1.

Discussion in 'AutoCAD' started by MiD-AwE, Apr 8, 2005.

  1. MiD-AwE

    MiD-AwE Guest

    Help. please.
    I need some slick help with this sweet idea.

    I need to draw a 3pt circle<c1> & capture the RADIUS to a variable (which must be rounded off to a 6" increment) and delete the circle<c1>.
    Then, I need to prompt the user to select an existing circle<c2>, single select only, and draw a 2pt circle<c3> from the 0-degree QUADRANT of the selected circle<c2> @ the RADIUS captured in the variable.
    Finally, I need to draw an identical circle<c4> from the 0-degree QUADRANT of the previous circle<c3> & delete circle<c3>.
    Now, having only circles <c2> & <c4> remaining on the screen, I need to enter into the rotate command & allow the user to rotate circle<c4> from the CENTER point of circle<c2> with the cursor until the user mouse clicks.
    I hope that I was clear enough in the description. I'll bet that this is not as difficult as it sounds but I'm still green when it comes to lisp. I have been trying to get this one right & I've learned a lot from this news group, but I don't know how to get the QUADRANT of a circle, or the RADIUS of a circle. I read some stuff about (POLAR) but didn't understand how to get the 0-degree QUADRANT.
    Please, someone looking for a challenge or just feeling generous even if I can invoke some pity, please help me.
    Thank you in advance for any and all help.
     
    MiD-AwE, Apr 8, 2005
    #1
  2. MiD-AwE

    Adesu Guest

    Hi MiD-AwE ,sorry I only answer for this your ask "but I don't know how to
    get the QUADRANT of a circle"

    (setq loc '(0 0 0))
    (setq rad 5)
    (command "_circle" loc rad "")
    (setq ss (entget (entlast)))
    (setq sp (cdr (assoc 10 ss)))
    (setq qu (polar sp 0 rad))
    (setq osm (getvar "osmode"))
    (setvar "osmode" 16)
    (setq equ (osnap qu "_qua"))
    (setvar "osmode" osm)



    not as difficult as it sounds but I'm still green when it comes to lisp. I
    have been trying to get this one right & I've learned a lot from this news
    group, but I don't know how to get the QUADRANT of a circle, or the RADIUS
    of a circle. I read some stuff about (POLAR) but didn't understand how to
    get the 0-degree QUADRANT.
    can invoke some pity, please help me.
     
    Adesu, Apr 8, 2005
    #2
  3. MiD-AwE

    MiD-AwE Guest

    Hey, thank you. Any and all help is greatly appreciated. I'll post any progress for everyone. Let me test this.

    Thanks again, please any more help
     
    MiD-AwE, Apr 8, 2005
    #3
  4. MiD-AwE

    T.Willey Guest

    Is this something like what you want? No error checking.

    Tim

    (defun c:CirDraw (/ Cir1 Rad1 Cir2 Rad2 Cnt2 Cnt3 Dist1 CurSpace tmpEnt ss)

    (command "_.circle" "_3p" pause pause pause)
    (setq tmpEnt (entlast))
    (setq Cir1 (vlax-ename->vla-object tmpEnt))
    (setq Rad1 (vla-get-Radius Cir1))
    (vla-Delete Cir1)
    (setq Dist1 (* 2 Rad1))
    (setq ss (ssget ":S:E" '((0 . "CIRCLE"))))
    (setq tmpEnt (ssname ss 0))
    (setq Cir2 (vlax-ename->vla-object tmpEnt))
    (setq Rad2 (vla-get-Radius Cir2))
    (setq Cnt2 (vlax-get Cir2 'Center))
    (setq Cnt3 (polar Cnt2 0.0 Dist1))
    (setq CurSpace (GetCurrentSpace (vla-get-ActiveDocument (vlax-get-Acad-Object))))
    (vla-AddCircle CurSpace (vlax-3d-point Cnt3) Rad1)
    (command "_.rotate" (entlast) "" Cnt2 pause)
    )

    (defun GetCurrentSpace (Doc / BlkCol SpaceList CurSpace ActSpace temp1)
    ; Returns the "block object" for the active space
    ; Thanks to Jason Piercey
    ;(defun activeSpaceObject (document) His Name for it

    (vla-get-block
    (vla-get-activelayout Doc)
    )
    )
     
    T.Willey, Apr 8, 2005
    #4
  5. You don't need to use Quadrant osnap at all, if you know the center point
    and radius of the circle.
    (polar <center-point> <0-degree-direction> <radius>) will put you at the
    quadrant point without osnap.
     
    Kent Cooper, AIA, Apr 8, 2005
    #5
  6. Tim beat me to it, but some things there look overly complicated, and it
    doesn't seem to account for rounding off the radius of the first circle.
    I'm assuming you want the 3-point circle to be drawn within the routine, and
    that rounding off to a 6" increment means rounding to the closest one (up or
    down). You can skip some of your steps and do what you want a little more
    directly, that is, draw your c4 circle right where you want it in the first
    place.

    (command "circle" "3p" pause pause pause); get user to draw the circle
    (setq circradius (cdr (assoc 40 (entget (entlast))))); save its radius
    (entdel (entlast)); get rid of the circle*
    (if (< (rem circradius 6) 3) (setq round 0) (setq round 1)); find whether 6"
    increment remainder requires rounding down or up
    (setq circdia (* (+ circradius round) 2)); apply rounding to radius and turn
    it into a diameter, since that's what you need for 2-point circles
    (setq circexist (entget (car (entsel "Select Existing Circle: ")))); ask
    user to select circle and save its association list
    (command "circle" "2p"
    (polar
    (cdr (assoc 10 circexist))
    0
    (+ (cdr (assoc 40 circexist)) circdia)
    )
    (polar
    (getvar "lastpoint")
    0
    cirdia
    ); draw your c4 circle directly in place, skipping the c3 circle entirely
    (command "rotate" (entlast) "" (cdr (assoc 10 circexist)) pause)

    * To get rid of the first circle, you could also do (command "erase" "l"
    ""), or even just (command "u") -- it undoes the circle but doesn't
    eliminate the saving of its radius value.
     
    Kent Cooper, AIA, Apr 8, 2005
    #6
  7. MiD-AwE

    T.Willey Guest

    Good point Kent. I did forget about rounding the radius to an increment of 6".

    Tim
     
    T.Willey, Apr 8, 2005
    #7
  8. MiD-AwE

    MiD-AwE Guest

    Wow, looks good but The resulting rotating circle needs to end up tangent to the selected circle. Is that possible? I imagine the problem is in the rounding off to the 6" increment.

    Thanks for your help.
     
    MiD-AwE, Apr 8, 2005
    #8
  9. MiD-AwE

    T.Willey Guest

    I had my math wrong. The new center point should have been (setq Dist1 (+ Rad1 Rad2)). So that is fixed, and the rounding issue is also. You still need the other sub, but that hasn't changed so I'm just posting the new version.

    Tim

    (defun c:CirDraw (/ Cir1 Rad1 Cir2 Rad2 Cnt2 Cnt3 Dist1 CurSpace tmpEnt tmpRad ss)

    (command "_.circle" "_3p" pause pause pause)
    (setq tmpEnt (entlast))
    (setq Cir1 (vlax-ename->vla-object tmpEnt))
    (setq Rad1 (vla-get-Radius Cir1))
    (vla-Delete Cir1)
    (while (/= (setq tmpRad (rem Rad1 6)) 0)
    (if (> tmpRad 3)
    (setq Rad1 (+ tmpRad Rad1))
    (setq Rad1 (- Rad1 tmpRad))
    )
    )
    (setq ss (ssget ":S:E" '((0 . "CIRCLE"))))
    (setq tmpEnt (ssname ss 0))
    (setq Cir2 (vlax-ename->vla-object tmpEnt))
    (setq Rad2 (vla-get-Radius Cir2))
    (setq Dist1 (+ Rad2 Rad1))
    (setq Cnt2 (vlax-get Cir2 'Center))
    (setq Cnt3 (polar Cnt2 0.0 Dist1))
    (setq CurSpace (GetCurrentSpace (vla-get-ActiveDocument (vlax-get-Acad-Object))))
    (vla-AddCircle CurSpace (vlax-3d-point Cnt3) Rad1)
    (command "_.rotate" (entlast) "" Cnt2 pause)
    )
     
    T.Willey, Apr 8, 2005
    #9
  10. MiD-AwE

    MiD-AwE Guest

    Amazing, I was wondering if this might become a theoretical project as some of mine become, but this is absolutely the best newsgroup I've ever seen. Thank you all for your help, including Jason Piercey for the sub. I'll be studying these examples for a while before I understand them thoroughly.
    Again, thank you all.
     
    MiD-AwE, Apr 8, 2005
    #10
  11. MiD-AwE

    MiD-AwE Guest

    Nice, I like the idea of skipping the c3 circle entirely. I thought that was possible but too tricky to describe clearly. I found an error in the code, (polar (getvar "lastpoint") 0 cirdia), should be (polar (getvar "lastpoint") 0 CIRCDIA), just a spelling correction. But, I can't find out why this one isn't drawing the resulting circle TANGENT to the existing circle. I'm stumped. I spent about an hour trying to figure it out but like I said previously I'll be studying this for quite awhile before I thoroughly understand all of it. Thanks again all.
     
    MiD-AwE, Apr 8, 2005
    #11
  12. MiD-AwE

    T.Willey Guest

    Glad it works the way you want it to. Sometimes that is the best way to learn, reading others code and looking the items up in the help within Acad. When Jason pointed that out to me I was so happy because my other routine for that was longer (Thanks again Jason).

    The code could be improved upon, like error checking and stuff like that.
    Tim
     
    T.Willey, Apr 8, 2005
    #12
  13. MiD-AwE

    Jeff Mishler Guest

    Just a bit of warning, the code Jason provided won't work correctly if you
    are working in MSpace thru a PSpace viewport. The ActiveSpace property will
    return the PS object. Using this function will solve that issue:

    (defun get_space (dwg)
    (if (= 1 (getvar "cvport"))
    (vla-get-paperspace dwg)
    (vla-get-modelspace dwg)
    )
    )
     
    Jeff Mishler, Apr 8, 2005
    #13
  14. MiD-AwE

    T.Willey Guest

    But you couldn't use that for ObjectDBX right? because you can't get variables? Not for this routine, but for others I have.

    Thanks for that tibbet Jeff.
    Tim
     
    T.Willey, Apr 8, 2005
    #14
  15. MiD-AwE

    Jeff Mishler Guest

    Correct, but then again in ObjectDBX the user won't be selecting objects,
    either. Also, when using ObjectDBX the programmer should know what space
    he's working in already, without the need for getting an ActiveSpace
    property. In fact, ODBX does not expose ANY Active* properties......
     
    Jeff Mishler, Apr 8, 2005
    #15
  16. MiD-AwE

    T.Willey Guest

    Good points. I thought I used that in one of my ODBX routines, but it seems that I didn't. I think I remember hearing about the not have access to any active* roperties, well now that you say it again I do

    Thanks for the clarification. Learn everyday. =D
    Tim
     
    T.Willey, Apr 8, 2005
    #16
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.