ScriptSpot is a diverse online community of artists and developers who come together to find and share scripts that empower their creativity with 3ds Max. Our users come from all parts of the world and work in everything from visual effects to gaming, architecture, students or hobbyists.
For now I added new argument "center". If "on" then gizmo will be placed at the center else at the pivot position.
fn getMody node modyClass: = if node.modifiers.count > 0 do(
local mody
for m in node.modifiers while mody == undefined where iskindof m modyClass do mody = m ; mody
)
mapped fn resetModyGizmoTm nodes whichClass: center: = if isValidNode nodes do(
mody = getMody nodes modyClass:whichClass
if mody != null and validModifier nodes mody do(
tm = if center then (translate (matrix3 1)(in coordsys nodes.objecttransform nodes.center))else(matrix3 1)
case of
((isProperty mody #gizmo) : mody.gizmo.transform = tm
(isProperty mody #slice_plane) : mody.slice_plane.transform = tm
)))
resetModyGizmoTm selection whichClass:SliceModifier center:off
-- this code reset the uvw map on selected object-- insert true the thing that you want to reset [I include position, rotation & scale]
fn centerTheUvwGizmo resetPos:true resetRot:false resetScales:false =
(for i in selectiondo(for y in i.modifiers where isKindof y Uvwmap do(
with undo "uvwmap gizmo center" on
(--theGismoPos= [0,0,i.center[3]]if resetPos == truedo y.gizmo.position = [0,0,0]if resetRot== truedo y.gizmo.rotation = (quat 0 0 -1 0)if resetScales == truedo y.gizmo.scale = [1,1,1]))))
usage : select object that already had uvwmap modifier then execute the function [Ctrl+E]
ex: if you want to reset scale only you only need to change resetScales from false to true
your code not working simple because many unworking part:
select i == --why do you use this ? I already define for something in selection
mod_obj = modPanel.getCurrentObject()--- this is too , when you already define for y in i.modifier....unworking
gizmo_rotation = mod_obj.gizmo.rotation --- gizmo rotation refer to quat matrix not eulerangle,see maxscript help about uvwmaping modifier
mod_obj.gizmo.rotation = gizmo_rotation *((eulerangles 0900) as quat)----refer to above.
clearSelection()--- why do you need to clear selection )
below simple design UI to make it better understanding how to use
fn centerTheUvwGizmo resetPos:true resetRot:false resetScales:false =
(for i in selectiondo(for y in i.modifiers where isKindof y Uvwmap do(
with undo "uvwmap gizmo center" on
(--theGismoPos= [0,0,i.center[3]]if resetPos == truedo y.gizmo.position = [0,0,0]if resetRot== truedo y.gizmo.rotation = (quat 0 0 -1 0)if resetScales == truedo y.gizmo.scale = [1,1,1]))))
rollout resetUvw "Untitled" width:162 height:125(
button btn1 "reset uvw pos" pos:[5,9] width:138 height:26
button btn2 "reset uvw sccale" pos:[6,38] width:138 height:26
button btn3 "reset uvw rotation" pos:[6,67] width:138 height:26
button btn4 "reset all" pos:[5,94] width:138 height:26
on btn1 pressed do(
centerTheUvwGizmo resetPos:true resetRot:false resetScales:false)
on btn2 pressed do(
centerTheUvwGizmo resetPos:false resetRot:false resetScales:true)
on btn3 pressed do(
centerTheUvwGizmo resetPos:false resetRot:true resetScales:false)
on btn4 pressed do(
centerTheUvwGizmo resetPos:true resetRot:true resetScales:true))
createDialog resetUvw
fn centerAllTheModifierGizmo =
(for i in selectiondo(for y in i.modifiers where (hasProperty y "gizmo")do(
with undo "center gizmo" on
(
theGismoPos= [0,0,i.center[3]]
setproperty y.gizmo "position" theGismoPos
))))
Thanks, regarding the centerAllTheModifierGizmo.
But that would require that the gizmo is called "Gizmo".
What if you want to extend the capacity of the script: For example, slice, uses gizmo name "Slice Plane".
I like your UI. The same features could be available for e.g. Slice: Reset Position, Scale and rotation. You could either make your code generic, compatible with all types of gizmos, or you could add items successively every time you want to make it compatible with yet one more item.
Further features could be that it works on sub-object "gizmos", for example in Editable Poly > Slice plane.
- center gizmo to selection.
- scale gizmo to selection
good reply thank you
i made this rotuine with your routine
but that is not work
there is many modifier ex) edit poly , shell , uvwmap
i would like to roate uvw gizmo only
what problem this code ?
ifselection[1]!= undefined do(for i in selectiondo(for y in i.modifiers where isKindof y Uvwmap do(
with undo "uvwmap gizmo center" on
(
select i
mod_obj = modPanel.getCurrentObject()
gizmo_rotation = mod_obj.gizmo.rotation
mod_obj.gizmo.rotation = gizmo_rotation *((eulerangles 0900) as quat)
clearSelection()))))
fn centerTheUvwGizmo =
(for i in selectiondo(for y in i.modifiers where isKindof y Uvwmap do(
with undo "uvwmap gizmo center" on
(
theGismoPos= [0,0,i.center[3]]
y.gizmo.position = theGismoPos
))))
its still raw tho, but work :)
how to :
select object that have uvwmap modifiers and run the function
Comments
...part2 (option "center")
For now I added new argument "center". If "on" then gizmo will be placed at the center else at the pivot position.
bga
...
Now how to use it
It's very simple, just select some objects and run this code
NOTE: in "whichClass" argument put any modifiers class
bga
-- this code reset the uvw
usage : select object that already had uvwmap modifier then execute the function [Ctrl+E]
ex: if you want to reset scale only you only need to change resetScales from false to true
your code not working simple because many unworking part:
below simple design UI to make it better understanding how to use
try this...fn
try this...
usage:
alternatively you can change i.center[3] to 0
.
Thanks, regarding the centerAllTheModifierGizmo.
But that would require that the gizmo is called "Gizmo".
What if you want to extend the capacity of the script: For example, slice, uses gizmo name "Slice Plane".
I like your UI. The same features could be available for e.g. Slice: Reset Position, Scale and rotation. You could either make your code generic, compatible with all types of gizmos, or you could add items successively every time you want to make it compatible with yet one more item.
Further features could be that it works on sub-object "gizmos", for example in Editable Poly > Slice plane.
- center gizmo to selection.
- scale gizmo to selection
Kind regards
Haider
www.haider.se
... universal solution
This functions allows you to reset any modifiers gizmo transform(of course if it have one)
bga
rotate gizmo
good reply thank you
i made this rotuine with your routine
but that is not work
there is many modifier ex) edit poly , shell , uvwmap
i would like to roate uvw gizmo only
what problem this code ?
what the meaning to all gizmo
what the meaning to all gizmo ? all kind of modifier that have gizmo?
More ideas
@fajar: I wonder if this code can be rewritten to fit to all kind of gizmos?
Kind regards
Haider
www.haider.se
fn centerTheUvwGizmo =( for
its still raw tho, but work :)
how to :
select object that have uvwmap modifiers and run the function