Add Color_Correction map to the currently selected VrayBitmap map in the SME


#1

Hi All,

I am stuck with creating the following script - A one, which gets the currently selected VrayBitmap map in SME and adds a Color_Correction map (with certain predefined settings) to its output.

Any help will be greatly appreciated!

PS: Is it also possible to have the option to just create the CC map without connecting it to the VrayBitmap output?

Thank you,


#2

Probably that’s all you have to do:

for n in (view = SME.GetView SME.ActiveView).GetSelectedNodes() where iskindof n.reference VrayBitmap do
(
      view.CreateNode (  ColorCorrection() ) (n.pos + [ 200, 0 ])
)

#3

Thanks for the reply. When select the VrayBitmap in SME and run the code I get this error:

   -- Error occurred in anonymous codeblock; filename: ; position: 177; line: 4
-- Unknown property: "CreateNode" in undefined
-- MAXScript callstack:
--	thread data: threadID:10856
--	------------------------------------------------------
--	[stack level: 0]
--	In n loop; filename: ; position: 155; line: 3
--		Parameters:
--			n: <MixinInterface:Node>
--		Locals:
--			n: <MixinInterface:Node>
--			view: undefined
--		Externals:
--			owner: undefined
--	------------------------------------------------------
--	[stack level: 1]
--	called from top-level

>     --	In n loop; filename: ; position: 155; line: 3
>     --		Parameters:
>     --			n: <MixinInterface:Node>
>     --		Locals:
>     --			n: <MixinInterface:Node>
>     --			view: undefined
>     --		Externals:
>     --			owner: undefined
>     --	------------------------------------------------------
>     --	[stack level: 1]
>     --	called from top-level

#4

try moving view variable definition outside the loop for it to work


#5

So I ended up with this code:

view = SME.GetView SME.ActiveView
for n in view.GetSelectedNodes() where iskindof n.reference VrayBitmap do
(
	view.CreateNode (  ColorCorrection() ) (n.pos + [ 200, 0 ]
)

When I run it the MaxScriptListener prints this, but nothing happens:

<IObject:IFP_NodeViewImp>

When I try to run it again nothing happens too.

Did this code work on your side?


#6

seems like you forgot closing parenthesis

anyway, this code won’t work in older max versions ( in older ones there’s no .reference property )
here’s what you can use instead

if SME.ActiveView > 0 do
(
	index = SME.ActiveView
	view  = SME.GetView SME.ActiveView	
	
	for n = 1 to trackViewNodes[#sme][index].numSubs do
	(	
		local ref = trackViewNodes[#sme][index][n].reference
		
		if isKindOf ref Checker do
		(
			local sme_node = view.GetNodeByRef ref
			if sme_node != undefined and sme_node.selected do
			(
				pos = getProperty sme_node #position -- accessing sme_node.pos directly sometimes throws an error '-- Unknown property: "pos" in <MixinInterface:Node>'
				view.CreateNode (  ColorCorrection() ) (pos + [ 200, 0 ])
			)
		)	
	)
)

#7

Works like a charm :slight_smile: Thank you!