CustomPointObject OnDraw method issue

Hello,

I have a CustomPointObject class named OriginPointObject. I override the OnDraw method, drawing a circle whenever the point is selected. The circle lies on a BasePlane, which is attached to OriginPointObject as a custom UserData. The problem I have is that the drawn geometry gets cut off when I zoom in, or make a copy of the point. I am guessing this is an issue with the BoundingBox, but is there a way I can recalculate the BBox without creating another DisplayConduit class ? Or is something else the matter ? Any suggestions/ solutions would be appreciated. I have attached code and a video of the problem.

        protected override void OnDraw(DrawEventArgs e)
        {
            if (IsSelected(false) == 2)
            {
                var ud = this.Attributes.UserData.Find(typeof(OriginUserData)) as OriginUserData;        
                e.Display.DrawCircle(new Circle(ud.BasePlane, 5), System.Drawing.Color.Red);
            }
            base.OnDraw(e);
        }

Error

Thanks

Hi @bovasbenjacob,

Custom object types, in RhinoCommon, lack overrides that allow you to provide the correct bounding box for your object. The the clipping issue.

https://mcneel.myjetbrains.com/youtrack/issue/RH-67438

The solution, today, is to not use a custom object. Instead, just draw your point object using a display conduit.

– Dale

1 Like

Thank you for the clarification!

Hi, I am also trying to achieve the effect you have implemented in the gif, but whenever I move the CustomCueve, I always get System.NullReferenceException error, can you share the complete code?
This is the code I wrote

        protected override void OnDraw(DrawEventArgs e)
        {
            var data = this.Attributes.UserData.Find(typeof(AnnotationData)) as AnnotationData;
            text = TextEntity.Create("±0.000", data.plane, data.dimstyle, false, 0, 0);
            e.Display.DrawText(text, System.Drawing.Color.Red);
            base.OnDraw(e);
        }

        protected override void OnTransform(Transform transform)
        {
            Data.plane.Transform(transform);
            text = TextEntity.Create("±0.000", Data.plane, Data.dimstyle, false, 0, 0);
        }

can you give some advise? @dale @bovasbenjacob

Hi @Fan ,
It has been a while since I worked on this and sharing some more of your code could be helpful. But if I were to make a guess, it could be that the OnDuplicate() override is being called before OnTransform, and you might need to pass along the data to a new instance. I am not sure about this, so do test it out. Also check what exactly is null.

Thanks for the advice, I’ll give it a try!

RH-67438 is fixed in Rhino 8 Service Release 3 Release Candidate