Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- (
- -- Apply selected SME material to selected objects
- sme_material_array = #()
- Fn Create_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 there is an active SME view
- if (sme.GetView (sme.activeView) != undefined) then
- (
- -- Check if any objects are selected in the scene
- if (selection.count > 0) then
- (
- -- Check if there are any nodes in the active SME view
- if ((trackViewNodes[#sme][(sme.activeView)].numSubs) >= 1) then
- (
- Create_material_array()
- -- Check if any materials were selected in the SME
- if sme_material_array.count > 0 then
- (
- -- Ensure only one material is selected
- if sme_material_array.count <= 1 then
- (
- -- Confirm the selected SME node is a material
- if superClassOf sme_material_array[1] == material then
- (
- for i in selection do
- (
- try
- (
- i.material = sme_material_array[1]
- ) catch()
- )
- ) else
- (
- print "Selected SME node is not a material."
- )
- ) else
- (
- print "Too many materials selected,\nSelect just 1 SME material."
- )
- ) else
- (
- print "No SME node selected."
- )
- ) else
- (
- print "No SME materials are available."
- )
- ) else
- (
- print "No objects are selected."
- )
- ) else
- (
- print "No SME View is active."
- )
- )
Advertisement
Add Comment
Please, Sign In to add comment