jordibares Posted February 7, 2014 Share Posted February 7, 2014 I am experiencing a behaviour when using object merge that is driving me mad… ok, here it goes… hopefully will be clear I have a car, 1 body and 4 wheels. All 5 elements are separate objects and I apply the materials at OBJ level too by drag&drop. But then I want to "collect" those objects so I can manipulate them as one when I object merge the OBJ the material is lost… it only works if I put a material node at SOP level which is not what I want. I am viewport century and the whole point of drag&drop at OBJ level seems to be lost. My question is… am I missing something or is this by design not possible? I already have a few workarounds but I just would like to know if this is possible. thanks in advance. Quote Link to comment Share on other sites More sharing options...
Guest tar Posted February 7, 2014 Share Posted February 7, 2014 my experience is no materials travel through the ObjectMerge Quote Link to comment Share on other sites More sharing options...
Netvudu Posted February 7, 2014 Share Posted February 7, 2014 (edited) to be more precise, no materials assigned at OBJ level travel through the Object Merge, and actually it makes sense. (I´m pretty sure you already know the following, but just in case) When you apply a material at OBJ level, you´re not actually applying any attributes to the geometry until it reaches the shader, which is where it´s reading that OBJ material info. Hence, there´s´no shop_material_path attribute applied yet and it reads whatever new material you apply at OBJ level. As you mentioned, if you apply the SOP Material and then merge that somewhere else, it does read it, because the shop_material_path is there already. I think it is designed this way, because that allows you to object merge some geometry, but choose a new material from OBJ level. But yes, from a drag&drop workflow POV, it´s not ideal. Just to put it from a different perspective. What if you wanted to keep on using drag&drop, but wanted a copy of your objects with different materials? Then, any other method would force you to use the SOP material again. Edited February 7, 2014 by Netvudu Quote Link to comment Share on other sites More sharing options...
jordibares Posted February 8, 2014 Author Share Posted February 8, 2014 Thanks Javier, I was not aware of the details (thanks for developing) but this is from the user experience point of view a bug… anyway, I guess a possible solution would be to always add a sop material reading the object material? I will try this on monday and see how it behaves as for me the drag and drop functionality is critical to scale teams up. :-) to be more precise, no materials assigned at OBJ level travel through the Object Merge, and actually it makes sense. (I´m pretty sure you already know the following, but just in case) When you apply a material at OBJ level, you´re not actually applying any attributes to the geometry until it reaches the shader, which is where it´s reading that OBJ material info. Hence, there´s´no shop_material_path attribute applied yet and it reads whatever new material you apply at OBJ level. As you mentioned, if you apply the SOP Material and then merge that somewhere else, it does read it, because the shop_material_path is there already. I think it is designed this way, because that allows you to object merge some geometry, but choose a new material from OBJ level. But yes, from a drag&drop workflow POV, it´s not ideal. Just to put it from a different perspective. What if you wanted to keep on using drag&drop, but wanted a copy of your objects with different materials? Then, any other method would force you to use the SOP material again. Quote Link to comment Share on other sites More sharing options...
Netvudu Posted February 9, 2014 Share Posted February 9, 2014 (edited) Sure. Python to the rescue! You could reference the object material from a Material SOP added to the Object Merge EDIT: I found a spare hour this weekend (of course it must be the weekend, otherwise there´s virtually no spare time) and created what you need. The attached shelf tool allows you to select from the viewer whichever object/s you need, and automagically brings them to a new node currently called "nuevo" (*ahem*you should change that ). It names each Object merge with the proper object´s name, and adds a material SOP (also with proper name) that references to the OBJ level material parameter, so if you change the original the new one follows. I had to choose the Object_merge transform mode for you, but it should be trivial changing that to what you need for a specific occasion. Finally, I didn´t crash-test it a lot. I just made sure that it works for objects at different levels and also it complains if you don´t select anything. Some more error-testing checks should be made prior to considering it production-ready. For instance, you could add checks to see if you decided to go the Material SOP route instead of using the OBJ-level material parameter for the original objects. The silly code is commented just in case you want to change anything. Hope it helps "realising" (huh-huh ) your pipeline. ObjectMergePlus.zip Edited February 9, 2014 by Netvudu Quote Link to comment Share on other sites More sharing options...
cowboy71 Posted November 24, 2015 Share Posted November 24, 2015 (edited) Hey Netvudu, Thank you so much for the script, works great. After running it and pushing it through a sim, I used an unpack to bring the textures back in the viewport but having same issue when rendered the geo is white. edit ( just had to dump the textures in the correct directory with the FBX.) Thanks again, that script rocks! Edited November 24, 2015 by cowboy71 Quote Link to comment Share on other sites More sharing options...
Netvudu Posted November 24, 2015 Share Posted November 24, 2015 You´re welcome! Happy it helped anybody. BTW, I still feel dizzy when I remember the number of margaritas I had in a mexican restaurant over there, in cool Santa Monica Quote Link to comment Share on other sites More sharing options...
hatrick Posted March 30, 2017 Share Posted March 30, 2017 could anyone take a look at this tool pls. it does not seem to work with the latest 16 builds. many thx Quote Link to comment Share on other sites More sharing options...
NNois Posted November 19, 2018 Share Posted November 19, 2018 (edited) in h17 you must comment the destroy function because the file node doesn't exist anymore import toolutils scene_viewer = toolutils.sceneViewer() # Ask for the objects to combine selected_objects = list(scene_viewer.selectObjects( prompt = toolutils.selectionPrompt(hou.objNodeTypeCategory()), allow_multisel = True, allowed_types = ("geo",))) # The following will raise an exception if nothing was selected. if len(selected_objects) == 0: raise hou.Error("Nothing was selected.") #print selected_objects # Create a new geo node, delete the file SOP and create a Merge SOP t= hou.node('/obj').createNode("geo","md_merge_1") # arch1= hou.node(t.path()+'/file1') # arch1.destroy() m1= t.createNode("merge") #Loop through every selected object and create an object merge and a # material SOP, both with the proper name and the original material. # Also set the object merge transform parameters and connect the material # SOP to the Merge. for s in selected_objects: om1=t.createNode("object_merge") nombre1= s.name() omname= "object_merge_"+nombre1 om1.setName(omname) om1.parm("objpath1").set(s.path()) om1.parm("xformtype").set(1) mat1=t.createNode("material") mat1.setName("material_"+nombre1) mat1.setFirstInput(om1) pmat1=mat1.parm("shop_materialpath1") mat_s= hou.parm(s.path()+"/shop_materialpath") pmat1.set(mat_s) m1.setNextInput(mat1) #Set all flags to the final Merge and properly place the nodes. #Also, go back to /obj level m1.setDisplayFlag(True) m1.setRenderFlag(True) for a in t.children(): a.moveToGoodPosition() t.moveToGoodPosition() t.setCurrent(True,True) toolutils.homeToSelectionNetworkEditorsFor(t) Edited November 19, 2018 by NNois 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.