View Full Version : editbegin() / editend() crash Modeler if geometry selected across models

07-12-2008, 09:21 AM
I've discovered a crash in one of my little scripts (my version of the measure points tool) where if I have two models loaded, and I make them both visible then select points spanning both it crashes Modeler instantly.

It seems the editbegin() / editend() command doesn't like geometry to be selected across two loaded models.

This is the code that gets the point information

// Get selection

// Get info on points
selected_points = editbegin();

// First points coords
x1 = pointinfo(points[1]).x;
y1 = pointinfo(points[1]).y;
z1 = pointinfo(points[1]).z;

// Last points coords
x2 = pointinfo(points[selected_points]).x;
y2 = pointinfo(points[selected_points]).y;
z2 = pointinfo(points[selected_points]).z;


// Get difference in axis
difference_x = abs((x2 - x1));
difference_y = abs((y2 - y1));
difference_z = abs((z2 - z1));

// Work out difference using Pythagoras . . .
distance = sqrt((difference_x * difference_x) + (difference_y * difference_y) + (difference_z*difference_z));

Is there a way of getting the points array of the selected geometry without using editbegin() / editend() or is my code just doing something illegal?


07-12-2008, 03:09 PM
are you using 2 different objects... or 2 layers in the same object? 2 layers in the same object worked for me.

07-12-2008, 03:49 PM
after thinking about using 2 different objects, as soon as you switch objects it loses the selection for that object. so unless you did something where you stored the point information for the first object and ran the script again to get the info for the second point (in the second object) and recalled the info for the first, i dont know if there is an easier way to get it to work. maybe some of you hardcore coders can chime in :).

07-12-2008, 04:25 PM
My script works fine with multiple foreground layers on _one_ object. But crashes with multiple foreground layers on _two_ different objects.