I’m trying to do 2 transforms with a list(of guid), but it will only do the 2nd transform. What am I doing wrong?
For Each item As Guid In GuidList
doc.Objects.Transform(item, Rhino.Geometry.Transform.Mirror(plane), True)
doc.Objects.Transform(item, Rhino.Geometry.Transform.Translation(New Rhino.Geometry.Vector3d(New Rhino.Geometry.Point3d(-centerx, -centery, 0))), True)
Next
Dim plane As New Rhino.Geometry.Plane(10, 0, 0, 0)
Dim transform As Geometry.Transform = Rhino.Geometry.Transform.Mirror(plane)
Dim transform2 As Geometry.Transform = Rhino.Geometry.Transform.Translation(New Rhino.Geometry.Vector3d(New Rhino.Geometry.Point3d(-centerx, -centery, 0)))
Dim combined As Geometry.Transform = transform * transform2
For Each item As Guid In GuidList
doc.Objects.Transform(item, combined, True)
Next
And still it will only do the last transform. Not move and mirror. But only Move OR mirror
I have very similar problem 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;
After the first transform the rhobj1 reference is lost.
Solution: Use the guid of the object instead of the objref:
doc.Objects.Transform(rhobj1, currentTransform, true);