| Author |
Message |
MiD-AwE
Guest
|
Posted:
Fri Apr 08, 2005 9:03 am Post subject:
Rotate circle2 around circle1. |
|
|
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.
|
|
| Back to top |
|
 |
Adesu
Guest
|
Posted:
Fri Apr 08, 2005 9:03 am Post subject:
Re: Rotate circle2 around circle1. |
|
|
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)
MiD-AwE <nospam@address.withheld> wrote in message
news:5814883.1112936796145.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | 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.
| Quote: | 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.
| Quote: | 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.
| Quote: | 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. |
|
|
| Back to top |
|
 |
MiD-AwE
Guest
|
Posted:
Fri Apr 08, 2005 6:41 pm Post subject:
Re: Rotate circle2 around circle1. |
|
|
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
|
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Fri Apr 08, 2005 7:15 pm Post subject:
Re: Rotate circle2 around circle1. |
|
|
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)
)
) |
|
| Back to top |
|
 |
Kent Cooper, AIA
Guest
|
Posted:
Fri Apr 08, 2005 7:17 pm Post subject:
Re: Rotate circle2 around circle1. |
|
|
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
"Adesu" wrote...
| Quote: | 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) |
|
|
| Back to top |
|
 |
Kent Cooper, AIA
Guest
|
Posted:
Fri Apr 08, 2005 8:02 pm Post subject:
Re: Rotate circle2 around circle1. |
|
|
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
"MiD-AwE" wrote...
| Quote: | 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. |
|
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Fri Apr 08, 2005 8:10 pm Post subject:
Re: Rotate circle2 around circle1. |
|
|
Good point Kent. I did forget about rounding the radius to an increment of 6".
Tim |
|
| Back to top |
|
 |
MiD-AwE
Guest
|
Posted:
Fri Apr 08, 2005 8:53 pm Post subject:
Re: Rotate circle2 around circle1. |
|
|
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. |
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Fri Apr 08, 2005 9:19 pm Post subject:
Re: Rotate circle2 around circle1. |
|
|
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)
) |
|
| Back to top |
|
 |
MiD-AwE
Guest
|
Posted:
Sat Apr 09, 2005 12:32 am Post subject:
Re: Rotate circle2 around circle1. |
|
|
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. |
|
| Back to top |
|
 |
MiD-AwE
Guest
|
Posted:
Sat Apr 09, 2005 12:39 am Post subject:
Re: Rotate circle2 around circle1. |
|
|
| 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. |
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Sat Apr 09, 2005 1:11 am Post subject:
Re: Rotate circle2 around circle1. |
|
|
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 |
|
| Back to top |
|
 |
Jeff Mishler
Guest
|
Posted:
Sat Apr 09, 2005 1:23 am Post subject:
Re: Rotate circle2 around circle1. |
|
|
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
check out www.cadvault.com
"T.Willey" <nospam@address.withheld> wrote in message
news:15412535.1112994695301.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | 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 |
|
|
| Back to top |
|
 |
T.Willey
Guest
|
Posted:
Sat Apr 09, 2005 1:38 am Post subject:
Re: Rotate circle2 around circle1. |
|
|
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 |
|
| Back to top |
|
 |
Jeff Mishler
Guest
|
Posted:
Sat Apr 09, 2005 2:01 am Post subject:
Re: Rotate circle2 around circle1. |
|
|
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
check out www.cadvault.com
"T.Willey" <nospam@address.withheld> wrote in message
news:3818852.1112996325418.JavaMail.jive@jiveforum2.autodesk.com...
| Quote: | 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 |
|
|
| Back to top |
|
 |
|
|
|
|