Subject:
|
Re: Sorting parts by location
|
Newsgroups:
|
lugnet.cad
|
Date:
|
Tue, 28 Aug 2001 13:03:23 GMT
|
Viewed:
|
518 times
|
| |
| |
In lugnet.cad, Fredrik Glöckner writes:
> "Larry Pieniazek" <lpieniazek@mercator.com> writes:
>
> > Does anyone know if there exists a utility to sort parts in a model file by
> > their "cut plane" location?
>
>
> No, I don't know of any utility.
>
>
> > Sorting using the origin is good enough, although sorting on the
> > vertex of the bounding box that is first intersected by the
> > cutplane might be better.
>
>
> You could hack up a Perl script which computes the euclidian distance
> between the viewing point and the origin of each individual part, and
> concatenates this number to the beginning of each part line. Then you
> can sort the parts lines and remove the number again. It's a
> solution, albeit a bit dirty...
Well I am sort of doing that right now, although not in perl. I chose to use
my company's product, sort of as a learning exercise. If someone has perl
code that recognises the various line types that would be spiffy.
If you have the formula for euclidian distance that would be great too. I am
using the approximation of taking the X Y anx Z values and summing them. If
the viewpoint is in the right place that's an excellent approximation.
Thanks for replying, it suggests I am on the right track. If i get this
working I'll be able to convert files for other people on request.
|
|
Message has 2 Replies: | | RE: Sorting parts by location
|
| (...) If the viewpoint is at location (a,b,c) and the part is at (x,y,z), then the distance between them is: ((a-x)^2 + (b-y)^2 + (c-z)^2)^0.5 Since all you want to do is sort, there's no need to take the square root after summing the squares. HTH, (...) (23 years ago, 28-Aug-01, to lugnet.cad)
| | | Re: Sorting parts by location
|
| (...) Bram Lambrecht gave you the formula. Depending on what you want to do and what kind of viewing transformation (if any) you are using, the euclidian distance _may_ be the wrong kind of measure to use. But it is probably an ok approximation... (...) (23 years ago, 28-Aug-01, to lugnet.cad)
|
Message is in Reply To:
| | Re: Sorting parts by location
|
| (...) No, I don't know of any utility. (...) You could hack up a Perl script which computes the euclidian distance between the viewing point and the origin of each individual part, and concatenates this number to the beginning of each part line. (...) (23 years ago, 28-Aug-01, to lugnet.cad)
|
7 Messages in This Thread:
- Entire Thread on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
This Message and its Replies on One Page:
- Nested:
All | Brief | Compact | Dots
Linear:
All | Brief | Compact
|
|
|
|