Dynamic Draw of surfface/plane

Hi,

Can someone provide simple example how to do dynamic draw of a plane, based on 3 points please? My knowledge in this area is very poor.
I’ve seen some examples how to do the lines, but still, can’t figure out how to use it for plane.

A plane as a surface or a plane as yeah. a plane xD

As a plane from 3 points.

Is this what you want to do?

Rhino.Geometry.Plane plane;
Rhino.Input.RhinoGet.GetPlane(out plane);

No, this is not what I’m looking for.
I need to dynamically draw maybe even not a plane, but projected curve, before I will accept final result of projection. SO I have something like this:

Rhino.Display.DisplayPipeline.DrawOverlay += (sender, e) => e.Display.DrawCurve(projected[0], Color.AntiqueWhite);

but it doesn’t redraw projection result whenever I move the mouse. So how can I acheve this? How to dynamically see projection result before accepting final 3rd point?

Here is also piece of ugly not working code, that I have created, can any one help with this please?

        const ObjectType geometryFilter = ObjectType.Surface;

        GetObject go = new GetObject();
        go.SetCommandPrompt("Select surfaces");
        go.GeometryFilter = geometryFilter;

        GetResult res = go.GetMultiple(1, 0);
        RhinoObject rhinoObject = go.Object(0).Object();

        var brep = rhinoObject.Geometry as Brep;

        RhinoApp.WriteLine("The {0} command will add a line right now.", EnglishName);

        Point3d pt0;
        using (GetPoint getPointAction = new GetPoint())
        {
            getPointAction.SetCommandPrompt("Please select the start point");
            if (getPointAction.Get() != GetResult.Point)
            {
                RhinoApp.WriteLine("No start point was selected.");
                return getPointAction.CommandResult();
            }
            pt0 = getPointAction.Point();
        }

        Point3d pt1;
        using (GetPoint getPointAction = new GetPoint())
        {
            getPointAction.SetCommandPrompt("Please select 2nd point");
            if (getPointAction.Get() != GetResult.Point)
            {
                RhinoApp.WriteLine("No 2nd point was selected.");
                return getPointAction.CommandResult();
            }
            pt1 = getPointAction.Point();
        }


        var line = new Line(pt0, pt1);
        var curve = line.ToNurbsCurve() as Curve;
        var tolerance = 0.01;

        Point3d pt2;
        using (GetPoint getPointAction = new GetPoint())
        {
            getPointAction.SetCommandPrompt("Please select the end point");
            getPointAction.SetBasePoint(pt1, true);

            if (getPointAction.Get() != GetResult.Point)
            {
                RhinoApp.WriteLine("No end point was selected.");
                return getPointAction.CommandResult();
            }

            while (getPointAction.Get() != GetResult.Nothing)
            {
                pt2 = getPointAction.Point();

                Vector3d vector3d = new Vector3d(pt2.X - pt1.X, pt2.Y - pt1.Y, pt2.Z - pt1.Z);
                var projectedCurves = Curve.ProjectToBrep(curve, brep, vector3d, tolerance);

                foreach (var projected in projectedCurves)
                {
                    Rhino.Display.DisplayPipeline.DrawOverlay += (sender, e) => e.Display.DrawCurve(projected[0], Color.AntiqueWhite);
                }

                //doc.Objects.AddCurve(projected[0]);
                doc.Views.Redraw();
            }
        }

These type of drawing is better off in a custom GetPoint class that overrides OnMouseMove and DynamicDraw.

See if this example is of any help.

https://github.com/dalefugier/SampleCsCommands/blob/master/SampleCsOrientPerpendicularToCurve.cs

This will do just fine, thanks :slight_smile:

I there a current version of this example?

Here is the source:

https://github.com/mcneel/rhino-developer-samples/blob/master/rhinocommon/cs/SampleCsCommands/SampleCsOrientPerpendicularToCurve.cs

Does this help?

1 Like

yes, thank you. At some point I’m hoping I can quit copying and start understanding. Is there a hidden c# noob section? :slight_smile:

Does this help?

– Dale