Sort objects in order away from given point...

Sort objects in order away from given point...

Anonymous
Not applicable
366 Views
4 Replies
Message 1 of 5

Sort objects in order away from given point...

Anonymous
Not applicable
Have the user select a group of objects.
Have the user indicate a beginning point and angle through those objects.

Now I want to order those objects away from the beginning point along a line parallel to the user's indicated angle.

I can process all the xy from each of the objects, get the xy of the user's point and it's angle in radians. What I can't seem to do is come up with a calculation that provides me with a single number for each object which, when sorted (using vl-sort), are in order away from the user's point.

I've tried this calculation to create that single number:

(setq newxy (* (sqrt (+ (expt objx 2) (expt objy 2))) (- (cos (atan objy objx)) udir)))

...which essentially is trying to convert everything to radians, etc. What the single number ends up being is irrelevent except for the order sequence.

Some of my calculations work in one direction but when I reverse the direction, don't. Or I can get it to work going both ways as long as it's in the x dir but not in any other angle.

I think part of the issue is which quadrant the objects are in related to 0,0 but I'm lost as to how to allow for that. I once thought maybe I could simply subtract the user's point from the objx and objy but that didn't seem to work either.

Thoughts or suggestions?

Merle
0 Likes
367 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Use the ActiveX method "GetBoundingBox" of each of the objects, and then
take the point closest to the the beginning point, then make a list of
associated lists of the distance and the object name, and then sort by the
distance.

Is that clear? I'm not sure it is, but that is how I would do it.

--

Tim
"A blind man lets nothing block his vision."



wrote in message news:5133133@discussion.autodesk.com...
Have the user select a group of objects.
Have the user indicate a beginning point and angle through those objects.

Now I want to order those objects away from the beginning point along a line
parallel to the user's indicated angle.

I can process all the xy from each of the objects, get the xy of the user's
point and it's angle in radians. What I can't seem to do is come up with a
calculation that provides me with a single number for each object which,
when sorted (using vl-sort), are in order away from the user's point.

I've tried this calculation to create that single number:

(setq newxy (* (sqrt (+ (expt objx 2) (expt objy 2))) (- (cos (atan objy
objx)) udir)))

...which essentially is trying to convert everything to radians, etc. What
the single number ends up being is irrelevent except for the order sequence.

Some of my calculations work in one direction but when I reverse the
direction, don't. Or I can get it to work going both ways as long as it's
in the x dir but not in any other angle.

I think part of the issue is which quadrant the objects are in related to
0,0 but I'm lost as to how to allow for that. I once thought maybe I could
simply subtract the user's point from the objx and objy but that didn't seem
to work either.

Thoughts or suggestions?

Merle
0 Likes
Message 3 of 5

Anonymous
Not applicable
But, of course! Distance between the user selected point and each of the objects. Sheesh. I was trying to make this too difficult. Parallel would be better, since distance is radial, but this will do unless someone has a suggestion for that. I'd give it a try if you do.

Thanks, Tim!

Merle
0 Likes
Message 4 of 5

Anonymous
Not applicable
You might find the code here useful:

http://www.caddzone.com/dimstr.zip

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com

wrote in message news:5133183@discussion.autodesk.com...
But, of course! Distance between the user selected point and each of the objects. Sheesh. I was trying to make this too difficult. Parallel would be better, since distance is radial, but this will do unless someone has a suggestion for that. I'd give it a try if you do.

Thanks, Tim!

Merle
0 Likes
Message 5 of 5

Anonymous
Not applicable
Looks promising. Thanks for sharing, Tony!

Merle
0 Likes