Attempt to Transform in Custom Derived GetPoint class

Dear Rhino5 Developer Ninjas

I am trying to do a dynamic transformation of objects such as curves, and am indeed successful utilizing the custom overriden methods shown here.
http://wiki.mcneel.com/developer/rhinocommonsamples/rhinogettransform

I was originally trying to do this behavior in a custom overriden GetPoint class which had this method.

protected override void OnDynamicDraw(GetPointDrawEventArgs e)
 {

//dynamically move elements
            base.OnDynamicDraw(e);
            Point3d currentPoint = e.CurrentPoint; //Create the current point object (where the mouse is)
            Vector3d pointsVector = new Vector3d(currentPoint.X - hereOriginPoint.X, currentPoint.Y - hereOriginPoint.Y, currentPoint.Z - hereOriginPoint.Z);
            RhinoApp.WriteLine("PointsVector is {0}", pointsVector);
            Transform xform = Transform.Translation(pointsVector);

if (hereObjRef.Object().ObjectType == ObjectType.Curve)
            {
                ObjRef tempRef = hereObjRef;
                hereDoc.Objects.Transform(tempRef.ObjectId, xform, true);
                Curve tempCurve = tempRef.Curve();
                e.Display.DrawCurve(tempCurve, System.Drawing.Color.Black);
                e.Display.DrawPoint(tempCurve.PointAtStart, System.Drawing.Color.Black);
                e.Display.DrawPoint(currentPoint, System.Drawing.Color.Black);
            }
        }

I am able to see that the vector created calculates correctly, and also that the matrix inside the Transformation class is indeed changing, however the temporary Curve I have transformed to draw does not move dynamically as I thought it would. It does move with the overriden Transform Class that is in the example, however there are some additional things I am trying to do concurrently while dynamically transforming the objects, namely run some math and display some other things. I am a bit lost on the easiest way to implement this.

If possible I’d like to continue to utilize the custom GetPoint class that is basically overriden, and am not really sure why it is not displaying the curve dynamically with the current point of the OnDynamicDraw method. Thanks!!!

You should not be trying to transform a document object in the middle of a dynamic operation, as you will just fill up the undo stack (very quickly).

A better approach is to make a copy of the geometry and then transform and draw the copy.

Or better yet, just draw the original geometry using a transform, as demonstrated in this sample.

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

Thanks Dale,

Exactly the kind of feedback and example I was looking for. Much thanks.

Hi Dale,

Checking back on this this morning. I believe in the example I had posted I was in fact copying the object and then utilizing it’s geometry in TempCurve to translate. I can simply draw the object utilizing the DrawObject(RhinoObject , Transform) and that does work, however I need to do math on where the curve has been transformed to so I need to calculate the geometry after the transform or transform the object and then gets it’s geometry to utilize for the math.

I was not intending to “add the object” to Rhino, does the RhinoDoc.Object.Transform command in fact re-add it to the document?

Can you elaborate on this?

This changes the object in the document, yes.

In what way would you recommend doing a dynamic transformation on geometry or an object that is not present in a document that afterword could be tested against. I was attempting to avoid copying all the knots and control points and defining new geometry.

Inside of my dynamic drawing I can use a the RhinoCommon Curve.Transform function which will infact , but the other methods I am using are parsing through lists of RhinoObjects (which I don’t believe I can get the transformed geometry into a RhinoObject unless it’s added to the document first).

Is there any way without adding the geometry to the document to then be testing against the object from a RhinoObject point of view?