Home Coding, Scripting, Shaders

[Max] Need help moving Multi-Object UV Islands/Sets

ngon master
Offline / Send Message
zachagreg ngon master
Hey currently I'm trying to sort through this piece of code that I've edited from one of @Ojah 's old posts. 
fn F_moveUV movePos = (
	if selection.count >= 1 do
	(
		SEL = selection as array
		for i = 1 to SEL.count do
		(
			print SEL[i]
			objMod = SEL[i].modifiers[#unwrap_uvw]
			objMod.unwrap2.faceToVertSelect() 
			print objMod

			vArray = objMod.getSelectedVertices()
			print vArray
			for vVar in vArray do
			(
						
			oldPos = objMod.getVertexPosition 0 vVar
			objMod.setVertexPosition 0 vVar (oldPos + movePos)
			)
		)
	)
)

I'm currently trying to have multiple objects selected with the Unwrap UVW modifier on it. With all of the UV islands/sets selected move them to a specific position within U1V1. The issue that I'm running into seems to be that the second object in the array "SEL" will not move even though the print SEL will show that the array is being processed with both objects.

I'm testing with two objects right now and haven't tried more than two yet. The function is executed later on in the script by a rollout button and I'm not getting any errors on that and the first item in the array does respond.

Also I don't particularly need an array if this can be done purely with a multiobject UV all selection and then moving that way. This is just what I could get semi-working with what I know.

Replies

  • zachagreg
    Options
    Offline / Send Message
    zachagreg ngon master
    I ended up solving what I needed in this case by changing it from two arrays to grabbing my previous selection and using the unwrap2 interface to move the entire selection by an offset which was set as a global variable.
    global movePos<br>fn F_moveUV movePos = (<br>	if selection.count >= 1 do<br>	(<br>		SEL = selection as array<br>		for i = 1 to SEL.count do<br>		(<br>					print SEL[i]<br>					objMod = SEL[i].modifiers[#unwrap_uvw]<br>					objMod.unwrap2.moveSelected movePos

    However I would still like to know if I'm just completely in the wrong assuming that you can for loop an array inside an array. Or where I went wrong with that.

    Also if someone can point me in the direction of the unwrap2 interface syntax. When I search for UV commands inside the max 2017 documentation there is the basic commands, but it just says its displayed through the unwrap2 interface with no further links or info on that. At least of what I could find.
  • monster
    Options
    Offline / Send Message
    monster polycounter
    This should show you all the Unwrap2 commands:
    showinterface unwrap_uvw.unwrap2

    When using a single unwrap mod on multiple objects you should use the ByNode commands available in the Unwrap6 interface. They are basically duplicates of the same commands with an extra parameter to specify the object to operate on.

    showinterface unwrap_uvw.unwrap6

    For your first script to work you would just need to change these two lines (I didn't test)

    			oldPos = objMod.getVertexPosition<b>ByNode</b> 0 vVar <b>SEL[i]</b>
    			objMod.setVertexPosition<b>ByNode</b> 0 vVar (oldPos + movePos) <b>SEL[i]</b>

  • zachagreg
    Options
    Offline / Send Message
    zachagreg ngon master
    Thank you very much for all of that. I'll run the first script with edits when I get home to test it out and report back, however what you've told me makes sense to me. Also thank you for those references to the interface of the unwraps. That issue has been plaguing me for a while.
Sign In or Register to comment.