Notifications
Clear all

[Closed] Scale UV's without going into the Unwrap Editor

I have a small UI with U and V spinners and a “Set” button to set the scale of UV’s on a selected object… I have written a script that works with selected texture vertices (in the Unwrap editor)

…but I wanted to know if there is a one line code to scale UV’s without having to select all texture vertices?

If not whats the best way to select all texture verts?

4 Replies

Scale based on what? Selection Center? UVW Center [0.5,0.5]? Random Point?

<void><Unwrap_UVW>.scaleSelectedCenter <float>scale <integer>dir
[left]Scales the selected sub-objects by the specified amount using the selection center. The dir integer defines the direction of scaling as follows:
[/left]
[left]0 – scale both X and Y
[/left]
[left]1 – scale X only
[/left]
[left]2 – scale Y only
[/left]
[left]Exposed via unwrap2 interface in 3ds Max 5 and higher.

<void><Unwrap_UVW>.ScaleSelected <float>scale <integer>dir <point3>axis
[/left]
[left]Scales the selected sub-objects by the specified amount using the specified axis. The dir integer defines the scaling mode as follows:
[/left]
[left]0 – scale both X and Y
[/left]
[left]1 – scale X only
[/left]
[left]2 – scale Y only
[/left]
[left]Exposed via unwrap2 interface in 3ds Max 5 and higher.
-Eric
[/left]

sorry in advance for any probable misspelling… i don’t have 3ds max on cell phone to verify the code…

if you want to change (scale) uv coords for editable polys (or editable meshes) you don't need to use (or apply and use) UVW Unwrap modifier. You can do it directly changing a map vert position:

  uv_channel = ... -- channel that you want to work on
  scale_center = ... -- let's say [0,0,0] 
   for node in <node_list> where iskindof node EditablePoly do
   (
     for v=1 to (polyop.getnummapverts node uv_channel) do
     (
  	   pos = polyop.getmapvert node uv_channel v
  	   pos = (pos - scale_center)*[u_scale_factor,v_scale_factor,1] + scale_center
  	   polyop.setmapvert node uv_channel v pos
     )
   )
   
  1. the easiest way to select all vertices in UVW unwrap modifier is

– modi is UVW unwrap modifier

all_verts = #{1…modi.numberVertices()}
modi.selectVerts all_verts – maybe modi.selectVertices (don’t remember)

if you need to do it for multiple nodes with the same modifier:


  for node in <node_list> do
  (
     all_verts_by_node = #{1..modi.numberVerticesByNode node:node} 
     modi.selectVertsByNode all_verts_by_node node:node
  )
  

thanks a lot… all sorted now

Thanks Denis… i wasnt thinking of adding this for multiple nodes but theres an idea and I will use it. much appreciated dude… thanks a lot (… and its modi.selectvertices)