Problem with PointStyle when using DrawPoint()

Hi guys, I`m trying to learn how to use display conduit, and write a script to display a point in view.

import Rhino
import System.Drawing
import scriptcontext
import rhinoscriptsyntax as rs

class PointConduit(Rhino.Display.DisplayConduit):
    def __init__(self, pt):
        self.pt = pt
        print "conduit pt initialized"
    
    def DrawForeground(self, e):
   
        Pointstyle = 0
        print "set ps"
        radius = 15
        print "set radius"
        color =  System.Drawing.Color.Red
        print "set color"
        e.Display.DrawPoint(self.pt, Pointstyle, radius, color)
        print "draw dot"

def RunCommand():
    
    Point = Rhino.Geometry.Point3d(0,0,0)
    print Point
    
    conduit = PointConduit(Point)
    
    conduit.Enabled = True
    print "conduit enabled"
    scriptcontext.doc.Views.Redraw()
    rs.GetString("Pausing for user input")
    conduit.Enabled = False
    scriptcontext.doc.Views.Redraw()
    
    return Rhino.Commands.Result.Success
    
if __name__=="__main__":
    RunCommand()

This script works as I expected, but I then notice that when I change point style to other styles like 1(represent for ControlPoint),2(ActivePoint) and so on, the script stops display the point in view.

I`d like to ask what reason causes this problem? or is my understanding of point style wrong?

The style input to Rhino.Display.DrawPoint(..) expects an instance of the Rhino.Display.PointStyle enum.

Something like this should work:

class PointConduit(Rhino.Display.DisplayConduit):
    def __init__(self, pt):
        self.pt = pt
    
    def DrawForeground(self, e):
        style = Rhino.Display.PointStyle.X
        radius = 15
        color =  System.Drawing.Color.Red
        e.Display.DrawPoint(self.pt, style, radius, color)

Hi Pierre,

Thanks a lot for reply, it does work. Now I know how to use it, but allow me to ask furthermore.
In my original script, why does “pointstyle = 0” work? Does it mean setting pointstyle to default style?

Yes, zero is a default. This link is C# but I think it’s a .NET standard.

Enumeration types - C# reference - C# | Microsoft Learn

The default value of an enumeration type E is the value produced by expression (E)0 , even if zero doesn’t have the corresponding enum member.

Thanks Nathan, Seems like I need to learn C# after all.