[Closed] Q: script error
Hopefully a quick scripting problem someone might beable to help with.
Script below works to randomly move the uvw of all or any objects selected. It worked fine in 3ds max
2012 32bit on windows xp. now i’ve upgraded to windows 7 64bit and 3ds max 2012 64bit it throws an error “– Unknown property: “gizmo” in undefined”. any ideas?
im not that hot on writing max script so its a bit hard to know whats the issue – whether its 64bit 3ds max vs 32bit, or windows 7 vs xp or 64bit windows vs 32bit, the new windows UAC, with or without 3ds running with administratorrights, folder security or just a difference in scripts for 3ds max 64bit.
many thanks in advance
for o in $ do
(
randX = random 0 1000
randY = random 0 1000
randZ = random 0 1000
o.modifiers[#UVW_Mapping].gizmo.position = [randX,randY,randZ]
)
Well… stupid question but do you have any object selected?
Also you could try changing the “$” to “selection” without the quotes.
for o in selection do
Cheers!
changing the script to that throws the same error about the gizmo sadly – with the object selected witha uvw modifier and map applied
It may be because you have a couple of items selected that do not have a UVW Modifier. Also your code will only modify the first uvw map if you have multiple UVW maps on one object.
This code will change the gizmo positon of every uvw map on each object, and will not fail if an object has no uvw map. I also changed random 0 to -1000 so that the gizmo is translated around the centre of the scene.
for o in selection do (
randX = random -1000 1000
randY = random -1000 1000
randZ = random -1000 1000
for a in o.modifiers do (
if classOf a == uvwmap do (
a.gizmo.position = [randX,randY,randZ]
)
)
)
No problem, glad to help.
By the way I should have done this earlier but didn’t see it. There is no need to calculate random values for every object. A more efficient script would be this:
for a in selection do (
for b in a.modifiers where classOf b == uvwmap do (
b.gizmo.position = [(random -1000 1000),(random -1000 1000),(random -1000 1000)]
)
)
b.gizmo.position = random [-1000,-1000,-1000] [1000,1000,1000]
it’s not an aesthetic issue. [color=Red](random -1000 1000)[/color] returns integer. we need float. Point3 value is always three floats.
Cheers for the info Dennis. I wasn’t aware random could be used like that.