Lucas_3D

Apply SME Nested

Jun 20th, 2024
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. (
  2. -- Apply selected SME material to selected objects
  3.  
  4. sme_material_array = #()
  5.  
  6. Fn Create_material_array=
  7. (
  8. viewNode = sme.GetView (sme.activeView)
  9. for n = 1 to trackViewNodes[#sme][(sme.activeView)].numSubs do
  10. (
  11. m = trackViewNodes[#sme][(sme.activeView)][n].reference
  12. b = viewNode.GetNodeByRef m
  13. if b.selected do append sme_material_array m
  14. )
  15. )
  16.  
  17. -- Check if there is an active SME view
  18. if (sme.GetView (sme.activeView) != undefined) then
  19. (
  20. -- Check if any objects are selected in the scene
  21. if (selection.count > 0) then
  22. (
  23. -- Check if there are any nodes in the active SME view
  24. if ((trackViewNodes[#sme][(sme.activeView)].numSubs) >= 1) then
  25. (
  26. Create_material_array()
  27. -- Check if any materials were selected in the SME
  28. if sme_material_array.count > 0 then
  29. (
  30. -- Ensure only one material is selected
  31. if sme_material_array.count <= 1 then
  32. (
  33. -- Confirm the selected SME node is a material
  34. if superClassOf sme_material_array[1] == material then
  35. (
  36. for i in selection do
  37. (
  38. try
  39. (
  40. i.material = sme_material_array[1]
  41. ) catch()
  42. )
  43. ) else
  44. (
  45. print "Selected SME node is not a material."
  46. )
  47. ) else
  48. (
  49. print "Too many materials selected,\nSelect just 1 SME material."
  50. )
  51. ) else
  52. (
  53. print "No SME node selected."
  54. )
  55. ) else
  56. (
  57. print "No SME materials are available."
  58. )
  59. ) else
  60. (
  61. print "No objects are selected."
  62. )
  63. ) else
  64. (
  65. print "No SME View is active."
  66. )
  67. )
  68.  
Advertisement
Add Comment
Please, Sign In to add comment