Hi,
I’m trying to use a display conduit to show progress on a script that involves drawing many many curves in succession. I’ve looked at the really basic sdk example about drawing an arrow, but I can’t figure out the general procedure for updating the list of objects in the conduit, all that I got to work in any way was to make an all-new conduit object every time through the loop and feed the current list of stuff to draw in to its constructor, which of course means all the previous results are shown also…which is possibly interesting now that I think of it but not the goal.
Thanks,
Jim
Hi Jim,
I extracted the following sample from one of the animations I did awhile back… Maybe it helps.
Cheers, --Mitch
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino, System, time
class DrawTextConduit(Rhino.Display.DisplayConduit):
#args: point(insertion),text,color,height,font
def __init__(self,point,text,tCol,tHt,font):
self.point = point
self.text = text
self.tCol = tCol
self.tHt = tHt
self.font = font
self.bbox = Rhino.Geometry.BoundingBox()
self.bbox.Union(point)
def CalculateBoundingBox(self, e):
e.IncludeBoundingBox(self.bbox)
def DrawOverlay(self, e):
#True=centered
e.Display.Draw2dText(self.text,self.tCol,self.point,True,self.tHt,self.font)
dotPt=rs.coerce3dpoint([0,0,0])
tColor=System.Drawing.Color.FromArgb(0,255,191,0)
fontHt=24
fontName="Arial"
data=["My","name","is","Jim","Carruthers"]
for i in range(len(data)):
name=data[i]
#send info to conduit to draw text
conduit = DrawTextConduit(dotPt,name,tColor,fontHt,fontName)
conduit.Enabled = True
sc.doc.Views.Redraw()
time.sleep(1)
conduit.Enabled = False
sc.doc.Views.Redraw()
1 Like
Thanks Mitch, I did get it working…I think half the problem was that it seems mucking about with this stuff means Rhino needs to be rebooted between running test scripts, I wonder what I can clean up to try to avoid that?