Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Script Camera Node for Camera Map

Script Camera Node for Camera Map

Anonymous
Not applicable
382 Views
4 Replies
Message 1 of 5

Script Camera Node for Camera Map

Anonymous
Not applicable
I only have some experience with maxscript and after looking around for hours, I can't figure out how to script this simple task.

I have a hundred or so objects that I want to assign a camera map modifer, but they have to be copies for the camera to map it correctly. So I wanted to run a script to assign the camera to each copy quickly, but it's not working out to well and the macroreader doesn't give me anything when I assign the camera to the camera map modifier manually.


for obj in $ do
(
obj.modifiers.CameraNode = $Camera01
)


This code gives me an error, so hopefully one of you scripting geniuses can help me out.
0 Likes
383 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Check the name of your CameraMap modifier.
Simple test on single node selected:
$.modifiers

If this returns undefined so the name is incorrect.
Default name is "Camera Map Modifier" and if you dont rename/assign new one then this should works:
for obj in selection do
(
obj.modifiers.CameraNode = $Camera01
)
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks, it works using 'Camera Map Modifier'. I knew it would be something simple :)
0 Likes
Message 4 of 5

ClaudioAlvaro
Contributor
Contributor
A piece of advice is to verify modifiers by type/class as opposed to referencing them by name. I've had issues where artists rename their modifiers and you end up with the same issue you experienced.


for obj in selection do
(
for mod in obj.modifiers where ( classOf mod == CameraMap ) do
(
mod.CameraNode = $Camera01
)
)
---
3DSMax 2012 SP2
0 Likes
Message 5 of 5

Anonymous
Not applicable
Check by class is a good tips at all, but renaming and check by name has their advantage in cases where more than 1 modifiers from the same class are applied to the nodes. This way will not safely to filter them by index in the stack if we want different settings for each of them. Example:
for obj in selection do
(
for mods in obj.modifiers do
(
if mods.name == "Pass1" do mods.CameraNode = $Camera01
if mods.name == "Pass2" do mods.CameraNode = $Camera02
)
)

Of course, can perform both checks for sure:
for obj in selection where ( classOf mods == CameraMap ) do
(
for mods in obj.modifiers do
(
if mods.name == "Pass1" do mods.CameraNode = $Camera01
if mods.name == "Pass2" do mods.CameraNode = $Camera02
)
)

Note: "mod" is a global name for Max function, so I used "mods" for the index vars in the examples.
0 Likes