@Subir_Dutta wrote:
I have a with Transformation. I need to transform a selected object continuously in a loop as seen in the attached code. I am running the loop for 18 times and in each loop I am rotating the selected object by 10 degree around z axis ( 0,0,1). But even after doing lots of attempt in different permutation combination, I see only one transformation of 10 degree ( don't know the first or the last ) where as I expect the selected object to be finally rotated by 180 degree when the loop ends.
What might be issue ?
The code is as below.
public class TransFormTest : Command
{
...protected override Result RunCommand(RhinoDoc doc, RunMode mode) { Rhino.DocObjects.ObjRef rhobj1; var rc1 = RhinoGet.GetOneObject("Select Link One", true, Rhino.DocObjects.ObjectType.InstanceReference, out rhobj1); if (rc1 != Rhino.Commands.Result.Success) return rc1; currentTransform = Transform.Identity; for(int i = 1; i <= 18; i++) { TransformBrep(ref doc, rhobj1); //Thread.Sleep(100); } return Result.Success; }
public Rhino.Commands.Result TransformBrep(ref Rhino.RhinoDoc doc, Rhino.DocObjects.ObjRef rhobj1)
{double deg = 10.0; double rad = (22.0 / 7.0) / 180.0 * deg; Point3d cen = new Point3d(0,0,0); Transform xform = Rhino.Geometry.Transform.Rotation(rad, cen); currentTransform = currentTransform * xform ; //currentTransform = xform * currentTransform; // tried both doc.Objects.Transform(rhobj1, currentTransform, true); doc.Views.Redraw(); return Rhino.Commands.Result.Success; } Transform currentTransform;
}
Posts: 12
Participants: 2