Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (
- Fn Apply_sme_material_to_selection=
- (
- sme_material_array = #()
- -- Check if there is an active SME view
- if (sme.GetView (sme.activeView) == undefined) do
- (
- print "No SME View is active."
- return #stop
- )
- -- Check if any objects are selected in the scene
- if (selection.count == 0) do
- (
- print "No objects are selected."
- return #stop
- )
- -- Check if there are any nodes in the active SME view
- if ((trackViewNodes[#sme][(sme.activeView)].numSubs) == 0) do
- (
- print "No SME materials are available."
- return #stop
- )
- -- Populate the material array
- viewNode = sme.GetView (sme.activeView)
- for n = 1 to trackViewNodes[#sme][(sme.activeView)].numSubs do
- (
- m = trackViewNodes[#sme][(sme.activeView)][n].reference
- b = viewNode.GetNodeByRef m
- if b.selected do append sme_material_array m
- )
- -- Check if any materials were selected in the SME
- if sme_material_array.count == 0 do
- (
- print "No SME node selected."
- return #stop
- )
- -- Ensure only one material is selected
- if sme_material_array.count > 1 do
- (
- print "Too many materials selected,\nSelect just 1 SME material."
- return #stop
- )
- -- Confirm the selected SME node is a material
- if superClassOf sme_material_array[1] != material then
- (
- print "Selected SME node is not a material."
- return #stop
- )
- for i in selection do
- (
- try
- (
- i.material = sme_material_array[1]
- ) catch()
- )
- )
- Apply_sme_material_to_selection()
- )
Advertisement