|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
|
Autodesk® Entertainment Creation Suite Ultimate®
|
|
Hi,
I’m trying to create a simple script that iterates through objects and increments a property according to object name suffix (01,02,03,04,05 etc)
01 - leave property as is
02 - multiply by 2
05 - multiply by 5 etc
for i = 1 to selection.count do
(
selection.property = i*5
)
Thanks in advance.
|
|
|
|
something like this
fn multiplyPropByName arr prop: =
(
if arr.count != 0 do
(
for obj in arr where isProperty obj prop do
(
val = ""
for s = 1 to obj.name.count where (obj.name[s] as number) != undefined do
(
if val.count == 0 and (obj.name[s] as number) > 0 or val.count > 0 do append val obj.name[s]
)
if val.count != 0 do
(
format "value = %\n" val
val = val as number
currVal = getProperty obj prop
setProperty obj prop (currVal*val)
)
)
)
)
--example for i in 1 to 10 do Box width:10 length:10 height:2 pos:[(i*12), 0, 0]
boxArr = $Box* as array multiplyPropByName boxArr prop:"height"
|
|
|
|
|
Thanks, so much for help. While putting to amazing piece of code it returns an error: unknown property count in undefined highlighting (3rd line) if arr.count != 0 do
Author: d2d2
|
| Replied: 17 September 2012 08:56 PM
|
|
|
|
|
Post your example to see what is wrong.
|
|
|
|
|
for i in 1 to 10 do
boxArr = $Obj* as array
multiplyPropByName boxArr prop:"viewPercent"
I’m using this for particles though.
Author: d2d2
|
| Replied: 17 September 2012 10:57 PM
|
|
|
|
|
If function *fn multiplyPropByName arr prop: =* first argument must by array of nodes (maxobject) e.i:
arr = selection as array
--or arr = objects as array
--or arr = geometry as array
--or (lights,helpers,cameras etc.)
Second argument is property string ("width", “height”, “radius” etc.)
If you want to set property of some modifiers then i need to change code.
This is why i need your example, or post some screenshots
Cheers!
|
|
|
|
|
I’m sorry, I’m a newbie and I appreciate your help. I’ve already learned huge amount by your example, thank you.
Author: d2d2
|
| Replied: 17 September 2012 11:13 PM
|
|
|
|
|
macroScript OperationX category: “PFun”
(
fn multiplyPropByName arr prop: =
(
if arr.count != 0 do
(
for obj in arr where isProperty obj prop do
(
val = “”
for s = 1 to obj.name.count where (obj.name[s] as number) != undefined do
(
if val.count == 0 and (obj.name[s] as number) > 0 or val.count > 0 do append val obj.name[s]
)
if val.count != 0 do
(
format “value = %\n” val
val = val as number
currVal = getProperty obj prop
setProperty obj prop (currVal*val)
)
)
)
)
rollout particles_rollout “Operation X”
(
for i in 1 to 10 do
boxArr = $Obj* as array
multiplyPropByName boxArr prop:"viewPercent"
)--end on
)--end rollout
createDialog particles_rollout 250 100
)
by the way I’m using this on SuperSpray
|
|
|
|
Try now.
If you select some supersprays then script will operate on selection otherwise it will all be taken in calculation.
link superspray test
|
|
|
|
Brilliant, thanks very much.
|
|
|
|
|
|