it’s maybe hard to believe but the function has to be three lines of code… i don’t have max right now to test but i will try to write it blind:
fn doesSubHaveAKey sub =
(
local has = off
if iskindof sub subanim and not has = (sub.keys != undefined and sub.keys.count > 0) do
for k=1 to sub.numsubs while not (has = doesSubHaveAKey sub[k]) do ()
has
)
hmm… it’s four lines.
ok… let’s make it three:
fn doesSubHaveAKey sub has:false =
(
if iskindof sub subanim and not has = (sub.keys != undefined and sub.keys.count > 0) do
for k=1 to sub.numsubs while not (has = doesSubHaveAKey sub[k]) do ()
has
)
no… it’s not correct… here is it
fn doesSubHaveAKey sub has:false =
(
if iskindof sub subanim do has = (sub.keys != undefined and sub.keys.count > 0)
for k=1 to sub.numsubs while not has do has = doesSubHaveAKey sub[k]
has
)
this has to work for all maxobjects: nodes, ca, modifiers, materials, controllers, …
technically the function needs a foolproof… but a ‘fool-proofing’ is kinda an old school today.
Wierd… :curious:
The functions work properly when you test a single object, but in the following code:
(
for obj in selection do
(
if ( isModifierAnimated obj ) == undefined or ( isModifierAnimated obj ) do
(
deselect obj
)
)
)
It is leaving an object (with an animated modifier) selected that should be deselected… if I run the For Loop a second time then it correctly removes the offending node. It’s late and I’m tired… can someone see the flaw in my logic?
that’s probably the issue. selection is a ‘live object’. by deselecting anything you change the selection.
so the loop should be at least:
for obj in selection as array ...
True. I was just trying to help out the original poster with his request… I guess it’s time to call the Doctor.
unfortunately my ‘prescription’ can’t really help the original poster today. but i hope it might be helpful for anyone how really sick with the mxs
Thank all of You for help, I checked your codes. I create 3 objects on scene, one without any
deformabele modyfiers, one with deformable modyfier, and one with animate modyfier.
First I use big code from Archangel35757. … and
Code unselect both – object with deformable modyfiers with animation and without animation:(
To unselect objects anyway I have to run script as many times as many object is in my selection:( So it seem code olny unselect object with any modyfier on it.
Second code from Denis – I assume this particular one it should work with skin only: I did identical test with object with animated skin and:
No matter if object have modyfier or not or animable modyfier with keys there is no action
whatsoever. In max listner ther is only :
doesSubHaveAKey()
(I assume is “has” – value)
Please help me with this, It’s to heave problem for my level of maxscript programming to solve it by my self. I also attached max file with simple scene – red object represent object that should be unselected from selection.
we need three steps to achieve what you want…
#1
make a function that recursively searches an valid object for any anumated parameter
fn doesSubHaveAKey sub has:false =
(
if iskindof sub subanim do has = (sub.keys != undefined and sub.keys.count > 0)
for k=1 to sub.numsubs while not has do has = doesSubHaveAKey sub[k]
has
)
#2
we need an iterator through specified list of nodes to collect all nodes which have at least one animated modifier
fn getNodesWithAnimatedModifiers nodes: =
(
if nodes == unsupplied do nodes = objects as array
for node in nodes collect
(
local has = off
for modi in node.modifiers while not has do has = doesSubHaveAKey modi
if not has then dontcollect else node
)
)
and
#3
delesecet (or do whatever we want with this list)
#all together:
deselect (getNodesWithAnimatedModifiers nodes:(getCurrentSelection()))
It’s funny because your description is identical like my tool name I’m working on right now – Max Doctor:)
Ok. so I took your code step by step and don’t work. Maybe i will tel You what i’m trying to do: I have two task to achieve:
- found all objects in selection, check if they have animated deformation any kind(modyfiers)
if yes then remove them from selection - found for any geometry on scene and remove unchecekd-unpined(not in use)modyfiers from each object
For me the most cruciall in my tool is point nr1. It’s like be or not to be. I search evrywhere about topic and I found only this:
and for a more global check:
trackbar.getPreviousKeyTime()
and
trackbar.getNextKeyTime()
If both are undefined then there are no keys on the trackbar, which means no animation for the selected object.
But I dont know how to use it and also topic
http://forums.cgsociety.org/showthread.php?f=98&t=1020938&highlight=mini-challenge
which dont help me much. So You are my last hope I can say:)
I need just code as one pise which will do 1)
please HElp me, it seems You are the code master:)
Please check your code on my scene if You can.
You will see no result by far. :banghead: :banghead: :banghead: