View Full Version : SetSelectFilter by obj.name
Anyone know of a way to do this? create a pick mask that allows to pick by name/partial name. I'm currently using a selection callback but that allows for misc objects to be picked first before the callback removes the invalid objects. The callback will work but requires that users swipe a selection and not just click to get what could be pick filtered.
|
|
Light
07-05-2007, 11:08 PM
Hi,
How about freezing everything except the objects with the specified name? Frozen objects can also be made to look like they are not frozen, so I think this should do it.
Light
Good idea, I'll have to test to see what kind of a hit it has on a large scene.
Likely better than any callback.
Light
07-05-2007, 11:47 PM
You can also use the isFrozen property on an array of objects, which would speed things up a little bit.
Light
magicm
07-06-2007, 12:34 AM
There's a callback mechanism available in maxscript which lets you add custom "Selection Filters" to the list in the main toolbar. Here's a simple example:
(
-- declare a global var for the callback function
global MySelectionFilterCallback
-- make sure any previous callback is removed
unregisterSelectFilterCallback MySelectionFilterCallback
-- the callback function (takes one argument containing the object to test)
-- a return value of true means the object may be selected
fn MySelectionFilterCallback obj =
(
-- returns true if the object's name begins with "Box"
matchPattern obj.name pattern:"Box*"
-- this callback function could virtually test against any object property.
-- the below for example would only allow objects with 100 or less faces to be selected
-- (getPolygonCount obj)[1] < 100
)
-- register the custom selection callback
registerSelectFilterCallback MySelectionFilterCallback "By Name"
-- activate the callback we've just created
local NumFilters = GetNumberSelectFilters()
for i = 1 to NumFilters do
(
if GetSelectFilterName i == "By Name" then
(
SetSelectFilter i
exit
)
)
)
I've been working on a script to add all sorts of custom filters some time ago, but never got around to finishing it. Maybe this is a good time to start working on it again :)
Cheers,
Martijn
You can also use the isFrozen property on an array of objects, which would speed things up a little bit.
Light
Yep did that :), made an array of objs frozen by the filter being enabled, so that when it was disabled only the array would be unfrozen.
Good simple solution, thanks light.
There's a callback mechanism available in maxscript which lets you add custom "Selection Filters" to the list in the main toolbar. Here's a simple example:
(
-- declare a global var for the callback function
global MySelectionFilterCallback
-- make sure any previous callback is removed
unregisterSelectFilterCallback MySelectionFilterCallback
-- the callback function (takes one argument containing the object to test)
-- a return value of true means the object may be selected
fn MySelectionFilterCallback obj =
(
-- returns true if the object's name begins with "Box"
matchPattern obj.name pattern:"Box*"
-- this callback function could virtually test against any object property.
-- the below for example would only allow objects with 100 or less faces to be selected
-- (getPolygonCount obj)[1] < 100
)
-- register the custom selection callback
registerSelectFilterCallback MySelectionFilterCallback "By Name"
-- activate the callback we've just created
local NumFilters = GetNumberSelectFilters()
for i = 1 to NumFilters do
(
if GetSelectFilterName i == "By Name" then
(
SetSelectFilter i
exit
)
)
)
I've been working on a script to add all sorts of custom filters some time ago, but never got around to finishing it. Maybe this is a good time to start working on it again :)
Cheers,
Martijn
Thanks Martijn, I'm going to look into this tomorrow.
Thank you again Martijn, that was exactly what I was looking for.
CGTalk Moderation
07-06-2007, 05:02 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.