PDA

View Full Version : script does not work as intended - no logic at all


Diancoff
11-14-2010, 11:40 AM
Ok, I'm trying to make a script that applies box mapping to a group of objects and moves the UVs to positive X and Y space. Doesn't sound so hard, right?

Well, for example if I add convertto $ editable_poly at the end of the script to collapse the stack, the vertices don't get aligned at all.

Also, despite the "for" loop I can't get the vertices to move on more than 1 object.

And, so on... Here is the script. Can anyone point me some errors that I've made, please?

fn applyMapping =
(
-- Apply box mapping
max modify mode
uv = uvwmap maptype:4 realWorldMapSize:true
for obj in selection do
(
convertto obj editable_poly
addModifier obj uv
convertto obj editable_poly
)
uv.gizmo.position = [0,0,0]
)

fn alignMapVerts =
(
for obj in selection do
(
convertto obj editable_poly
unw = unwrap_UVW()
addModifier obj unw
all_verts = #{1..unw.numberVertices()}
unw.selectVertices all_verts
pos = polyop.getmapvert obj 1 1
minx = pos[1]
miny = pos[2]
for v=1 to (polyop.getnummapverts obj 1) do
(
pos = polyop.getmapvert obj 1 v
if pos[1] < minx then minx=pos[1]
if pos[2] < miny then miny=pos[2]
)
unw.moveSelectedVertices [-minx,-miny,0]
convertto obj editable_poly
)
)

JHN
11-14-2010, 08:58 PM
Have you though about using the uvXform modifier and just use the offset parameters?

-Johan

CGTalk Moderation
11-14-2010, 08:58 PM
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.