XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : How to copy material id between polys ?

03-23-2006, 07:17 AM
Hello everyone

I want to use a script , it can copy material id ,I hope receive some information

for example ,I wan to A polyface id = B polyface id, subject mode ,I select A polyface, run a script , select B polyface

then A id = B id ,

It resemble this tools:
fn getObjMat =
local objPick
objPick=pickObject prompt:"select the obj you want copy the material"
local lwh
local lwhMd=1
for i=1 to numobjSel do objSel[i].material=objPick.material
try lwh=[(objpick.modifiers[#uvw_mapping].length),(objpick.modifiers[#uvw_mapping].width),(objpick.modifiers[#uvw_mapping].height)] catch(lwhMd=0; print( "can't Get=>Copy the uvwMap modifier") )
if lwhMd==1 do
addModifier objSel (Uvwmap length:lwh.x width:lwh.y height:lwh.z mapType:mp.mapType utile:mp.utile uflip:mp.uflip vtile:mp.vtile vflip:mp.vflip wtile:mp.wtile wflip:mp.wflip channel:mp.channel mapchannel:mp.mapchannel axis:mp.axis)

03-23-2006, 10:03 AM

Sometihng like this:

cpyMatID = undefined
try(destroyDialog cpyMat)catch()
rollout cpyMat "Copy Mat ID" width:88 height:72
button cpy "Copy Mat ID" pos:[8,8] width:72 height:24
button pst "Paste Mat ID" pos:[8,40] width:72 height:24 enabled:false

on cpy pressed do
if selection.count == 1 and classOf selection[1] == Editable_Poly then
theObj = selection[1]
faceSel = (theObj.selectedfaces as bitarray) as array
if faceSel.count == 1 then
cpyMatID = polyop.getFaceMatID theObj faceSel[1]
pst.enabled = true
else messageBox "Please select just one face to copy Material ID from" title:"Copy Material ID"
else messageBox "Please select just one Editable Poly object." title:"Copy Material ID"

on pst pressed do
for o in selection where classOf o == Editable_Poly do
for f in (polyop.getFaceSelection o) do polyop.setFaceMatID o f cpyMatID
createDialog cpyMat


Run the script and use the buttons :)

03-24-2006, 02:13 AM
Hi Moosley thanks

The code works very good ,but I feel it's work mode is trouble a little

I don't want that buttons

Can you change it , let it transfer polyface id

For example want to A id = B id
first select polyface A ,run code , select B poly face , then A id = B id

Thank you once

03-24-2006, 09:50 AM
I think the script I posted is probably one of the safer way to approch it (I could be wrong), the way you described it sounds like it would need a mouse tool or ray intersect test to pick a sub-object face selection which could be a bit unreliable and really works best on editable meshes... This script will remember the material ID you copied and you can paste it to as many faces as you like over and over again with just one click :)

03-30-2006, 01:50 AM
You are right,I have decied to use you tool !!

CGTalk Moderation
03-30-2006, 01:50 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.