ZBrushCentral

GoZ reopens Maya every time is used

Hi guys,

I installed Zbrush 4.0 like ten times already trying to fix this issue. First off the installation of GoZ seems to be working fine during the entire process, that is, choosing the target app (Maya 64bit 2011 in my case), setting paths, etc, however when I send a mesh from Zbrush to Maya the GoZ Shelf is not installed properly so I cannot send the mesh back to Zbrush. After a little of dooling around I into the .mel scripts and GoZ’s installed files I managed to set the shelf myshelf, sorry myself, and now I can send models back into Zbrush. Since I have Maya 2010 installed as well I tried with this version also, but to no avail.

I think that Zbrush does not install GoZ properly on Windows 7 in a language different than english. For example, my program-files directory is “archivos de programa” in Spanish and like it happened with many other applications I previously installed in my computer I am having issues with Zbrush this time around.

However, like I said before, I managed to install it manually. Nevertheless, every time I click on the GoZ button in Zbrush Maya is opened again, regardless of being already running. I am not familiar with GoZ, but I do not think this is the way it should work, or is it?

Any help would be appreciated.

Tomas

Its not just you. I am having that problem with my zbrush on maya 8.5 for 64bit XP. But for me when I send something to maya it will open maya and then give me and error…no model. If maya is open and I try to send something from zbrush to maya it will open another copy of maya and then give me the error. I hope you find some help. Sorry I wasn’t it.

I’ve seen this issue with 3dsmax as well. Reopens a new instance of 3DSmax every time I click goZ. It doesnt happen all the time… im confused.

I’m noticing this with mine too! BTW, Where is the “GoZ” button installed to within Maya. What do i click to send it back to ZBrush?

I have also experienced that same problem on my very first attempts, that is, no model when Maya is open. I cannot remember exactly how I managed to solve it, but I cleaned the cash (from GoZ preferences) and then reinstalled Zbrush from scratch on top of the existing one. Then forced the reinstall of GoZ components (also from GoZ preferences) and voila! the models reappeared in Maya. My main issue now is that Maya is annoyingly reopening on every GoZ use from Zbrush. That is really getting on my nerves. I am going to go thru the entire .mel script and study it deeply to see what happens. There must be an area in the code which checks if Maya is already open. If it is not there, then unfortunately it must be in the GoZ executable files which I can not reverse engineer to study their code. I will get back to you guys.

Good luck
Tomas

This is a reply for RyDarling…

You can easily install the GoZ button manually into a new Shelf in Maya. This is the mel code to do it, but first check out where are your GoZApps installed. In my case (Windows7) they are located in
C:/Users/Public/Pixologic/GoZApps

If yours are in a different location simply change those accordingly into the code. First Open the script editor, paste the code underneath, execute it (really just sourcing the procedure) and then execute the procedure itself shelf_GoZBrush. The icon will show up in the script editor and you can drag and drop it into the shelf that you prefer.

global proc shelf_GoZBrush () { global string $gBuffStr;
global string $gBuffStr0;
global string $gBuffStr1;
shelfButton
-enableCommandRepeat 1
-enable 1
-width 34
-height 34
-manage 1
-visible 1
-preventOverride 0
-align “center”
-label “GoZ”
-labelOffset 0
-font “tinyBoldLabelFont”
-image “C:/Users/Public/Pixologic/GoZApps/Maya/GoZBrush.xpm”
-image1 “C:/Users/Public/Pixologic/GoZApps/Maya/GoZBrush.xpm”
-style “iconOnly”
-marginWidth 1
-marginHeight 1
-command "source “C:/Users/Public/Pixologic/GoZApps/Maya/GoZBrushFromMaya.mel”
"
-sourceType “mel”
-actionIsSubstitute 0
-commandRepeatable 1
;
}

The code underneath is executed every time you click the GoZ shelf button

in Maya:

// ------------------------------------------
// GoZBrush from Maya script
// ------------------------------------------
// ------------------------------------------
// Global variables.
global string $GoZBrushPath = “C:/Users/Public/Pixologic/GoZBrush/”;
global string $GoZAppExt = “.exe”;
global string $GoZProjectPath;
global int $GoZDebugON = 0;
global string $gFileBaseName = “”;
global int $gFileOccurrence = 0;
global string $selObjects[];
// ------------------------------------------
// Launch an application.
// Code is different depending on PC/Mac.
global proc launchApp(string $path)
{
// On Windows:
system($path);
// On MacOSX:
//system(“open -a “”+$path+”"");
}
// ------------------------------------------
// Debug purpose…
global proc printDebug(string $text)
{
global int $GoZDebugON;
if ($GoZDebugON)
{
print($text+"
“);
}
}
// ------------------------------------------
// Decompose a fileName into [$gFileBaseName][$gFileOccurrence],
// where [$gFileBaseName] is text and $gFileOccurrence is an integer.
// For example, decompose “myFile25” into (“myFile”, 26)
global proc decomposeFileName(string $fileName)
{
global string $gFileBaseName;
global int $gFileOccurrence;
int $index;
int $count;
string $car;
$count = size($fileName);
for ($index=$count; $index>0; $index–)
{
$car = substring $fileName $index $index;
$car = match "[0-9]" $car;
if ($car == “”)
break;
}
if ($index == $count)
{
$gFileBaseName = $fileName;
$gFileOccurrence = 0;
}
else
{
if ($index > 0)
$gFileBaseName = substring $fileName 1 $index;
else
$gFileBaseName = “”;
$index++;
$car = substring $fileName $index $count;
$gFileOccurrence = $car;
}
}
// ------------------------------------------
// Tests if a GoZ name matches an object name.
// The test is performed using decomposition of both names(see decomposeFileName).
// The GoZ name matches the object name if and only if:
// 1- both names decomposition have the same base name
// 2- the occurence of GoZ name is greater or equal to the occcurrence of object name.
// For example, for object name “myFile25”:
// - “myFile25” and “myFile48” are valid GoZ names,
// - “myFile24” and “toto_en_short” are NOT valid GoZ names!
global proc int isRightGoZID(string $objectName, string $objectGoZName)
{
global string $gFileBaseName;
global int $gFileOccurrence;
string $objectGoZBaseName;
int $objectGoZOccurrence;
string $objectBaseName;
int $objectOccurrence;
decomposeFileName($objectGoZName);
$objectGoZBaseName = tolower $gFileBaseName;
$objectGoZOccurrence = $gFileOccurrence;
decomposeFileName($objectName);
$objectBaseName = tolower $gFileBaseName;
$objectOccurrence = $gFileOccurrence;
if ($objectBaseName != $objectGoZBaseName)
return 0;
if ($objectGoZOccurrence < $objectOccurrence)
return 0;
return 1;
}
// ------------------------------------------
// Simulates a sleep of some milliseconds.
// Note: as no sleep command is available, it waits “actively” for the amout of time…
global proc sleep(float $delayInSecond)
{
float $startTime;
float $ellapsedTime;
$startTime = timerX;
$ellapsedTime = timerX -st $ellapsedTime;
while ($ellapsedTime < $delayInSecond)
{
$ellapsedTime = timerX -st $ellapsedTime;
}
}
// ------------------------------------------
// Creates a new GoZ name based an an object name.
// Creation is made using the GoZ utility “GoZMakeObjectPath”,
// which ensures that the GoZ name is unique.
// Note: check if the GoZ name $name is unique consists on
// checking ZTN files in “/Users/Public/Pixologic/GoZProject/default/”,
// and verify that the file $name.ztn does not exist in that folder.
// IMPORTANT: It implies that to safely create several unique GoZ names,
// the caller should create an empty ZTN file using the unique name it returns.
global proc string createGoZID(string $objectName)
{
global string $GoZBrushPath;
global string $GoZAppExt;
string $fileName;
string $path;
int $fileId;
float $startTime;
float $ellapsedTime;
float $delay;
$fileName = $GoZBrushPath + “GoZ_ObjectPath.txt”;
$fileId = fopen $fileName "w";
fprint $fileId $objectName;
fclose $fileId;
$fileName = $GoZBrushPath + “GoZMakeObjectPath” + $GoZAppExt;
launchApp($fileName);
$fileName = $GoZBrushPath + “GoZ_ObjectPath.txt”;
$startTime = timerX;
$ellapsedTime = timerX -st $startTime;
$delay = 0.02;
while ($ellapsedTime < 2.0)
{
$fileId = fopen $fileName "r";
if ($fileId != 0)
{
$path = “”;
$path = fread $fileId $path;
fclose $fileId;
if (size($path) > size($objectName))
{
string $tokens[];
int $tokenCount;
$tokenCount = tokenize $path "/\\" $tokens;
/*
if ($tokenCount < 2)
{
printDebug(” >>>> No token found in path “” + $path + “” <<<<");
return $objectName;
}
printDebug(" >>>> " + $tokenCount + " tokens found in path “” + $path + “” <<<<");
*/
$path = $tokens[$tokenCount-1];
printDebug(" >>>> Unique GoZ ID “” + $path + “” generated for object “” + $objectName + “” <<<<");
return $path;
}
}
sleep($delay);
$delay = 0.1;
$ellapsedTime = timerX -st $startTime;
}
// If here, did not manage to find a valid path.
// As such an error is not managed, just returns $objectName which will be overwrited.
printDebug(" >>>> No unique GoZ ID generated for object “” + $objectName + “” <<<<");
return $objectName;
}
// ------------------------------------------
// Exports a GoZ object to ZBrush.
global proc int exportGoZObject(string $objectName)
{
global string $GoZBrushPath;
global string $GoZProjectPath;
global string $selObjects[];
string $maFileName;
string $ztnFileName;
string $gozName;
string $gozPath;
string $validGoZName;
string $fileName;
int $fileId;
printDebug(" Exporting object " + $objectName + “…”);
// The object already has a GoZBrushID attribute, which contains an ID of ZTN file.
if (attributeQuery -node $objectName -ex "GoZBrushID")
{
//select -r $objectName;
$gozName = getAttr($objectName + “.GoZBrushID”);
$ztnFileName = $GoZProjectPath + $gozName + “.ztn”;
printDebug(" Found GoZBrushID attribute = " + $gozName);
// There is an existing GoZ ID, but it does not match the object name.
// This can occur either after a copy or a rename of the object.
// In such a case, create a new GoZ ID matching the object name,
// and copy maps from previous ID if it still exists.
if (!isRightGoZID($objectName, $gozName))
{
// Stores previous GoZ ID.
string $oldGoZName = $gozName;
// Creates a new GoZ ID.
$gozName = createGoZID($objectName);
setAttr -type “string” ($objectName + “.GoZBrushID”) ($gozName);
printDebug(" GoZBrushID is not valid(object is a copy or was renamed) - new GoZBrushID created = " + $gozName);
// If previous ID still exists, copy maps from previous ID to new ID.
if (file -q -exists $ztnFileName)
{
printDebug(" The previous ZTN file still exists: copy the maps from previous GoZBrushID to new one!");
string $sourcePath;
string $targetPath;
// copy normal map
$sourcePath = $GoZProjectPath+ $oldGoZName + “_NM.tif”;
$targetPath = $GoZProjectPath+ $gozName + “_NM.tif”;
if (file -q -exists $sourcePath)
{
sysFile -copy $targetPath $sourcePath;
}
// copy displacement map
$sourcePath = $GoZProjectPath+ $oldGoZName + “_DM.tif”;
$targetPath = $GoZProjectPath+ $gozName + “_DM.tif”;
if (file -q -exists $sourcePath)
{
sysFile -copy $targetPath $sourcePath;
}
// copy texture map
$sourcePath = $GoZProjectPath+ $oldGoZName + “_TXTR.tif”;
$targetPath = $GoZProjectPath+ $gozName + “_TXTR.tif”;
if (file -q -exists $sourcePath)
{
sysFile -copy $targetPath $sourcePath;
}
} // End of if (file -q -exists $ztnFileName)
// Creates an empty ZTN file.
$ztnFileName = $GoZProjectPath + $gozName + “.ztn”;
$fileId = fopen $ztnFileName "w";
fclose $fileId;
} // End of if (!isRightGoZID($objectName, $gozName))
// If the GoZBrushID is the right one, verifies that the ZTN file still exists.
// If not, creates an empty one.
else if (!file -q -exists $ztnFileName)
{
// Creates an empty ZTN file.
$fileId = fopen $ztnFileName "w";
fclose $fileId;
}
} // End of if (attributeQuery -node $objectName -ex "GoZBrushID")
// The object does NOT have any GoZBrushID attribute.
else
{
string $objectHistory[];
string $historyName;
int $objectHistoryCount;
int $objectHistoryIndex;
printDebug(" No GoZBrushID found… search in the history for any GoZBrushID");
// Search in the object history for a GoZ object.
$gozName = “”;
$objectHistory = listHistory $objectName;
$objectHistoryCount = size($objectHistory);
for ($objectHistoryIndex=0; $objectHistoryIndex<$objectHistoryCount; $objectHistoryIndex++)
{
$historyName = $objectHistory[$objectHistoryIndex];
if (attributeQuery -node $historyName -ex "GoZBrushID")
{
$gozName = getAttr($historyName + “.GoZBrushID”);
$ztnFileName = $GoZProjectPath + $gozName + “.ztn”;
if (file -q -exists $ztnFileName)
{
string $msg;
int $result;
printDebug(" Found a GoZ object in the history: " + $historyName + " — GoZBrushID = " + $gozName);
// Found a GoZ object in the construction history: asks the user if we change the object name to GoZ one or not.
$msg = “The object “” + $objectName + “” is a descendant of “” + $historyName + “.GoZBrushID”.”;
$msg = $msg + "

Press OK to restore the original GoZ name “” + $gozName + “” and send the modified mesh to ZBrush for remapping.";
$result = confirmDialog -title "GoZBrush Note" -message $msg -button "OK" -button "Cancel" -defaultButton "OK" -cancelButton "Cancel" -dismissString "OK";
if ($result == “Cancel”)
{
$gozName = “”;
break;
//return 0;
}
// “Move” the GoZBrushID attribute from the history object to selected object,
// and rename the selected object to the ZTN file name.
// Note: compared to previous version, the history is NOT destroyed(not needed).
deleteAttr($historyName + “.GoZBrushID”);
addAttr -ln “GoZBrushID” -nn “GoZBrushID” -dt “string” $objectName;
setAttr -type “string” ($objectName + “.GoZBrushID”) ($gozName);
rename $objectName $gozName;
$objectName = $gozName;
break;
} // End of if (file -q -exists $ztnFileName)
else
{
deleteAttr($objectHistory[$objectHistoryIndex] + “.GoZBrushID”);
$gozName = “”;
}
} // End of if ( attributeQuery -node $objectHistory[$objectHistoryIndex] -ex "GoZBrushID" )
} // End of for ( $objectHistoryIndex=0; $objectHistoryIndex<$objectHistoryCount ; $objectHistoryIndex++)
// If no valid GoZ object was found in the history, create a new GoZ ID.
if ($gozName == “”)
{
// Creates a new GoZ ID.
$gozName = createGoZID($objectName);
addAttr -ln “GoZBrushID” -nn “GoZBrushID” -dt “string” $objectName;
setAttr -type “string” ($objectName + “.GoZBrushID”) ($gozName);
// Creates an empty ZTN file.
$ztnFileName = $GoZProjectPath + $gozName + “.ztn”;
$fileId = fopen $ztnFileName "w";
fclose $fileId;
printDebug(" nothing found in the history, create GoZBrushID"" + $gozName + “”");
}
} // End of else of if (attributeQuery -node $objectName -ex "GoZBrushID")
// All is fine now regarding the GoZBrushID, next step is exporting the object to a Maya file.
printDebug(" Exporting object “” + $objectName + “” to “” + $gozName + “.ma”");
// To avoid parametric object descriptions and any other unsupported shapes, first of all delete the construction history.
// As a result, the object will become a basic mesh.
delete -ch $objectName;
makeIdentity -apply true -t 1 -r 1 -s 1 -n 0 $objectName;
delete -ch $objectName;
// Selects only the object so that it can be exported “alone”.
select -r $objectName;
// Then exports it to a Maya file.
$maFileName = $GoZProjectPath + $gozName + “.ma”;
sysFile -delete $maFileName;
file -op “v=0” -typ “mayaAscii” -es $maFileName;
// Then reselects all the objects previously selected.
select -r $selObjects;
// Appends the GoZ object to the GoZ object list.
$gozPath = $GoZProjectPath + $gozName;
$fileName = $GoZBrushPath + “GoZ_ObjectList.txt”;
$fileId = fopen $fileName "a";
fprint $fileId $gozPath;
fprint $fileId "
“;
fclose $fileId;
printDebug(” Object path is “” + $gozPath + “”");
return 1;
}
// ------------------------------------------
// Export one or several meshes to ZBrush…
printDebug(“GoZ Maya >>> ZBrush”);
// Misc local initializations.
string $fileName;
int $selObjectCount;
int $fileId;
int $exportCount;
// Gets the path where to export Maya files.
$fileName = $GoZBrushPath + “GoZ_ProjectPath.txt”;
$fileId = fopen $fileName "r";
$GoZProjectPath = fread $fileId $GoZProjectPath;
fclose $fileId;
// Set the object selection mode and get all selected objects.
SelectTool;
changeSelectMode -component;
changeSelectMode -object;
$selObjects = ls -selection -shortNames -dagObjects -transforms; // -tail 1; $selObjectCount =size($selObjects); // Clears the GoZ object list. $fileName = $GoZBrushPath + "GoZ_ObjectList.txt"; $fileId =fopen $fileName "w"; fclose $fileId; // Exports all selected objects. printDebug("GoZ start exporting " + $selObjectCount + " selected objects:"); $exportCount = 0; for ($selObjectIndex=0; $selObjectIndex<$selObjectCount; $selObjectIndex++) $exportCount += exportGoZObject($selObjects[$selObjectIndex]); printDebug($exportCount + " GoZ objects were exported!"); // If no object was exported, shows up a dialog to ask the user to select a mesh to GoZBrush. if ($exportCount == 0) { confirmDialog -title "GoZBrush Note" -message "No mesh was exported! Please, select a mesh to GoZBrush." -button "OK" -defaultButton "OK"; } // Otherwise(at least 1 object was exported), GoZee to ZBrush. else { // Sets the right application id(Maya). $fileName = $GoZBrushPath + "GoZ_Application.txt"; $fileId =fopen $fileName “w”`;
fprint $fileId “Maya”;
fclose $fileId;
// Launch GoZBrush application.
$fileName = $GoZBrushPath + “GoZBrushFromApp” + $GoZAppExt;
launchApp($fileName);
}

Nice! I have GoZ install on Maya. Now, how can we stop all the instances of Maya to stop? Do I need to reinstall goz or what? I’m totally stumped!

Hi again,

The only way I managed to solve all issues with GoZ so far is to save the Ztool you are currently using inside the DEFAULT directory of your projects. I am using Windows 7 64 bits, Maya 2011 and Zbrush 4 and my default projects directory is located in

C:\Users\Public\Pixologic\GoZProjects\Default

Again, if you save your current Zbrush tool inside of that directory the back and forth workflow between Maya and Zbrush works like a charm as long as you have GoZ properly set up in both Maya and Zbrush. I know this is not a solution, but at least will give you some rest until something else comes up.

Good luck

Tomas

Cool I got it working. However, Any diea why my Object looks like this?

Attachments

Maya Output.jpg

It’s supposed to look like this.

Attachments

settings.jpg

Sorry dude, absolutely no clue.
:cry:small_orange_diamond:cry:small_orange_diamond:cry:small_orange_diamond:cry:

Could this have something to do with my scaling on my displacement map pallet? should I be using 32 bit?

I just Learned… I’m being redundant with my Maps. I should know better.