THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 14/06/2011 at 08:18, xxxxxxxx wrote:
User Information:
Cinema 4D Version: 12
Platform: Mac OSX ;
Language(s) : C.O.F.F.E.E ;
---------
Hello Folks,
I wrote a script to get the Size of a Pointselection. Now I want to do the Same thing for a Polyselection. I am stucked here. I hope someone can help me.
Here is my approach to get x,y,z-dimensions of a Pointselection.
var doc = GetActiveDocument();
var obj = doc -> GetActiveObject();
doc->StartUndo();
doc->AddUndo(UNDO_OBJECT_BASEDATA, obj);
var select = obj -> GetPointSelection();
var i;
var found = 0;
var sum = 0;
var minX=100000000, minY=100000000, minZ=1000000000;
var maxX=0, maxY=0, maxZ=0;
for (i = 0; i < obj -> GetPointCount(); i++){
if (found >= select -> GetCount()) break;
if (select -> IsSelected(i)){
var temp = obj->GetPoint(i);
if (temp.x>maxX) maxX=temp.x;
if (temp.x<=minX) minX=temp.x;
if (temp.y>maxY) maxY=temp.y;
if (temp.y<=minY) minY=temp.y;
if (temp.z>maxZ) maxZ=temp.z;
if (temp.z<=minZ) minZ=temp.z;
found++;
}
}
var sizeX=maxX-minX;
var sizeY=maxY-minY;
var sizeZ=maxZ-minZ;
println("Size x:", sizeX);
println("Size y:", sizeY);
println("Size Z:", sizeZ);
found = 0;