Select interseptions objects

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JokerMartini's picture

Revision

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()

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

iunewind's picture

Still not (

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

LittleLordPotala's picture

An idea for you

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's picture

If i try apply vol select for

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.

LittleLordPotala's picture

Collision script

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.

AttachmentSize
collision_detection.ms 1.01 KB
iunewind's picture

Just see your script,

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's picture

The script will work with

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's picture

i will try, thanks again

i will try, thanks again

JokerMartini's picture

Hey

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()

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

JokerMartini's picture

I'll make ya something. Ill

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

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.