Hi diff, thank-you for your response. I don’t think this solution is what I need because it requires me to know the radius of the arc I am creating. I have looked at the documentation and don’t see any options for what I need. I even tried creating an arc with 2 points and a vector but that didn’t seem to work either.
Here is what I am trying to accomplish. I have a file that supplies the Start Point, the End Point and the Centre of the radius, and whether it is CW or CCW and I am trying to create geometry from the information in this file(it is building a cutting tool for a cam software) The Arc command that uses Centre,Start,Angle works perfect when manually creating arcs because I can control which side the arc is on, but when ran in a script I don’t know how to control whether it is cw or ccw. I have just been using
rhinoscriptsyntax.Command() with the points from the file as the parameters passed in and it works right about 95% of the time, which is great, but not when processing hundreds of files. If you have any other ideas I am all ears, thank-you again for taking the time to help me!
Well, maybe I’m not understanding this correctly, but if you have an arc center, start, end, it doesn’t need CW or CCW information to be created - there is only one single arc that has the specified center that starts at the start point and ends at the end point - the radius being fixed as the distance from center to start. Whether it’s CW or CCW will just depend on which side you’re looking at it from…
Edit: my brain is not working correctly here - too early on a Saturday morning… There are of course two arcs possible, one less than or equal to 180° and the other one its complement. So, we can ad the CW/CCW specification to the code below:
So, for example, using the Arc constructor Start, tangent at start, end:
We assume that the start tangent is perpendicular to the arc plane’s X-Axis, i.e. the Y-Axis vector. All you need to do is create the plane first, then the arc. As the arc is normally created CCW in the arc plane, all we need to do later is reverse the arc tangent direction to get the CW arc possibility, I will do this with a True (CW) / False (CCW) flag in the method.
import rhinoscriptsyntax as rs
import scriptcontext as sc
#if cw is true, invert the tangent vector, the arc goes the other way
if cw: start_tan_vec=-start_tan_vec
The above numbers make a 30° arc of radius 25 centered at 10,10,0 (World Top) starting at 30° to the horizontal and going CCW, but you can plug in any numbers you like. If you pass the argument True for cw, you will get the 330° CW arc instead.
It also works in different planes, for example these numbers will make a 90° radius 25 arc, CW viewed from Front, centered at 0 and starting at X-25. If you pass the True argument, you will get the 270° arc instead, CCW when viewed from the Front.
Thank-you so much for this, this is exactly what I was looking for. Interestingly, I didn’t end up using the CW and CCW call-outs from the file, just creating them with the argument of False worked every time. I ran 169 files through and they were perfect. Using the CW/CCW callouts actually caused it to create the wrong arcs. Now I will have some fun playing with different planes and finding exactly when and why I would use the CW/CCW call-outs from the file! Thank-you again for your time and expertise!
Hmm, I guess in that case that all of the arcs were in the same plane and less than or equal to 180° - maybe… The CW and CCW in the file are perhaps just indications of whether the original command was G2 or G3.