This commit is contained in:
2025-04-17 04:52:48 +08:00
commit 9985b73dc1
3708 changed files with 2387532 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,128 @@
// ===========================================================================
// Copyright 2022 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
// ===========================================================================
proc setOptionVars(int $forceFactorySettings)
{
optionVar -init $forceFactorySettings -category "Modify.Match Pivots"
-iv matchRotPivot 1
-iv matchScalePivot 1
-iv matchPivotOrient 1 // Default is off (for backcomp)
;
}
global proc performMatchPivotsSetup(string $parent, int $forceFactorySettings)
{
setOptionVars ($forceFactorySettings);
setParent $parent;
int $rot = `optionVar -q matchRotPivot`;
int $scale = `optionVar -q matchScalePivot`;
int $ori = `optionVar -q matchPivotOrient`;
checkBoxGrp -e -v1 $rot -v2 $scale -v3 $ori matchPivotsCheckBoxGrp;
}
global proc performMatchPivotsCallback(string $parent, int $doIt)
{
setParent $parent;
optionVar -iv matchRotPivot `checkBoxGrp -q -v1 matchPivotsCheckBoxGrp`;
optionVar -iv matchScalePivot `checkBoxGrp -q -v2 matchPivotsCheckBoxGrp`;
optionVar -iv matchPivotOrient `checkBoxGrp -q -v3 matchPivotsCheckBoxGrp`;
if ($doIt) {
performMatchPivots 0;
addToRecentCommandQueue "performMatchPivots 0" "MatchPivots";
}
}
proc performMatchPivotsOptions()
{
string $commandName = "performMatchPivots";
string $callback = ($commandName + "Callback");
string $setup = ($commandName + "Setup");
string $layout = getOptionBox();
setParent $layout;
setUITemplate -pushTemplate DefaultTemplate;
waitCursor -state 1;
tabLayout -tabsVisible 0 -scrollable 1;
string $parent = `columnLayout -adjustableColumn 1`;
checkBoxGrp -label (uiRes("m_performMatchPivots.kPivots"))
-ncb 3 -vertical
-label1 (uiRes("m_performMatchPivots.kRotate"))
-label2 (uiRes("m_performMatchPivots.kScale"))
-label3 (uiRes("m_performMatchPivots.kOrient"))
matchPivotsCheckBoxGrp;
waitCursor -state 0;
setUITemplate -popTemplate;
button -edit
-label `runTimeCommand -q -label MatchPivots`
-command ($callback + " " + $parent + " " + 1)
`getOptionBoxApplyBtn`;
button -edit
-command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
`getOptionBoxSaveBtn`;
button -edit
-command ($setup + " " + $parent + " " + 1)
`getOptionBoxResetBtn`;
setOptionBoxTitle `runTimeCommand -q -ann MatchPivotsOptions`;
setOptionBoxHelpTag("MatchPivots");
eval (($setup + " " + $parent + " " + 0));
showOptionBox();
}
proc string assembleCmd()
{
setOptionVars(false);
int $rot = 1;
int $scale = 1;
int $ori = 1;
string $cmd = "";
if ($rot || $scale) {
$cmd = "matchTransform";
if ($rot && $scale) {
$cmd += " -piv";
} else if ($scale) {
$cmd += " -sp";
} else /*if ($rot)*/ {
$cmd += " -rp";
}
}
if ($ori) {
if ($cmd != "") $cmd += "; ";
$cmd += "matchPivotOrient";
}
return $cmd;
}
global proc string performMatchPivots(int $action)
{
string $cmd = "";
switch ($action) {
case 0: // Execute command
$cmd = `assembleCmd`;
if ($cmd != "") eval($cmd);
break;
case 1: // Options
performMatchPivotsOptions;
break;
case 2: // Command string
$cmd = `assembleCmd`;
break;
}
return $cmd;
}
performMatchPivots(0);

View File

@ -0,0 +1,128 @@
// ===========================================================================
// Copyright 2021 Autodesk, Inc. All rights reserved.
//
// Use of this software is subject to the terms of the Autodesk license
// agreement provided at the time of installation or download, or which
// otherwise accompanies this software in either electronic or hard copy form.
// ===========================================================================
proc setOptionVars(int $forceFactorySettings)
{
if ($forceFactorySettings || !`optionVar -exists matchRotPivot`)
optionVar -iv matchRotPivot 1;
if ($forceFactorySettings || !`optionVar -exists matchScalePivot`)
optionVar -iv matchScalePivot 1;
if ($forceFactorySettings || !`optionVar -exists matchPivotOrient`)
optionVar -iv matchPivotOrient 0; // Default is off (for backcomp)
}
global proc performMatchPivotsSetup(string $parent, int $forceFactorySettings)
{
setOptionVars ($forceFactorySettings);
setParent $parent;
int $rot = `optionVar -q matchRotPivot`;
int $scale = `optionVar -q matchScalePivot`;
int $ori = `optionVar -q matchPivotOrient`;
checkBoxGrp -e -v1 $rot -v2 $scale -v3 $ori matchPivotsCheckBoxGrp;
}
global proc performMatchPivotsCallback(string $parent, int $doIt)
{
setParent $parent;
optionVar -iv matchRotPivot `checkBoxGrp -q -v1 matchPivotsCheckBoxGrp`;
optionVar -iv matchScalePivot `checkBoxGrp -q -v2 matchPivotsCheckBoxGrp`;
optionVar -iv matchPivotOrient `checkBoxGrp -q -v3 matchPivotsCheckBoxGrp`;
if ($doIt) {
performMatchPivots 0;
addToRecentCommandQueue "performMatchPivots 0" "MatchPivots";
}
}
proc performMatchPivotsOptions()
{
string $commandName = "performMatchPivots";
string $callback = ($commandName + "Callback");
string $setup = ($commandName + "Setup");
string $layout = getOptionBox();
setParent $layout;
setUITemplate -pushTemplate DefaultTemplate;
waitCursor -state 1;
tabLayout -tabsVisible 0 -scrollable 1;
string $parent = `columnLayout -adjustableColumn 1`;
checkBoxGrp -label (uiRes("m_performMatchPivots.kPivots"))
-ncb 3 -vertical
-label1 (uiRes("m_performMatchPivots.kRotate"))
-label2 (uiRes("m_performMatchPivots.kScale"))
-label3 (uiRes("m_performMatchPivots.kOrient"))
matchPivotsCheckBoxGrp;
waitCursor -state 0;
setUITemplate -popTemplate;
button -edit
-label `runTimeCommand -q -label MatchPivots`
-command ($callback + " " + $parent + " " + 1)
`getOptionBoxApplyBtn`;
button -edit
-command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
`getOptionBoxSaveBtn`;
button -edit
-command ($setup + " " + $parent + " " + 1)
`getOptionBoxResetBtn`;
setOptionBoxTitle `runTimeCommand -q -ann MatchPivotsOptions`;
setOptionBoxHelpTag("MatchPivots");
eval (($setup + " " + $parent + " " + 0));
showOptionBox();
}
proc string assembleCmd()
{
setOptionVars(false);
int $rot = `optionVar -q matchRotPivot`;
int $scale = `optionVar -q matchScalePivot`;
int $ori = `optionVar -q matchPivotOrient`;
string $cmd = "";
if ($rot || $scale) {
$cmd = "matchTransform";
if ($rot && $scale) {
$cmd += " -piv";
} else if ($scale) {
$cmd += " -sp";
} else /*if ($rot)*/ {
$cmd += " -rp";
}
}
if ($ori) {
if ($cmd != "") $cmd += "; ";
$cmd += "matchPivotOrient";
}
return $cmd;
}
global proc string performMatchPivots(int $action)
{
string $cmd = "";
switch ($action) {
case 0: // Execute command
$cmd = `assembleCmd`;
if ($cmd != "") eval($cmd);
break;
case 1: // Options
performMatchPivotsOptions;
break;
case 2: // Command string
$cmd = `assembleCmd`;
break;
}
return $cmd;
}

View File

@ -0,0 +1,85 @@
//This is a paid script pack and is not free to use. Please purchase a copy and download the script pack here https://gumroad.com/malcolm341
//Thanks very much for your support! Each purchase helps maintain the ad free Youtube channel found here https://www.youtube.com/malcolm341
//Error if any xforms selected
string $checkForXformsSelected[] = `ls -sl -exactType transform`;
$sizecheckForXformsSelected = `size $checkForXformsSelected`;
if ($sizecheckForXformsSelected >= 1)
{
error "Please select faces only";
}
$selected_Faces = `ls -sl`;
toggleSelMode;
toggleSelMode;
selectMode -object;
$errorSelectedObjs = `ls -sl`;
//Error if faces selected on more than one object
$countObjs = `ls -sl`;
$size_countObjs = `size $countObjs`;
if ($size_countObjs > 1)
{
select $selected_Faces;
select -add $errorSelectedObjs;
toggleSelMode;
error "Please select faces on one object only";
}
$recordName_1 = `ls -sl`;
selectMode -object;
DeleteHistory;
$selected_Obj_1 = `ls -sl`;
duplicate -rr;
$selected_Obj_2 = `ls -sl`;
select $selected_Obj_1;
changeSelectMode -component;
//CenterPivot;
//makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
select $selected_Faces;
//polyChipOff;
//rename "polyChipOff1" "m341_CleanDupeFace";
InvertSelection;
Delete;
changeSelectMode -object;
select $selected_Obj_1;
rename duplicated_01;
CenterPivot;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
$recordObj = `ls -sl`;
select $selected_Obj_2;
rename $recordName_1;
select $recordObj;
//select -add m341_CleanDupeFace;
//Check if object had children and run special clean up
$childrenObj = `ls -sl`;
string $checkForChildren[] = `listRelatives -fullPath -type transform`;
$size_checkForChildren = `size $checkForChildren`;
if ($size_checkForChildren > 0)
{
select $checkForChildren;
delete;
select $childrenObj;
CenterPivot;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 -pn 1;
}

View File

@ -0,0 +1,55 @@
global proc detachSeparate()
{
string $nameSplitSkip[];
string $faceNum[];
string $temp[];
string $newObj[];
string $newFaceSel[];
string $origFaceSel[] = `filterExpand -ex 1 -sm 34`;
string $origObjShape[] = `listRelatives -p $origFaceSel`;
string $origObj[] = `listRelatives -p $origObjShape`;
//Get my selected face numbers into $faceNum
for ($step = 0, $skip = 0; $step < size($origFaceSel); $step++, $skip++)
{
tokenize $origFaceSel[$step] "." $temp;
$nameSplitSkip[$skip] = $temp[0];
$skip++;
$nameSplitSkip[$skip] = $temp[1];
clear $temp;
}
for ($step2 = 0, $skip2 = 1; $step2 < (size($nameSplitSkip)/2); $step2++, $skip2 = $skip2 + 2)
{
$faceNum[$step2] = $nameSplitSkip[$skip2]; //every other value
}
//Dupe original object
$newObj = `duplicate -un $origObj[0]`;
delete -ch $newObj[0];
string $newAllFaces[] = `ls ($newObj[0] + ".f[*]")`;
//Make new array for face selection on $newObj
for ($step3 = 0; $step3 < size($faceNum); $step3++)
{
$newFaceSel[$step3] = ($newObj[0] + "." + $faceNum[$step3]);
}
//Delete original face selection
delete $origFaceSel;
//Delete inverse face selection on duplicate
select -r $newAllFaces;
select -d $newFaceSel;
delete;
select -r $newObj[0];
CenterPivot;
}
detachSeparate;
dR_movePress;
dR_DoCmd("movePress");
getPanel -wf;
// Result: modelPanel4 //
dR_buildTransformMM("move");
dR_moveRelease;
dR_DoCmd("moveRelease");
getPanel -wf;
// Result: modelPanel4 //
MarkingMenuPopDown;
if (`popupMenu -exists tempMM`) { deleteUI tempMM; }if (`popupMenu -exists tempMM2`) { deleteUI tempMM2; };