Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5871

GetPoint.OnDynamicDraw with dynamic display within?

$
0
0

@dveenendaal wrote:

I was trying to get a dynamic display within Rhino.Input.Custom.GetPoint.OnDynamicDraw. The point would be to include an iterative process dependent on the mouse position, and show these iterations (e.g. mouse moves once, but as a result, geometry changes 10x, and I want to show that as an animation).

I was trying to achieve this by making OnDynamicDraw() recursive (couldn't get it to work) or opening a new conduit (also doesn't work like this). Any thoughts on how to make this work? I'm not a total noob at Python, but this level of Rhinocommon use is a bit beyond me.

import Rhino
import System.Drawing
import scriptcontext as sc

class GetLines(Rhino.Input.Custom.GetPoint):

    def OnDynamicDraw(self, args):
        for i in range(10):
            pt3 = Rhino.Geometry.Point3d(0,0,i)
            line = args.Display.DrawLine(pt3, args.CurrentPoint, System.Drawing.Color.Green, 2)

class GetLinesRecursive(Rhino.Input.Custom.GetPoint):

    def __init__(self):
        self.count = 0

    def OnDynamicDraw(self, args):

        print self.count

        if self.count < 10:
            pt3 = Rhino.Geometry.Point3d(0,0,self.count)
            line = args.Display.DrawLine(pt3, args.CurrentPoint, System.Drawing.Color.Green, 2)
            self.count += 1
            OnDynamicDraw(args)
        else:
            pass

class GetLinesConduit(Rhino.Input.Custom.GetPoint):

    def __init__(self):
        self.count = 0

    def OnDynamicDraw(self, args):

        while self.count < 10:
            pt3 = Rhino.Geometry.Point3d(0,0,self.count)
            conduit = DrawConduit(pt3, args.CurrentPoint, System.Drawing.Color.Green)
            conduit.Enabled = True
            sc.doc.Views.Redraw()
            conduit.Enabled = False
            self.count += 1

class DrawConduit(Rhino.Display.DisplayConduit):

    def __init__(self, pt3, pt4, color):
        self.pt3 = pt3
        self.pt4 = pt4
        self.color = color

    def DrawOverlay(self, args):
        args.Display.DrawLine(pt3, pt4, color, 2)

gp = GetLines()
gp.Get()

gp2 = GetLinesRecursive()
gp2.Get()

gp3 = GetLinesConduit()
gp3.Get()

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5871

Trending Articles