[Closed] Found geometry with keyable modyfiers
Can anybody could help me with this:
I need script which will deselect objects which contain keys for modyfiers:
check on selected geometrys if there are keys in theirs modyfiers and deselect those objects.
I have no clue how to solve it.
Maybe pass a selection of scene nodes as an array argument to a function that goes thru each node searching its modifier stack. Try searching the forums and MXS help for functions interrogating the modifier stack.
I very fresh in maxscript programming and my knowlede is very poor, However I have to make this script. I get to far to get beck. It sound like bleck magic to me. Can You or anybody can give me some simple example how it should work.
Search maxscript Help on:
[ul]
[li]ModifierArray Values[/li][li]Modifier Common Properties, Operators, and Methods[/li][li]Skipping Loop iterations[/li][/ul]You can try this script, to see if it works for you… (again I’m not at Max to test it myself…)
newArray = #()
local omitObj = false
for obj in selection do
(
if (obj.modifiers).count > 0 do
(
for m in obj.modifiers while not omitObj do
(
if not isIdentity ( getModcontextTM obj ) do
(
omitObj = true
)
)
if not omitObj then
(
append newArray obj
)
else
(
omitObj = false
)
)
)
clearSelection()
if newArray.count > 0 then
(
for i = 1 to newArray.count do
(
selectMore newArray[i]
)
)
Warning: Not tested… so it may contain errors but maybe it gives you enough of an idea of how to help you achieve what you want to do. I’m assuming that if the modifier doesn’t perform any animation on the node then it’s context transform is identity– this may be a faulty assumption until I can get to 3dsMax and test out the script.
maxscript showed me error after I run it:
#()
– Error occurred in anonymous codeblock; filename: E:\WORK\doctor\NA CZYSTO\MODULES\SCAN\show_missing_bitmaps.ms; position: 30; line: 2
– Compile error: no local declarations at top level: omitObj
– In line: local omitObj =
I just need this action:
check in my selection if object contain keys in their modyfiers, if yes deselect this object if no do nothing. I would be very gratefull because I blew up numbers of days to figure it out and founding clue on forum is my last stand.I stack in many different points with my big script and this is one of significant puzzle. Please help me if you can.
Just close the code from Archangel35757 with “(” and “)”
(
newArray = #()
local omitObj = false
for obj in selection do
(
if (obj.modifiers).count > 0 do
(
for m in obj.modifiers while not omitObj do
(
if not isIdentity ( getModcontextTM obj ) do
(
omitObj = true
)
)
if not omitObj then
(
append newArray obj
)
else
(
omitObj = false
)
)
)
clearSelection()
if newArray.count > 0 then
(
for i = 1 to newArray.count do
(
selectMore newArray[i]
)
)
)
so “getModcontextTM obj m” isn’t going to work… trying to find you an answer…
i’m looking in your code and cannot understand what you want to get…
do you want to find all nodes in scene which have at least one modifier with at list one keyed parameter? right?
@DenisT – yes, as I understood it… Kredka is wanting a script to run on a selection of objects that will remove all the objects from the selection that have animated modifiers– leaving a selection of objects that have no animated modifiers. My script was a fail…
you are doing it from wrong side… first of all you have to write a function that checks if a modifier has a key. i’ve showed how to check recursively if a controller keyable. it’s exactly the same but additionally you have to check number of keys. if the number greater than 0 the property (subanim) is keyed.
after that… after that i will tell what to do next
Ok… so here are the two functions you will need (this was my approach… I’m sure there are plenty of other, more professional, ways to do this).
function isKeyed c = if c != undefined do
(
if c.supportsKeys and (c.keys.count > 0) then
(
return true
)
else if ((c.numSubs != undefined) and (c.numSubs > 0)) then
(
count = c.numSubs
for i = 1 to count do
(
if (getSubAnim c i).controller != undefined do
(
if (getSubAnim c i).controller.supportsKeys and ( (getSubAnim c i).controller.keys.count > 0 ) then
(
return true
)
else if (((getSubAnim c i).numSubs != undefined) and ((getSubAnim c i).numSubs > 0)) do
(
if ( isKeyed (getSubAnim c i).controller ) do
(
return true
)
)
continue
)
return false
)
return false
)
else
(
return false
)
)
function isModifierAnimated obj =
(
if (obj.modifiers).count > 0 do
(
local m = obj.modifiers
for i = 1 to m.count do
(
if (m[i]).numSubs > 0 do
(
for n = 1 to(m[i]).numSubs do
(
if ( (isKeyed ((m[i])[n].controller)) != undefined ) and ( isKeyed ((m[i])[n].controller) ) then
(
return true
)
else ( continue )
)
)
)
return false
)
)
--evaluate each of the two functions above.
--Then select your scene nodes you want to test and run the following code:
(
for obj in selection do
(
if ( isModifierAnimated obj ) == undefined or ( isModifierAnimated obj ) do
(
deselect obj
)
)
)
Hope this helps you… DenisT has showed in one of my recent posts how to write a shorter, professional version of “isKeyable” function… I will also attach the maxscript file– just delete the .txt extension.