统计
  • 建站日期:2021-03-10
  • 文章总数:32 篇
  • 评论总数:7 条
  • 分类总数:9 个
  • 最后更新:7月9日
文章 Houdini

houdini 快速找到选择物体材质球(ar mr rs )

Luo7758
首页 Houdini 正文

一.跳转到材质

  1. #Import Modules
  2. import toolutils
  3. import hou
  4. #Set Variables
  5. selected_node = ""
  6. #Define type arrays
  7. MAT_Detect = ["redshift::Material","redshift_vopnet","principledshader::2.0","materialbuilder","arnold::standard_surface", "arnold_materialbuilder"]
  8. Sel_Detect = ["geo","instance"]
  9. #Get the Selected Nodes
  10. selected = hou.selectedNodes()
  11. #Check if there is something selected
  12. if selected:
  13. #Compare first selected objects type with the valid object types
  14. if selected[0].type().name() in Sel_Detect:
  15. #Set the selected node. Just the fist is valid
  16. selected_node = selected[0]
  17. #Force the user to select an object, if the current doesn't match the selection type
  18. else:
  19. #Clear the selection
  20. hou.clearAllSelected()
  21. #Promt the user to select an new object
  22. prompt = toolutils.selectionPrompt(hou.objNodeTypeCategory())
  23. scene_viewer = toolutils.sceneViewer()
  24. selected_objects = scene_viewer.selectObjects(prompt)
  25. #Check if an object is selected
  26. if selected_objects:
  27. #Set the first selected node to variable
  28. selected_node = selected_objects[0]
  29. else:
  30. #Output an Error
  31. hou.ui.displayMessage("Nothing Selected")
  32. #Force the user to select an object, because nothing is selected
  33. else:
  34. #Promt the user to select an new object
  35. prompt = toolutils.selectionPrompt(hou.objNodeTypeCategory())
  36. scene_viewer = toolutils.sceneViewer()
  37. selected_objects = scene_viewer.selectObjects(prompt)
  38. #Check if an object is selected
  39. if selected_objects:
  40. #Set the first selected node to variable
  41. selected_node = selected_objects[0]
  42. else:
  43. #Output an Error
  44. hou.ui.displayMessage("Nothing Selected")
  45. #Check if the selected_node variable is not empty
  46. if selected_node:
  47. #Compare selected_node's type with the valid object types
  48. if selected_node.type().name() not in MAT_Detect :
  49. #Convert Releative Pathes to Absolute Pathes
  50. matPath = selected_node.parm("shop_materialpath").eval()
  51. #Set the targetpath to the node variable
  52. node = selected_node.node(matPath)
  53. #Check if node is valid
  54. if node:
  55. #Look for child Objects
  56. if node.children():
  57. #If there are children, replace node with the fist child
  58. node = node.children()[0]
  59. else:
  60. #Output an Error
  61. hou.ui.displayMessage("Empty material path")
  62. else:
  63. node = selected_node
  64. #Look for child Objects
  65. if node.children():
  66. node = node.children()[0]
  67. #Check if the material node exists
  68. if node:
  69. #Set some Variables
  70. pane = ""
  71. index = 0
  72. #Loop over the active panes
  73. while pane is not None:
  74. #Search for the first network editor
  75. pane = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor, index)
  76. #Loop over the panes
  77. if pane is not None:
  78. #Get the current state
  79. ID = pane.linkGroup()
  80. #Looking for Linkgroup1
  81. if str(ID) == "paneLinkType.Group1":
  82. targetPane = pane
  83. switchorselect = 1
  84. #Looking for FollowSelection
  85. if str(ID) == "paneLinkType.FollowSelection":
  86. targetPane = pane
  87. switchorselect = 0
  88. #Looking for Pinned
  89. if str(ID) == "paneLinkType.Pinned":
  90. targetPane = pane
  91. switchorselect = 2
  92. index += 1
  93. #If there is a PaneType Group1
  94. if switchorselect == 1:
  95. #Set the current Node
  96. targetPane.setCurrentNode(node)
  97. #If the PaneTypeState is set to Follow selection
  98. if switchorselect == 0:
  99. #Selet the material
  100. node.setSelected(True, clear_all_selected=True)
  101. #If the PaneTypeState is set to Pinned
  102. if switchorselect == 2:
  103. #Retun an errror
  104. hou.ui.displayMessage("The PaneType is set to Pinned")

二. 选择当前节点跳转到引用此节点参数的节点

  1. sel = hou.selectedNodes()[0]
  2. sel.setSelected(False)
  3. ref = sel.parmsReferencingThis()
  4. if len(ref) == 1:
  5. target = ref[0].node()
  6. elif len(ref) >1:
  7. list = []
  8. for i in ref:
  9. list.append(i.node().path())
  10. path = hou.ui.selectFromList(list, message='to Jamp referencing Node')
  11. print (path)
  12. target = ref[path[0]].node()
  13. else:
  14. target = sel
  15. target.setSelected(True)
  16. p = hou.ui.paneTabOfType(hou.paneTabType.NetworkEditor)
  17. p.setCurrentNode(target)
  18. p.homeToSelection()

版权说明
文章采用: 《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》许可协议授权。
版权声明:未标注转载均为本站原创,转载时请以链接形式注明文章出处。如有侵权、不妥之处,请联系站长删除。敬请谅解!

-- 展开阅读全文 --
这篇文章最后更新于2022-8-10,已超过 1 年没有更新,如果文章内容或图片资源失效,请留言反馈,我们会及时处理,谢谢!
如何利用vscode 写 Markdown笔记
« 上一篇
carbon学习之路(一)
下一篇 »

发表评论

已有 1 条评论

  1. silence V管理员

    说道:顶呱呱

HI ! 请登录
注册会员,享受下载全站资源特权。
暂不提供社交账号登录

今日事今日毕

今日已经过去 7 小时
30%
这周已经过去 3
42%
本月已经过去 21
67%
今年已经过去 5 个月
41%

标签

热门文章

2
Houdini vellum 学习 - 01
4
Houdini vellum 学习 - 02
5
carbon学习之路(一)