Rotate a block instance around fixed point

Hi,

I am working on a plugin for a company and one step in the plugin is to move many objects with x and y offset and with a rotation around the Z-axis.

The x and y offset was no problem with a translation transform. But I have problems with the rotation.
If I try to rotate the objects with GeometryBase.Geometry.Rotate(rad, Vector3D.ZAxis, referencePoint),
it will rotate all reference instances right but my block instances stay the same.

Is there a way to rotate blockinstances around a point is my question?

My code example that doesn’t work for me.

RhinoGet.GetMultipleObjects("Select objects to move or none to move all", true, ObjectType.AnyObject, out ObjRef[] refs);

List<RhinoObject> objectsToMove = (refs != null)?refs.ToList().ConvertAll(rRef => rRef.Object()).ToList():doc.Objects.GetObjectList(ObjectType.AnyObject).ToList();

foreach(var obj in objectsToMove)
{
        obj.Geometry.Rotate(DegToRad(inst.ZRotOffset ?? 0), Vector3d.ZAxis, inst.ReferencePoint);
        obj.CommitChanges();
}
doc.Views.Redraw();

I also tried to first declare the InstanceObjects as InstanceObjects in the code but that also didn’t work out for me.

Does anyone know a solution?

Hi @ian6,

Does this help?

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  var result = RhinoGet.GetMultipleObjects("Select objects", false, ObjectType.AnyObject, out ObjRef[] objrefs);
  if (result != Result.Success)
    return result;

  var xform = Transform.Rotation(RhinoMath.ToRadians(45.0), Vector3d.ZAxis, Point3d.Origin);
  foreach (var objref in objrefs)
    doc.Objects.Transform(objref.ObjectId, xform, true);
  
  doc.Views.Redraw();

  return Result.Success;
}

– Dale

Hi @dale,

This works for me! Thanks!