Cursor guide possible?

In our CAM products (not RhinoCAM) we have the ability to display a “cursor guide” at the crosshair when creating curves to limit the toolpaths. This is very useful, but lacking in RhinoCAM. I’ve contacted Mecsoft and requested this as an enhancement for a future version.

However, it would be nice to emulate somehow right now. I’m at a loss as to how I could do something like this:

image

Basically it’s just a circle that follows the crosshair when creating a curves (polylines, rectangle, etc.). The only catch is that the size of the circle has to be user definable. Is this possible through RhinoCommon or am I hoping for too much?

Thanks,

Dan

Hi @DanBayn,

Is this helpful?

import Rhino
import scriptcontext as sc

class CrossHairGetPoint(Rhino.Input.Custom.GetPoint):
    def __init__(self, radius):
        self.m_radius = radius
        self.m_color = Rhino.ApplicationSettings.AppearanceSettings.CrosshairColor
    
    def GetPoint(self):
        old_setting = Rhino.ApplicationSettings.AppearanceSettings.ShowCrosshairs
        Rhino.ApplicationSettings.AppearanceSettings.ShowCrosshairs = True
        res = Rhino.Input.Custom.GetPoint.Get(self)
        Rhino.ApplicationSettings.AppearanceSettings.ShowCrosshairs = old_setting
        return res
            
    def OnDynamicDraw(self, e):
        plane = e.Viewport.ConstructionPlane()
        plane.Origin = e.CurrentPoint
        circle = Rhino.Geometry.Circle(plane, self.m_radius)
        e.Display.DrawCircle(circle, self.m_color)
        Rhino.Input.Custom.GetPoint.OnDynamicDraw(self, e)
        
def test_crosshair_getpoint():
    radius = 2.0
    gp = CrossHairGetPoint(radius)
    gp.SetCommandPrompt('Location of point object')
    gp.GetPoint()
    if gp.CommandResult() == Rhino.Commands.Result.Success:
        sc.doc.Objects.AddPoint(gp.Point())
    sc.doc.Views.Redraw()

if __name__ == "__main__":
    test_crosshair_getpoint()

– Dale

1 Like

Hi @dale ,

I have a pretty good feeling it will be. :smiley:

I’ll see what I can do with it in the morning.

Thanks,

Dan

Is it possible to keep the size of the radius constant regardless of the Zoom?

Hi @cristiano.pasini,

Here you go:

import Rhino
import scriptcontext as sc

class CrossHairGetPoint(Rhino.Input.Custom.GetPoint):
    def __init__(self, radius):
        self.m_radius = radius
        self.m_color = Rhino.ApplicationSettings.AppearanceSettings.CrosshairColor
    
    def GetPoint(self):
        old_setting = Rhino.ApplicationSettings.AppearanceSettings.ShowCrosshairs
        Rhino.ApplicationSettings.AppearanceSettings.ShowCrosshairs = True
        res = Rhino.Input.Custom.GetPoint.Get(self)
        Rhino.ApplicationSettings.AppearanceSettings.ShowCrosshairs = old_setting
        return res
            
    def OnDynamicDraw(self, e):
        screen_cs = Rhino.DocObjects.CoordinateSystem.Screen
        world_cs = Rhino.DocObjects.CoordinateSystem.World
        s2w = e.Viewport.GetTransform(screen_cs, world_cs)
        plane = e.Viewport.ConstructionPlane()
        dir = s2w * (plane.XAxis * self.m_radius)
        plane.Origin = e.CurrentPoint
        circle = Rhino.Geometry.Circle(plane, dir.Length)
        e.Display.DrawCircle(circle, self.m_color)
        Rhino.Input.Custom.GetPoint.OnDynamicDraw(self, e)
        
def test_crosshair_getpoint():
    radius = 20 # pixels
    gp = CrossHairGetPoint(radius)
    gp.SetCommandPrompt('Location of point object')
    gp.GetPoint()
    if gp.CommandResult() == Rhino.Commands.Result.Success:
        sc.doc.Objects.AddPoint(gp.Point())
    sc.doc.Views.Redraw()

if __name__ == "__main__":
    test_crosshair_getpoint()

– Dale

1 Like

Perfect ! ! !

Thanks ! ! !