Moving rhino meshes in grasshopper

I have about 6000 meshes, each with textures. I want to move each object along a certain vector.

I cannot reference in the meshes, move them and use gh to reapply the textures, as about 2000 of the meshes are invalid (this does not mean they cannot exist within rhino).

So I just want to move them using GUID or other. There is a similar problem here, but I could not get it to work with meshes:

Essentially, the script would just move / relocate any given object (according to its GUID), without having to reference the object into GH.

Thanks for any help, Arkadius

private void RunScript(Guid id, Vector3d vec, ref object A)
{
  var objRef = new Rhino.DocObjects.ObjRef(id);
  vec += Point3d.Origin - objRef.Geometry().GetBoundingBox(true).Center;
  RhinoDocument.Objects.Transform(objRef, Transform.Translation(vec), true);
}

MoveMesh.gh (4.1 KB)

Hi Mahdiyar,

thanks for the response, but I am getting an error when I try to run the component

I think that it moves the objects, but to the origin plane first, here I have moved just two of the objects:

here I have tried to move all the objects, but it has taken their bounding box center, moved that to the origin of the file and then moved it in the Z direction:

private void RunScript(List<Guid> id, List<Plane> source, List<Plane> target, bool run, ref object A)
{
  if(run)
  {
    _guids = id;
    _sources = source;
    _targets = target;
    GrasshopperDocument.ScheduleSolution(200, SolutionCallBack);
  }
}
// <Custom additional code> 
List<Guid> _guids;
List<Plane> _sources, _targets;
void SolutionCallBack(GH_Document doc)
{
  for(var i = 0; i < _guids.Count; i++)
  {
    var objRef = new Rhino.DocObjects.ObjRef(_guids[i]);
    RhinoDocument.Objects.Transform(objRef, Transform.PlaneToPlane(_sources[i], _targets[i]), true);
  }
}
  // </Custom additional code> 

MoveMeshes.3dm (356.3 KB) MoveMeshes.gh (12.2 KB)

1 Like