generative modeling for Rhino
I am trying to give planes created in a scripted component a custom preview color. I've been looking through several posts regarding custom previews in VB/C# and it looks like the most helpful post may be:
But unfortunately not all of it makes sense to me and I'm not very familiar with C#.
It seems that I need to use the GH_Plane.DrawViewportWires method:
Public Sub DrawViewportWires( _
Is it as simple as going:
myPlane.DrawViewportWires(vp As , pl As , color As Color, thickness As Integer _ )
? If this is the case, I'm not sure how to say "all viewports" for vp, and I'm not sure what displayPipeline requires.
The posts I looked at made it seem like there is probably more to it (clipping boxes, etc.) but I'm not sure.
Also I just found this post:
Which sounds like the process is even simpler in .9?
Now the scripts actually derive from a class that has display logic build in
If anyone has any pointers, I'm all ears!
Made using the new display overrides in 0.9. This won't work on 0.8.0066. Also, it only ever accumulates planes, it never forgets about them, more code is needed.
Hey David, thanks.
I was wondering - is this:
For k As Int32 = -4 To 4
args.Display.DrawLine(P.PointAt(-4, k), P.PointAt(4, k), C)
args.Display.DrawLine(P.PointAt(k, -4), P.PointAt(k, 4), C)
actually drawing lines on top of the planes (one for each grid line within the plane)? Is this the approach the custom preview component takes? I'm just curious.
Also, is there a way to easily expose just the x and y axis as their uaual colors (so one can tell which way the plane is oriented)? My guess is you would have to treat the lines created in the middle of the loop to go from -4 to 0 instead of -4 to 4 (in order to expose 0 to 4).
Is this on the right track? I haven't had any time to play around with it yet.
Those lines are the only things drawn. It is actually not possible to use the GH_Plane drawing routines with custom wire colours due to cerain methods being internal to Grasshopper.dll.
But planes in Grasshopper are drawn just like that, except there's indeed a special case for the X and Y axes. If you keep it within a loop I suppose it would look something like this:
Dim extent As Integer = 4
For k As Int32 = -extent To extent
If (k = 0) Then
'Draw short gridlines
args.Display.DrawLine(P.PointAt(-extent, k), P.PointAt(0, k), C)
args.Display.DrawLine(P.PointAt(k, -extent), P.PointAt(k, 0), C)
args.Display.DrawLine(P.PointAt(0, k), P.PointAt(extent, k), DarkRed, 2)
args.Display.DrawLine(P.PointAt(k, 0), P.PointAt(k, extent), DarkGreen, 2)
args.Display.DrawLine(P.PointAt(-extent, k), P.PointAt(extent, k), C)
args.Display.DrawLine(P.PointAt(k, -extent), P.PointAt(k, extent), C)
Awesome that's great.
The only thing is that the lines sort of scintillate while orbiting. Is this the original planes showing through? Is there a way to set just those to not preview / be hidden?
If the original planes come from an input parameter that does not have any sources (i.e., the planes are defined internally) then they will be drawn as well, and they may well interfere with your own lines). You can quickly check this by changing the preview plane size and see if they still line up.
It is possible to hide specific input/output parameters on components, but if an input has been connected to a source, it won't show anyway.
I had responded to this post but shortly after solved my problems. I am actually curious about the above post - I am trying to hide a specific output parameter (in this case meshes). Within this scripted component I use drawMeshShaded to create a custom preview for these meshes. I would like to be able to see this custom preview, and output the actual meshes being previewed, but I don't want to see the output meshes (only the drawMeshShaded preview of them).
Is this possible?