marwan131 Posted April 15, 2021 Share Posted April 15, 2021 (edited) hello , it's my first time i use python in houdini fx i know python from before but i never used it in houdini fx and it seems it's easier than vex to achieve the same task, my problem is i have an fbx file with shop_materialpath and there are different name in shop_materialpath i want to create a string channel for each unique name , that string channel it will be a path for ue4 material for example if i have 2 different name in shop_material the first one is TS_02 and the second is Roof_01 i want to create 2 string channel to expose it later to ue4 using hda first string pathmat1 and the second one is pathmat2 and they will be applied in an attribute name unreal_material or path , i want to automate this process because i want it to work on random asset if i dont know the name of the shop_materialpath the python script should loop in each primitive and see how many name there are in shop_material path and create string channels for them . i already made a script to store the name of the shop_materialpath in a dictionary and then i lost from where should i continue idk how to access primnum in python and idk how to create string channel like in vex using chs() here is my python code # Run a generator Box SOP Verb def grp_n(grp): myDict={} for mat in grp: if mat in myDict: myDict[mat]=1 else: myDict[mat]=1 return myDict node = hou.pwd() geo = node.geometry() dict={} list=[] for pri in geo.prims(): list.append(pri.attribValue("shop_materialpath")) l=grp_n(list) print l and i made a simple code in vex but in this case i already know the shop_material names and im testing using if conditions and applying string to the unreal_material , i want to automate this process to check how many names there are in shop_material path and then creating string channels for each one, sorry i dont know how to explain this in an easy way but my english is not too good string id1=chs("uemat1"); string id2=chs("uemat2"); string id3=chs("uemat3"); // testing conditions comparing the groups name if(s@shop_materialpath=="TS_02"){ s@unreal_material=id1; } else{ s@unreal_material=id2; } if(s@shop_materialpath=="Emissive_01"){ s@unreal_material=id3; } Edited April 16, 2021 by marwan131 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.