Notifications
Clear all

[Closed] How to copy material id between polys ?

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 =
(
objSel=getCurrentSelection()
numobjSel=objSel.count
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
(
pG=objPick.modifiers[#uvw_mapping].gizmo.pos
sG=objPick.modifiers[#uvw_mapping].gizmo.scale
rG=objPick.modifiers[#uvw_mapping].gizmo.rotation
gP=objPick.modifiers[#uvw_mapping].gizmo
mP=objPick.modifiers[#uvw_mapping]

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)
redrawViews()
objSel[1].modifiers[#uvw_mapping].gizmo.pos.z=pG.z
objSel[1].modifiers[#uvw_mapping].gizmo.scale=sG
objSel[1].modifiers[#uvw_mapping].gizmo.rotation=rG
)
)
getObjMat()
)

4 Replies

Hi!

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

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

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

You are right,I have decied to use you tool !!