public static Rhino.Commands.Result Twist(Rhino.RhinoDoc doc) { ObjectType filter = SpaceMorphObjectFilter(); Rhino.DocObjects.ObjRef objref; Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select object to twist", false, filter, out objref); if (rc != Rhino.Commands.Result.Success || objref == null) { return(rc); } Rhino.Geometry.Line axis; rc = Rhino.Input.RhinoGet.GetLine(out axis); if (rc != Rhino.Commands.Result.Success || axis == null) { return(rc); } double angle = Rhino.RhinoMath.UnsetValue; rc = Rhino.Input.RhinoGet.GetNumber("Twist angle in degrees", false, ref angle); if (rc != Rhino.Commands.Result.Success || !Rhino.RhinoMath.IsValidDouble(angle)) { return(rc); } Rhino.Geometry.Morphs.TwistSpaceMorph morph = new Rhino.Geometry.Morphs.TwistSpaceMorph(); morph.TwistAxis = axis; morph.TwistAngleRadians = Rhino.RhinoMath.ToRadians(angle); Rhino.Geometry.GeometryBase geom = objref.Geometry().Duplicate(); if (morph.Morph(geom)) { doc.Objects.Add(geom); doc.Views.Redraw(); } return(Rhino.Commands.Result.Success); }
public static Rhino.Commands.Result Twist(Rhino.RhinoDoc doc) { ObjectType filter = SpaceMorphObjectFilter(); Rhino.DocObjects.ObjRef objref; Rhino.Commands.Result rc = Rhino.Input.RhinoGet.GetOneObject("Select object to twist", false, filter, out objref); if (rc != Rhino.Commands.Result.Success || objref == null) return rc; Rhino.Geometry.Line axis; rc = Rhino.Input.RhinoGet.GetLine(out axis); if (rc != Rhino.Commands.Result.Success || axis == null) return rc; double angle = Rhino.RhinoMath.UnsetValue; rc = Rhino.Input.RhinoGet.GetNumber("Twist angle in degrees", false, ref angle); if (rc != Rhino.Commands.Result.Success || !Rhino.RhinoMath.IsValidDouble(angle)) return rc; Rhino.Geometry.Morphs.TwistSpaceMorph morph = new Rhino.Geometry.Morphs.TwistSpaceMorph(); morph.TwistAxis = axis; morph.TwistAngleRadians = Rhino.RhinoMath.ToRadians(angle); Rhino.Geometry.GeometryBase geom = objref.Geometry().Duplicate(); if (morph.Morph(geom)) { doc.Objects.Add(geom); doc.Views.Redraw(); } return Rhino.Commands.Result.Success; }