Notifications
Clear all

[Closed] urgent help Script npot working UVWmap

hello, i´m trying to make a script to work with several objects apllying to them an uvwmap gizmo normal aligned to the objects face.
but it does not work it work for a single object but not a bunch of them can anyone help?

thankx bern.
script:

obj = selection as array
for i = 1 to obj.count do

(

faceArr = (polyop.getFaceSelection obj[i]) as array

faceNormal = in coordsys obj[i] (polyop.getFaceNormal obj[i] faceArr[1])

worldUpVector = [0,0,1]

rightVector = normalize (cross worldUpVector faceNormal)

upVector = normalize (cross rightVector faceNormal)

theMatrix = matrix3 rightVector upVector faceNormal [0,0,0]

— UVWmap modifier

addModifier obj[i] (Uvwmap())

—obj[i].modifiers[#UVW_Mapping].gizmo.transform = theMatrix

obj[i].modifiers[#UVW_Mapping].length = 40

obj[i].modifiers[#UVW_Mapping].width = 40

obj[i].modifiers[#UVW_Mapping].realWorldMapSize = on

print faceArr

)

3 Replies

sorry got mistaken this is the final one:

obj = selection as array

for i = 1 to obj.count do

(

faceArr = (polyop.getFaceSelection obj[i]) as array

faceNormal = in coordsys obj[i] (polyop.getFaceNormal obj[i] faceArr[1])

worldUpVector = [0,0,1]

rightVector = normalize (cross worldUpVector faceNormal)

upVector = normalize (cross rightVector faceNormal)

theMatrix = matrix3 rightVector upVector faceNormal [0,0,0]

— UVWmap modifier

addModifier obj[i] (Uvwmap())

obj[i].modifiers[#UVW_Mapping].gizmo.transform = theMatrix

obj[i].modifiers[#UVW_Mapping].length = 40

obj[i].modifiers[#UVW_Mapping].width = 40

obj[i].modifiers[#UVW_Mapping].realWorldMapSize = on

print faceArr

)

Try this. Might not be the most efficient, but it works. (Also added space for “in coordsys” )


  mxv = maxVersion()
  obj = selection as array
  for i = 1 to obj.count do (
  	select obj[i]
  	faceArr = (polyop.getFaceSelection obj[i]) as array	
  	if faceArr.count == 0 then (
  		-- No selection, then pick face 1. I suppose a popup with face number or something would also work here
  		faceArr=#(1)
  		-- If all faces then
  		--faceArr=#()
  		--x = polyOp.getNumFaces obj[i]
  		--for b = 1 to x do (
  		--	append faceArr b
  		--)
  	)
  	
  	faceNormal = in coordsys obj[i] (polyop.getFaceNormal obj[i] faceArr[1])
  	worldUpVector = [0,0,1]
  	rightVector = normalize (cross worldUpVector faceNormal)
  	upVector = normalize (cross rightVector faceNormal)
  	theMatrix = matrix3 rightVector upVector faceNormal [0,0,0]
  	
  	new = Uvwmap()
  	new.length = 40
  	new.width = 40
  	modPanel.addModToSelection new ui:on
  	new.gizmo.transform = theMatrix
  	
  	if mxv[1] >= 8000 then (
  		-- Only max 8 and above
  		new.realWorldMapSize = on
  	)
  	--print faceArr
  )
      

theres one litle thing i forgot …
i want to place the gizmo to the bottom edge of the object, by bottom i mean the lowest edge of the bounding box… gonna try that… hugs bern