Modification on this script... 3d ui align set a minimum handle length
I tried contacting the creator but no luck.
The script works great, but there is one annoying thing, the handle length is based on the selection of the verts. So if you have verts that are just slightly off and you run the script you have to zoom in a lot to see which handle alignment you are activating.
Basically i would like the handles to have a set minimum length so they are easy to see and select.
Anyone out there that could modify it to work, would be much appreciated.
thx
here is the script:
--------------------------------------
-- 3D UI Vertex Align Tool v1.0 --
-- Created by Trent Fealy --
-- www.studiosyntax.net --
--------------------------------------
global VertexAligner
global draw = false
global SelectedPoint = 0
global X = #([0,0,0], [0,0,0], [0,0,0])
global Y = #([0,0,0], [0,0,0], [0,0,0])
global Z = #([0,0,0], [0,0,0], [0,0,0])
global P = #([0,0,0], [0,0,0])
global screenpoints= #([0,0,0], [0,0,0], [0,0,0], [0,0,0], [0,0,0], [0,0,0], [0,0,0])
global BitVertArray
global VertArray
global amount
fn Align =
(
selectionarray = getCurrentSelection()
if classOf selectionarray[1] == Editable_Poly do
(
BitVertArray = polyop.getVertSelection selectionarray[1]
VertArray = BitVertArray as array
amount = BitVertArray.count
print "asda"
for i = 1 to amount do
(
if BitVertArray[i] == true do
(
original = polyop.getVert selectionarray[1] i
if SelectedPoint == 1 do
(
original[1]=X[1][1]
)
if SelectedPoint == 2 do
(
original[1]=X[2][1]
)
if SelectedPoint == 3 do
(
original[2]=Y[1][2]
)
if SelectedPoint == 4 do
(
original[2]=Y[2][2]
)
if SelectedPoint == 5 do
(
original[3]=Z[1][3]
)
if SelectedPoint == 6 do
(
original[3]=Z[2][3]
)
polyop.setVert selectionarray[1] i original
)
)
)
)
fn AlignInfo =
(
selectionarray = getCurrentSelection()
if classOf selectionarray[1] == Editable_Poly do
(
BitVertArray = polyop.getVertSelection selectionarray[1]
VertArray = BitVertArray as array
amount = BitVertArray.count
init = false
for i = 1 to amount do
(
if BitVertArray[i] == true do
(
original = polyop.getVert selectionarray[1] i
if init == false do
(
X[1][1]= original[1]
X[2][1]= original[1]
Y[1][2]= original[2]
Y[2][2]= original[2]
Z[1][3]= original[3]
Z[2][3]= original[3]
)
init = true
if original[1] < X[1][1] do
(
X[1][1] = original[1]
)
if original[1] > X[2][1] do
(
X[2][1] = original[1]
)
if original[2] < Y[1][2] do
(
Y[1][2] = original[2]
)
if original[2] > Y[2][2] do
(
Y[2][2] = original[2]
)
if original[3] < Z[1][3] do
(
Z[1][3] = original[3]
)
if original[3] > Z[2][3] do
(
Z[2][3] = original[3]
)
)
)
X[3][1] = X[1][1] + (X[2][1] - X[1][1] ) /2
Y[3][2] = Y[1][2] + (Y[2][2] - Y[1][2] ) /2
Z[3][3] = Z[1][3] + (Z[2][3] - Z[1][3] ) /2
)
)
fn redrawviews_callback_function =
(
if draw == true do
(
X[1][2] = Y[3][2]
X[1][3] = Z[3][3]
X[2][2] = Y[3][2]
X[2][3] = Z[3][3]
X[3][2] = Y[3][2]
X[3][3] = Z[3][3]
Y[1][1] = X[3][1]
Y[1][3] = Z[3][3]
Y[2][1] = X[3][1]
Y[2][3] = Z[3][3]
Z[1][1] = X[3][1]
Z[1][2] = Y[3][2]
Z[2][1] = X[3][1]
Z[2][2] = Y[3][2]
gw.setTransform(Matrix3 1)
p[1]= gw.wTransPoint X[1]
gw.setTransform(Matrix3 1)
p[2] = gw.wTransPoint X[2]
gw.setTransform(Matrix3 1)
mid = gw.wTransPoint X[3]
screenpoints[1] = p[1]
screenpoints[2] = p[2]
gw.setColor #line [50,171,248]
gw.wPolyline p false
gw.wMarker p[1] #smallDiamond color:[0,30,255]
gw.wMarker p[2] #smallDiamond color:[0,30,255]
gw.wMarker mid #smallDiamond color:[0,30,255]
gw.setTransform(Matrix3 1)
p[1]= gw.wTransPoint Y[1]
gw.setTransform(Matrix3 1)
p[2] = gw.wTransPoint Y[2]
screenpoints[3] = p[1]
screenpoints[4] = p[2]
gw.setColor #line [50,171,248]
gw.wPolyline p false
gw.wMarker p[1] #smallDiamond color:[0,30,255]
gw.wMarker p[2] #smallDiamond color:[0,30,255]
gw.setTransform(Matrix3 1)
p[1]= gw.wTransPoint Z[1]
gw.setTransform(Matrix3 1)
p[2] = gw.wTransPoint Z[2]
screenpoints[5] = p[1]
screenpoints[6] = p[2]
screenpoints[7] = mid
gw.setColor #line [50,171,248]
gw.wPolyline p false
gw.wMarker p[1] #smallDiamond color:[0,30,255]
gw.wMarker p[2] #smallDiamond color:[0,30,255]
if SelectedPoint > 0 do
(
gw.wMarker screenpoints[SelectedPoint] #circle color:green
)
)
gw.enlargeUpdateRect #whole
gw.updateScreen()
)
fn newselection ev nd =
(
AlignInfo()
completeRedraw()
)
tool MouseAlign
(
local MousePosition = [0,0,0]
local ClosestDistance =10
on freeMove do
(
MousePosition[1]=mouse.pos[1]
MousePosition[2]=mouse.pos[2]
SelectedPoint =0
ClosestDistance =10
for i =1 to screenpoints.count do
(
screenpoints[i][3] = 0
PointDistance = distance MousePosition screenpoints[i]
if PointDistance < ClosestDistance do
(
SelectedPoint = i
ClosestDistance = PointDistance
)
)
completeRedraw()
)
on mousePoint clickno do
(
if SelectedPoint > 0 do
(
Align()
VertexAligner.bbox.state = false
draw = false
completeRedraw()
#stop
)
)
on mouseMove clickno do
(
MousePosition[1]=mouse.pos[1]
MousePosition[2]=mouse.pos[2]
SelectedPoint =0
ClosestDistance =10
for i =1 to screenpoints.count do
(
screenpoints[i][3] = 0
PointDistance = distance MousePosition screenpoints[i]
if PointDistance < ClosestDistance do
(
SelectedPoint = i
ClosestDistance = PointDistance
)
)
completeRedraw()
)
on mouseAbort clickno do
(
VertexAligner.bbox.state = false
draw = false
completeRedraw()
)
)
rollout VertexAligner "3D UI Vertex Aligner"
(
checkbutton bbox "Align"
on bbox changed state do
(
if state == on do (
AlignInfo()
draw = true
startTool MouseAlign
)
)
on VertexAligner open do
(
unregisterRedrawViewsCallback redrawviews_callback_function
registerRedrawViewsCallback redrawviews_callback_function
)
on VertexAligner close do
(
unregisterRedrawViewsCallback redrawviews_callback_function
stopTool MouseAlign
completeRedraw()
)
)
createdialog VertexAligner width:100 height:100 style:#(#style_toolwindow,#style_resizing,#style_sysmenu)
Comments
Thanks for the modification.
Thanks for the modification.
Principal Environment Artist
https://www.artstation.com/jeffross
www.custom-airbrush.com
try using " ... " (without
try using ["code] ... [/code"] (without the ") to make your posted code more readable
Never get low & slow & out of ideas
Go here
Go here
Tools and Scripts for Autodesk 3dsMax
Anyone care to crack at
Anyone care to crack at it?
thx
Principal Environment Artist
https://www.artstation.com/jeffross
www.custom-airbrush.com