ScriptSpot

Forum topic · Scripts Wanted

Select interseptions objects

By Anonymous · 2012-04-18

Description

I need this script:
Large group of object, for example - heaps of rocks on the ground.
One long complicated object, for example - road. This object curved and interesct with many of little objects - this rocks, bush, grass etc.
I need script what select of objects what intersepted with this complicated long objects.
It hard to develop?

sorry my english.

Comments (13)

Revision

JokerMartini · 2012-04-19

Compact version. Here you go.


fn fnIntersectsSel =
(
problemObjs = #()
safeNodes = selection as array
testers = for i in objects where (findItem safeNodes i) == 0 collect i

for obj in safeNodes do --//test each object in the selection
(
for p in testers where intersects obj p do appendIfUnique problemObjs p --//test the intersection to the scene objects
)
select problemObjs
)

fnIntersectsSel()

Still not (

iunewind · 2012-04-21

When i try, it select many of non-intercected objects. Look like it work with bound box, it not enough (

An idea for you

LittleLordPotala · 2012-04-22

Select all the small objects that could collide with your master object, then apply a "vol. select" modifier on the selection (so it creates an instanced modifier). Change the modifier parameters as following :
-Stack selection level -> face
-selection method -> replace
-selection type -> crossing
-select by -> mesh object -> and select your big master mesh object

Keep your selection (without the master object)
Then open Maxscript listener, and execute :
arr = #()
for i in selection where (getfaceselection i as array).count > 0 do append arr i
select arr

Just be aware that if you have a lot of objects, the "vol. select" modifier can be slow, it depends of your system specs.

iunewind · 2012-04-22

If i try apply vol select for small object only and make all us you describe,
It reply "-- No ""select"" function for undefined"
every time, nothing happen.
If i try apply "vol select" to small object with master object, it fantastick slow (on i5-2500k i use array of 7x7x7 boxes for test), i even cant make "select by mesh" and pick mech.

Collision script

LittleLordPotala · 2012-04-22

I made a small script to detect quickly the collision with only one "vol select".
Launch the script and there is three buttons :
-First pick the master object
-Pick the collision objects in the "select by name" window
-Click the last button and it will select the objects that collide with the master

I tested on Max 2012 and 2013 with no error message.

Attachments

iunewind · 2012-04-26

Just see your script, thaks.
And still not work well (
First my trying was succesfull - i make spheres array and master sphere - work good, select all collision.
After that i try box array and master object extruded from shape - and it select only several boxes from array.
After convert sphere from worked example to polymesh - not work too. Seems to it cannot work with mesh objects, only with standart objects.
And script many times brokeup after first trying - not worked without scene reloading but maybe it because mmaster object was a mesh.
Any way, many thanks, it work with standart objects well and maybe will be helpfull for someone.

LittleLordPotala · 2012-04-27

The script will work with primitives and editable_mesh objects, it doesn't work with editable_poly. As workaround, you can add "turn to mesh" modifier or convert to editable_mesh before using the script.
This script use the volume select capabilities, so that means your objects must have enough subdivion (particularly the master object).
I think you could also use the reset xform before converting your objects, it can often resolve weird issues.

I hope that helps.

iunewind · 2012-04-28

i will try, thanks again

Hey

JokerMartini · 2012-04-19

Here you go. Just run this.


fn fnIntersectsSel =
(
problemObjs = #()
safeNodes = selection as array
testers = for i in objects where (findItem safeNodes i) == 0 collect i

for obj in safeNodes do --//test each object in the selection
(
for p in testers do --//test the intersection to the scene objects
(
if intersects obj p do
(
appendIfUnique problemObjs p
)
)
)
select problemObjs
)

fnIntersectsSel()

JokerMartini · 2012-04-19

I'll make ya something. Ill be back with a script.

Not realy

iunewind · 2012-04-19

Thanks, but it work not like i need.
I try to make Box array and make torus intersected many of boxes. When i use script when all selected it slect only torus.
If i select only torus and run script - it make nothing selected.
(and if i try add some tolerance it freez 3d max, i use 2011 64bit)
Maybe i do something wrong?

I try to illustrated what i need in attached jpg
It must select all boxes what interesepted with "master" object - torus in this example.

Attachments

br0t · 2012-04-18

if you only test for their bounding box, this is very easy. if it has to be more precise, which in your case i fear it has to be, it gets more complicated and i dont know how to do it right now. i think you might have to raytrace from the surface of one object to another ones and see if you hit, which would be very costly on performance. hm... maybe someone else has a smart idea :P