Rhino Grease Pencil


#1

I’d like to make either a script or plugin for Rhino that works like Blender’s Grease Pencil

I looked if I could utilise selbrush’s method of drawing on the screen but that doesn’t seem to be easily accessible by code. Selbrush would work perfectly if It could draw separate lines and hang on the screen to take a screenshot of.

Next I tried using rs.GetCursorPos() in python, but I think that would need an on mouse event function to click start and end lines… I read that I’d need to make a proper plugin to utilise this.

Before I go ahead and try developing full on plugin, will this actually (or easily) be possible?

Cheers
Alasdair


Grease pencil tool (like in Blender...)
(Nathan 'jesterKing' Letwory) #2

Grease Pencil in Blender is great, I used to use it a lot.

To implement something like that I’d add create a custom user data in which to record strokes as curves. In a display conduit you’d draw these curves.

I am not sure where I’d put the user data. Document makes sense for global penciling, but one could also attach it to an object, based on selection.

Some utility function to convert the strokes as actual rhino objects to the document would be very useful.

Good luck with your endeavour!

/Nathan

P.S. with Rhino 6 out it makes sense to create such a plug-in for that!


#3

Glad its possible but it sounds a bit out of my depth at the moment… I’ll see how far I get

Thanks!


#4

Is there a way to clear all DrawForeground conduits?

I’m using DisplayPipeline.Draw2dLine, and on OnMouseMove I make a new conduit. I was hoping that giving the same name to a conduit would add to that conduit, but I think it makes a new instance? When I disable the conduit and set it to null it only removes the most recent line.


(Nathan 'jesterKing' Letwory) #5

Hmm, instead of adding continuosly new conduits perhaps only have one instead? You probably should toggle your grease pencilling support like http://developer.rhino3d.com/samples/rhinocommon/overlay-text-display-conduit/ Would that makre more sense?

You’d probably start tracking drawn curves while your command and conduits are active, collect the generated curves and draw them in the one conduit.


#6

If we start tracking mouse movements then drawing at the end, I imagine this won’t be as intuitive as drawing a curve in real-time.

I’ve tried adding points to a Rhino.Collections.Point3dList and then redrawing all the points each time onMouseMove is called, but this is significantly slower than making a new conduit each time onMouseMove is called.


(Nathan 'jesterKing' Letwory) #7

You probably could set up your data structures so that you draw only the newly added stuff, without clearing existing drawn lines. Could that work?


#8

@nathanletwory how do you add to an existing conduit, without clearing and redrawing?
Cheers