PDA

View Full Version : Condensing code


JokerMartini
08-16-2011, 07:31 PM
I'm recently posed a script here.
I'm working on condensing the code and I'm trying to make a function that does just that.
This is bugging out and I'm not sure exactly how to solve it.
http://jokermartini.com/extras/217/Welder

The setup. A spline object has a displace modifier on it and then the displace mod has a cellular map in the map slot.

Then run this function with the object selection.


fn fnDisplaceModChange prop val =
(
undo on (
for i = 1 to selection.count do
(
Obj = selection[i]
for m in Obj.modifiers where (classOf m == Displace) and (classof m.map == Cellular) do
m.prop = val
)
)
)

fnDisplaceModChange (map.size) 50

denisT
08-16-2011, 07:44 PM
fn fnDisplaceModChange prop val =
(
undo on (
for i = 1 to selection.count do
(
Obj = selection[i]
for m in Obj.modifiers where (classOf m == Displace) and (classof m.map == Cellular) do
setproperty m prop val
)
)
)

fnDisplaceModChange #size 50


it was wrong using of property name, and setting a property

JokerMartini
08-16-2011, 07:47 PM
Thank you for clearing that up Denis.
I was wondering why it was not working vs when it would work when it was outside of the function.

Thanks

CGTalk Moderation
08-16-2011, 07:47 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.