I’m having issues with nothing from the display conduit showing up. This is copy/pasted from the samples. Some stuff is confusing me including the fact that the class has no constructor. I’m just getting back into this.
I’m having similar issues with other samples where I can’t get a dynamic object to show up. I’m seeing different approaches and therefore curious about best practices as well.
Note that I’m running this in the script editor. I’m pretty okay getting these to work when they actually throw an error, but but all the coffee in the world won’t allow me to get the display conduits working.
from Rhino import *
from Rhino.DocObjects import *
from Rhino.Geometry import *
from Rhino.Commands import *
from Rhino.Input.Custom import *
from System.Drawing import Color
def RunCommand():
gp = GetDrawStringPoint()
gp.SetCommandPrompt("Point")
gp.Get()
return gp.CommandResult()
class GetDrawStringPoint(GetPoint):
def OnDynamicDraw(self, e):
xform = e.Viewport.GetTransform(CoordinateSystem.World, CoordinateSystem.Screen)
current_point = e.CurrentPoint
current_point.Transform(xform)
screen_point = Point2d(current_point.X, current_point.Y)
msg = "screen {0}, {1}".format(screen_point.X, screen_point.Y)
e.Display.Draw2dText(msg, Color.Blue, screen_point, False)
if __name__ == "__main__":
RunCommand()
Using the Script Editor I need to use IronPython for your first sample (which makes sense, our older python samples are all IronPython). And it works well for me, I can see some live coordinates in blue as I move my cursor in the GetPoint operation.
Your updated code works only in Python 3 for me, but works well! I get the same coordinates drawn and end up with a circle.
Do you not see the blue coordinates in your viewport? Or you’d like to achieve this kind of stuff in a constant DisplayConduit?
I’m trying to do all sorts of stuff and also went down a pretty deep rabbit hole. The main goal was to convert a C# command to Python. That proved way too hard for me just getting back into coding, so I tried easier and easier stuff. I’m finding lots of stuff doesn’t work and also know that there’s probably a ‘best’ way.
The end goal will be to figure out how to preview stuff - just like the display pipeline does but it doesn’t have to be via the display pipeline (unless it does of course… which I wouldn’t know yet). If I were able to generate preview geometry from a GetPoint call using Rhinoscriptsyntax to draw objects, that would be perfect, but I don’t think it’s possible. Next would be to create Rhino Objects instead of display pipeline ‘objects’. And lastly, I could just learn more about display pipeline and incorporate any standards/styles around that (I do see there’s an DrawBlockInstance method that would cover a lot of use cases).
TLDR: Just looking for a good solid example of this using Python 3 - maybe one with getting multiple points and using display pipeline.
I converted this C# sample to Python3. Display Conduits are not entry level (imo) in C#, and in Python they make my head hurt.
Note that when this sample is run, the conduit will run until Rhino ends, it is only a sample to show how they run. You need the script to run constantly to keep a handle on it so you can close the Conduit when you’re done.
I think having both good code, and translation from C# to Python will be invaluable going forward. Your code will probably be much closer to my end goal. Thank you so much!
My code was just keyboard mashing rather than throwing any real skill or intelligence at the problem. If it works it works though right?