cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Option to physically separate copies where "Delete and Copy" is used in a parameter table

Option to physically separate copies where "Delete and Copy" is used in a parameter table

Currently when the "delete and copy" option is used for objects whose quantity is in a parameters table, the copies are on top of each other in the 3D space. I would suggest that there be an option to space them out using X, Y and maybe Z offsets based on the position of the original. The total offset is the copy number times the entered offset value. I modified the code as if there were X, Y and Z offsets available in the edit window. There is likely a more elegant way of doing this maybe with Vec3 :

treenode reference = param(1);
Variant newValue = param(2);
Variant oldValue = param(3);
Variant X_offset = param(4);
Variant Y_offset = param(5);
Variant Z_offset = param(6);
int isReset = param(7);

{ // ************* PickOption Start ************* //
/***popup:ParamSetNodeValue*/
/**Delete and Copy Out Objects*/
if (/***tag:condition*//**/isReset/**/) {
   Array objects = reference.as(Object).outObjects.toArray();

   if (objects.length == 0) {
      mpt("Error setting parameter " + c.up.up.name + " - Not enough objects in object set"); mpr();
   } else {
      for (int i = 2; i <= objects.length; i++) {
         objects.destroy();
      }

      treenode firstObj = objects[1];
      double firstX = firstObj.as(Object).location.x;
      double firstY = firstObj.as(Object).location.y;
      double firstZ = firstObj.as(Object).location.z;
      int total = Math.max(1, newValue);
      for (int i = 2; i <= total; i++) {
         treenode newObj = createcopy(firstObj, firstObj.up);
         newObj.name = firstObj.name + "_" + i;
         applicationcommand("recreateObjectConnections", newObj, firstObj);
         newObj.as(Object).location.x = firstX + X_offset*(i-1);
         newObj.as(Object).location.y = firstY + Y_offset*(i-1);
         newObj.as(Object).location.z = firstZ + Z_offset*(i-1);
      }
   }
}

} // ******* PickOption End ******* //

 

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea