
now i can see my mistakes, i'm learning very slowly, sorry.
ciao beppe
how can I identify the material if same type in the two materials?stratified wrote:
Yes, it's possible but now you would have 3 things in your selection and 6 different cases to consider...
I want to automate the connection of materials that I did for Daz Victoriastratified wrote: I'm not sure what you're trying to accomplish with your script? You just want to make the connectios or is there a general rule to which connections to make? You could store a table mapping a material to all the pins on the mesh it connects to and loop over this to make the desired connections.
Code: Select all
-- maps a matterial to all the pins connections = { ["V6Torso"] = { "dzmat_Head", "dzmat_Neck", "dzmat_Hips", "dzmat_Torso" } } for i,pinName in ipairs(connections["V6Torso"]) do print(string.format("connect material %s to pin %s", "V6Torso", pinName)) -- do the connections here... end
Code: Select all
--
-- Select a mesh and mats in strict sequence
--
local mesh, limbs, face, lips, torso = nil, nil, nil, nil, nil
local selection = octane.project.getSelection()
if #selection ~= 5 then error("a material and a mesh needs to be selected") end
mesh, limbs, face, lips, torso = selection[1], selection[2], selection[3], selection[4], selection[5]
-- connect the material to a pins of the mesh
pinIx=1,mesh:getPinCount()
mesh:connectToIx(pinIx, limbs)
pinIx=3,mesh:getPinCount()
mesh:connectToIx(pinIx, face)
pinIx=6,mesh:getPinCount()
mesh:connectToIx(pinIx, lips)
pinIx=12,mesh:getPinCount()
mesh:connectToIx(pinIx, face)
pinIx=16,mesh:getPinCount()
mesh:connectToIx(pinIx, torso)
pinIx=17,mesh:getPinCount()
mesh:connectToIx(pinIx, limbs)
pinIx=18,mesh:getPinCount()
mesh:connectToIx(pinIx, limbs)
pinIx=19,mesh:getPinCount()
mesh:connectToIx(pinIx, torso)
pinIx=20,mesh:getPinCount()
mesh:connectToIx(pinIx, torso)
pinIx=21,mesh:getPinCount()
mesh:connectToIx(pinIx, torso)
pinIx=22,mesh:getPinCount()
mesh:connectToIx(pinIx, torso)
pinIx=23,mesh:getPinCount()
mesh:connectToIx(pinIx, limbs)
pinIx=24,mesh:getPinCount()
mesh:connectToIx(pinIx, limbs)
pinIx=28,mesh:getPinCount()
mesh:connectToIx(pinIx, torso)
myMaterialNode:getProperties().name
). If both name and type are identical, there's no easy way to distinguish them.myMeshNode:connectTo("dzmat_Neck", v6TorsoNode)
. You should only use the index of a pin when iterating over all the pins. Otherwise you should use the name or the id of the pin. It makes the code more readable.pinIx=1,mesh:getPinCount()
doesn't do anything for you mesh:getPinCount()
is superfluous. Are you sure that mesh is really a mesh? The selection depends on how you dragged the lasso in the nodegraph editor.Code: Select all
local v6mesh, mtorso, mface = nil, nil, nil
local selection = octane.project.getSelection()
if selection[1]:getProperties().type == octane.NT_GEO_MESH then
v6mesh = selection[1]
elseif selection[1]:getProperties().name == "torso" then
mtorso = selection[1]
elseif selection[1]:getProperties().name == "face" then
mface = selection[1]
end
if selection[2]:getProperties().type == octane.NT_GEO_MESH then
v6mesh = selection[2]
elseif selection[2]:getProperties().name == "torso" then
mtorso = selection[2]
elseif selection[2]:getProperties().name == "face" then
mface = selection[2]
end
if selection[3]:getProperties().type == octane.NT_GEO_MESH then
v6mesh = selection[3]
elseif selection[3]:getProperties().name == "torso" then
mtorso = selection[3]
elseif selection[3]:getProperties().name == "face" then
mface = selection[3]
end
v6mesh:connectTo("Head", mtorso)
v6mesh:connectTo("Ears", mtorso)
v6mesh:connectTo("Neck", mtorso)
v6mesh:connectTo("Torso", mtorso)
v6mesh:connectTo("Nipples", mtorso)
v6mesh:connectTo("Hips", mtorso)
v6mesh:connectTo("Face", mface)
v6mesh:connectTo("Nostrils", mface)
Hi there,Slide3D wrote:Stratified
Yes!!! I did it!
Code: Select all
local v6mesh, mtorso, mface = nil, nil, nil local selection = octane.project.getSelection() if selection[1]:getProperties().type == octane.NT_GEO_MESH then v6mesh = selection[1] elseif selection[1]:getProperties().name == "torso" then mtorso = selection[1] elseif selection[1]:getProperties().name == "face" then mface = selection[1] end if selection[2]:getProperties().type == octane.NT_GEO_MESH then v6mesh = selection[2] elseif selection[2]:getProperties().name == "torso" then mtorso = selection[2] elseif selection[2]:getProperties().name == "face" then mface = selection[2] end if selection[3]:getProperties().type == octane.NT_GEO_MESH then v6mesh = selection[3] elseif selection[3]:getProperties().name == "torso" then mtorso = selection[3] elseif selection[3]:getProperties().name == "face" then mface = selection[3] end v6mesh:connectTo("Head", mtorso) v6mesh:connectTo("Ears", mtorso) v6mesh:connectTo("Neck", mtorso) v6mesh:connectTo("Torso", mtorso) v6mesh:connectTo("Nipples", mtorso) v6mesh:connectTo("Hips", mtorso) v6mesh:connectTo("Face", mface) v6mesh:connectTo("Nostrils", mface)
Thanks!stratified wrote: Congrats, keep up the good work! Is this pass of a larger project or was it just a test with lua?
cheers,
Thomas
Will your script be available or only for your personal useSlide3D wrote:my work which had painstakingly hand joining materials
it was very boring
http://slide3d.deviantart.com/gallery/40795322
principle is shown in the script that I postedTugpsx wrote: Will your script be available or only for your personal use