|
|
|
Tell us what you think of the site.
|
Autodesk Media & Entertainment User Community
|
Autodesk® 3ds Max®
|
|
Autodesk® Maya®
|
|
Autodesk® Softimage®
|
|
Autodesk® MotionBuilder®
|
|
Autodesk® Mudbox™
|
|
Autodesk® ImageModeler™
|
|
Autodesk® Sketchbook® Pro
|
|
Autodesk® Smoke on Mac®
|
| MEL or PYTHON snap vertex constrain xy, zx, yz, like Max?
|
|
|
1.can we constrain edeges,face in maya like we can in max?
2.is there any snapping tools in maya?like snap to vertex, snap to face etc like in max?
thank you for taking the time to answer these questions.
it is important for modelers building a rational :)
| Attachment
|
|
|
|
|
|
there are a range of snapping/constrainting tools in maya.
On the status line (the bar BELOW menu bar which has File,Edit etc) you have icons with magnets on, from left to right activating them will do;
1. Snap to Grid (works best in orthographic views - side, top etc)
2. Snap to curve (will constrain movement to nearest curve)
3. Snap to vertex
4. Snap to imagePlane
5. Make Live tool (very useful, select an object you want to constrain thing to, make it live then all movements will follow that geometry’s surface)
You also have the align tool in maya which can be very useful under Modify -> Align Tool (and depend on which version of maya the Snap together tool)
and to constrain to 2 axis only, ctrl+lmb click on the axis you wan to pin.
Best to look up documentation on it all.
Lee Dunham | Character TD
ldunham.blogspot.com
|
|
|
|
this video explain what I mean
Note the difference ,max snap constraint plan XY no Z,,,Maya snap vertex constraint XY and Z
the operation snap of max it exists in of alias design ,autodesk maya familiar alias design,,,
|
|
|
|
//----Snap Objects
global proc ld_snapObjs() {
if(`window -ex ld_snapObjects_win`)
deleteUI ld_snapObjects_win ;
window -t "Snap Object" -s false ld_snapObjects_win ;
columnLayout -adj true ;
text -l "Snap Objects" ;
separator -style "in" ;
rowLayout -nc 2 ;
columnLayout -adj true ;
checkBox -l "Translate" -v 1 -onc "checkBoxGrp -e -en 1 snapTransAxis_cBoxGrp" -ofc "checkBoxGrp -e -en 0 snapTransAxis_cBoxGrp" snapTrans_cBox ;
checkBoxGrp -numberOfCheckBoxes 3 -cw3 40 40 40 -va3 1 1 1 -vertical -labelArray3 "X" "Y" "Z" snapTransAxis_cBoxGrp ;
setParent.. ;
columnLayout -adj true ;
checkBox -l "Rotate" -v 1 -onc "checkBoxGrp -e -en 1 snapRotAxis_cBoxGrp" -ofc "checkBoxGrp -e -en 0 snapRotAxis_cBoxGrp" snapRot_cBox ;
checkBoxGrp -numberOfCheckBoxes 3 -cw3 40 40 40 -va3 1 1 1 -vertical -labelArray3 "X" "Y" "Z" snapRotAxis_cBoxGrp ;
setParent.. ;
setParent.. ;
button -l "Snap" -h 35 -c ld_snapObjsCmd ;
setParent.. ;
showWindow ld_snapObjects_win ; } //----Snap Objects Command global proc ld_snapObjsCmd()
{
string $mySel[] = `ls -sl` ;
if (`size ($mySel)` >= 2)
{
float $pos[] = `xform -q -ws -rp $mySel[0]` ;
float $rot[] = `xform -q -ws -ro $mySel[0]` ;
for($i=1;$i<`size($mySel)`;$i++)
{
select -r $mySel[$i] ;
string $objType = `objectType $mySel[$i]` ;
if (`checkBox -q -v snapTrans_cBox` == 1)
{
if(`checkBoxGrp -q -v1 snapTransAxis_cBoxGrp`)
move -a -ws -rpr -x $pos[0] ;
if(`checkBoxGrp -q -v2 snapTransAxis_cBoxGrp`)
move -a -ws -rpr -y $pos[1] ;
if(`checkBoxGrp -q -v3 snapTransAxis_cBoxGrp`)
move -a -ws -rpr -z $pos[2] ;
}
if (`checkBox -q -v snapRot_cBox` == 1)
{
if(`checkBoxGrp -q -v1 snapRotAxis_cBoxGrp`)
rotate -ws -x $rot[0] ;
if(`checkBoxGrp -q -v2 snapRotAxis_cBoxGrp`)
rotate -ws -y $rot[1];
if(`checkBoxGrp -q -v3 snapRotAxis_cBoxGrp`)
rotate -ws -z $rot[2] ;
}
}
select $mySel ;
}
else
error ">>> Selected at least 2 Objects" ; }
command to use the script is
ld_snapObjs;
Lee Dunham | Character TD
ldunham.blogspot.com
|
|
|
|
|
whoops sorry wrong script, this will only really work on objects, not components as it’ll snap to pivot, making adjustments now.
Author: ldunham1
|
| Replied: 08 December 2011 09:12 PM
|
|
|
|
|
ok this should work.
a little different this time, you need to declare your target in the target field, just to cut down the need to get the component selection order, so select your target first, press the “<<” button to load it then select the verts you want to move and snap, turning off the axis you dont want to snap.
Will also work on objects (currently will only work properly on verts or objects).
//----Snap Objects
global proc ld_snapObjs() {
if(`window -ex ld_snapObjects_win`)
deleteUI ld_snapObjects_win ;
window -t "Snap Object" -s false ld_snapObjects_win ;
columnLayout -adj true ;
text -l "Snap Objects" ;
separator -style "in" ;
rowLayout -nc 3 -adj 2 ;
text -l "Target" ;
textField snapTarget_tField ;
button -l "<<" -c "string $mySel[]=`ls -sl`;textField -e -tx $mySel[0] snapTarget_tField;" ;
setParent.. ;
rowLayout -nc 2 ;
columnLayout -adj true ;
checkBox -l "Translate" -v 1 -onc "checkBoxGrp -e -en 1 snapTransAxis_cBoxGrp" -ofc "checkBoxGrp -e -en 0 snapTransAxis_cBoxGrp" snapTrans_cBox ;
checkBoxGrp -numberOfCheckBoxes 3 -cw3 40 40 40 -va3 1 1 1 -vertical -labelArray3 "X" "Y" "Z" snapTransAxis_cBoxGrp ;
setParent.. ;
columnLayout -adj true ;
checkBox -l "Rotate" -v 1 -onc "checkBoxGrp -e -en 1 snapRotAxis_cBoxGrp" -ofc "checkBoxGrp -e -en 0 snapRotAxis_cBoxGrp" snapRot_cBox ;
checkBoxGrp -numberOfCheckBoxes 3 -cw3 40 40 40 -va3 1 1 1 -vertical -labelArray3 "X" "Y" "Z" snapRotAxis_cBoxGrp ;
setParent.. ;
setParent.. ;
button -l "Snap" -h 35 -c ld_snapObjsCmd ;
setParent.. ;
showWindow ld_snapObjects_win ; } //----Snap Objects Command global proc ld_snapObjsCmd()
{
string $mySel[] = `ls -sl` ;
string $target=`textField-q -tx snapTarget_tField` ;
string $tFlag1="-rp" ;
if(`size($mySel)`>= 1 && size($target))
{
select -r $target ;
if(size(`filterExpand -sm 31`)>0)
$tFlag1="-t" ;
float $pos[] = `xform -q -ws $tFlag1 $target` ;
float $rot[] = `xform -q -ws -ro $target` ;
for($i=0;$i<`size($mySel)`;$i++)
{
select -r $mySel[$i] ;
string $objType = `objectType $mySel[$i]` ;
if (`checkBox -q -v snapTrans_cBox` == 1)
{
if(`checkBoxGrp -q -v1 snapTransAxis_cBoxGrp`)
move -a -ws -rpr -x $pos[0] ;
if(`checkBoxGrp -q -v2 snapTransAxis_cBoxGrp`)
move -a -ws -rpr -y $pos[1] ;
if(`checkBoxGrp -q -v3 snapTransAxis_cBoxGrp`)
move -a -ws -rpr -z $pos[2] ;
}
if (`checkBox -q -v snapRot_cBox` == 1)
{
if(`checkBoxGrp -q -v1 snapRotAxis_cBoxGrp`)
rotate -ws -x $rot[0] ;
if(`checkBoxGrp -q -v2 snapRotAxis_cBoxGrp`)
rotate -ws -y $rot[1];
if(`checkBoxGrp -q -v3 snapRotAxis_cBoxGrp`)
rotate -ws -z $rot[2] ;
}
}
select $mySel ;
}
else
error ">>> Need target and objects to snap." ; }
Usage is the same as before.
Lee Dunham | Character TD
ldunham.blogspot.com
|
|
|
|
yeah i see what you mean. You dont want to have to select each target, unfortunately i havent got time to fix it right now, but will have a go when i get the chance.
Lee Dunham | Character TD
ldunham.blogspot.com
|
|
|
|
|
|