Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
186 changes: 160 additions & 26 deletions ZScripts/GoB_Import.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,27 @@
/*
/*
name: GoB_Import.zsc
description: Zbrush script for Blender GoB addon
tracker_url: https://github.com/JoseConseco/GoB
author: Daniel Grauer
*/

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~VARIABLES
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[VarDef,isMac,0]//do we have a Mac or PC
[VarDef,Zvers,0]//ZBrush version
[VarDef,dllPath,""]//plugin DLL path
[VarDef,dllVersion,0]//plugin DLL version
[VarDef,err,0]//standard error

[VarDef, folderPath,""]
[VarDef, GoZPath,""]
[VarDef, defaultPath, "C:/Users/Public/Pixologic"]
[VarDef, defaultPathMac,"Users/Shared/Pixologic"]

[VarDef,GoBImport,1]
[VarDef,reportDuration,-1] //Display Duration (in seconds) (0:wait for user action(default), -1:combine with next note command),
[VarDef,reportDuration,0] //Display Duration (in seconds) (0:wait for user action(default), -1:combine with next note command),
[VarDef,showFinalReport,0] // Final Report (1: show, 0 Hide)
[VarDef,finalReportreportDuration,100] //Display Duration (in seconds) (0:wait for user action(default), -1:combine with next note command),
[VarDef,maxSubtools,999]
Expand All @@ -23,6 +38,132 @@ author: Daniel Grauer
*/


//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~ROUTINES
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//The CheckSystem routine is a standard routine to make sure everything is as it should be.
//Call it whenever the plugin is reloaded
[RoutineDef, CheckSystem,
//check ZBrush version
[VarSet,Zvers,[ZBrushInfo,0]]
[If,[Val,Zvers] >= 2021.0,,
[Note,"\Cff9923This zscript\Cffffff is not designed for this version of \Cff9923ZBrush\Cffffff.",,3,4737096,,300]
[Exit]
]
[VarSet,isMac, [ZBrushInfo,6]] //check Mac or PC
// Make sure we have the dll and set its path
[If,[ZBrushInfo,16]==64,//64 bit
[If,isMac,
//use the path below for testing only
//[VarSet,dllPath,"MyPluginData/ZFileUtils.lib"]
//use the path below for installed plugins
[VarSet,dllPath,"ZBRUSH_ZSTARTUP/ZPlugs64/MyPluginData/ZFileUtils.lib"]
,
//use the path below for testing only
[VarSet,dllPath,"MyPluginData\ZFileUtils64.dll"]
//use the path below for installed plugins
//[VarSet,dllPath,"ZBRUSH_ZSTARTUP\ZPlugs64\MyPluginData\ZFileUtils64.dll"]
]
,//else 32 bit - no longer supported
[Note,"\Cff9923This zscript\Cffffff is not designed for this version of \Cff9923ZBrush\Cffffff.",,3,4737096,,300]
[Exit]
]
[If, [FileExists, [Var,dllPath]],
//check that correct version
[VarSet, dllVersion, [FileExecute, [Var,dllPath], Version]]
[If, [Val,dllVersion] >= 8.0,//dll version
//OK
,//else earlier version
[Note,"\Cff9923Note :\Cc0c0c0 The \Cff9923 ZFileUtils plugin \CffffffDLL\Cc0c0c0 is an earlier version which does not support this plugin. Please install correct version."]
[Exit]
]
, // else no DLL.
[Note,"\Cff9923Note :\Cc0c0c0 The \Cff9923 ZFileUtils plugin \CffffffDLL\Cc0c0c0 could not be found at the correct location. Please re-install the plugin, making sure the relevant files and folders are in the \CffffffZStartup/ZPlugs\Cc0c0c0 folder."]
[Exit]
]
]//end routine

//call routine here to ensure it's called every time plugin loaded
[RoutineCall, CheckSystem]

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~Folder Path Setup
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

//Loads saved path from settings file, or sets default
[RoutineDef, SetPath,
[VarSet, fileExists,[FileExists,"GoB_Import_Settings.svr"]]
[If, fileExists,
[VarLoad, folderPath, "GoB_Import_Settings.svr"]
[VarSet, GoZPath, folderPath]
,
[If, isMac,
[VarSet, GoZPath, defaultPathMac]
,
[VarSet, GoZPath, defaultPath]
]
]
]
[RoutineCall, SetPath]

[RoutineDef, ChooseFolder,
//create memblock to get the path
[If,[MemGetSize,MC_FolderPath],,
[MemCreate,MC_FolderPath,256,0]
]
[VarSet,err,[FileExecute, [Var,dllPath],ChooseFolder,,,MC_FolderPath]]
[If,err,
[Note,err]//function will return -1 if no folder chosen
,
//copy path from memblock to variable
[MemReadString,MC_FolderPath,folderPath,0,1]
//show the selected folder path
[Note,folderPath]//Notes do not display backslashes
//*** when using the path remember to append a slash before the file name!***
//*** for example:
//[VarSet,fileName,"My_Model.ztl"]
//[FileNameSetNext,[StrMerge,folderPath,"/",fileName]]
]
[varSave, folderPath, "GoB_Import_Settings.svr"]
[MemDelete,MC_FolderPath]
]

//Checks the folder path is valid, if it is not asks user to choose the correct folder
[RoutineDef, CheckFolderExists,
//check to see if folder exists
[VarSet, folderCheck, [StrMerge,GoZPath,"/GoZProjects"]]
[VarSet,folderExists,[FileExecute,[Var,dllPath],"FolderExists",#folderCheck]]
[If,folderExists,
,//else
[Note,"Cannot locate GoZ data folders",,3]
[Note,"Please locate the Pixologic folder that is usually located within the Users/Public/ folder",,3]
[RoutineCall, ChooseFolder]
[VarSet, GoZPath, folderPath]
]
]
[RoutineCall, CheckFolderExists]

//Save the chosen folder path to settings file
[varSave, folderPath, "GoB_Import_Settings.svr"]

//Check if the folder selected by the user is valid, if not abort script.
[RoutineDef, SecondCheck,
//check to see if folder exists
[VarSet, folderCheck, [StrMerge,GoZPath,"/GoZProjects"]]
[VarSet,folderExists,[FileExecute,[Var,dllPath],"FolderExists",#folderCheck]]
[If,folderExists,
,//else
[Note,"Still cannot locate GoZ data, aborting zscript...",,3]
[Exit]
]
]
[RoutineCall, SecondCheck]

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//~~~GoB Main
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

[If,GoBImport==1, //make sure this script runs when loaded
[RoutineDef,AdjustPath, //replace backslashes with forward slashes
[VarDef,pathStr,""]
Expand All @@ -44,19 +185,19 @@ author: Daniel Grauer
]
,path]

[VarSet,publicPath,[FileNameExtract,[FileNameResolvePath,"ZPUBLIC_ZPluginData/"],1]]
//[VarSet,publicPath,[FileNameExtract,[FileNameResolvePath,"ZPUBLIC_ZPluginData/"],1]]
[VarSet,publicPath,GoZPath]
[VarSet,publicPathMac,defaultPathMac]
[RoutineCall,AdjustPath,publicPath] //just as Notes don't display backslashes!
//[Note,[StrMerge, "\nThe ZBrush Data folder path is: \n ", publicPath],,reportDuration]

[VarDef,GoZProjectsPath,""]
[VarDef, GoZBrushPath, ""]
[If,[ZBrushInfo,6],//is MacOS
[If,[StrFind,"Shared",publicPath]>-1,
[VarSet,GoZProjectsPath,[StrExtract,publicPath,0,([StrFind,"Shared",publicPath]+6)]]
[VarSet,GoZProjectsPath,[StrMerge,GoZProjectsPath,"Pixologic/GoZProjects/Default/"]]
[If,[StrFind,"Pixologic",publicPath]>-1,
[VarSet,GoZProjectsPath,[StrMerge,publicPathMac,"/GoZProjects/Default/"]]

[VarSet,GoZBrushPath,[StrExtract,publicPath,0,([StrFind,"Shared",publicPath]+6)]]
[VarSet,GoZBrushPath,[StrMerge,GoZBrushPath,"Pixologic/GoZBrush/"]]
[VarSet,GoZBrushPath,[StrMerge,publicPathMac,"/GoZBrush/"]]

//[Note,[StrMerge, "\nThe GoZ Projects path is: \n ", GoZProjectsPath],,reportDuration]
//[Note,[StrMerge, "\nThe GoZ objects list path is: \n ", GoZBrushPath],,reportDuration]
Expand All @@ -65,21 +206,18 @@ author: Daniel Grauer
//this needs to be removed if passing paths to dynamic libraries etc. - see GetFullPath routine above

,//else Windows
[If,[StrFind,"Documents",publicPath]>-1,
[VarSet,GoZProjectsPath,[StrExtract,publicPath,0,([StrFind,"Documents",publicPath]-1)]]
[VarSet,GoZProjectsPath,[StrMerge,GoZProjectsPath,"Pixologic/GoZProjects/Default/"]]
[If,[StrFind,"Pixologic",publicPath]>-1,
[VarSet,GoZProjectsPath,[StrMerge,publicPath,"/GoZProjects/Default/"]]
[RoutineCall,AdjustPath,GoZProjectsPath]//just as Notes don't display backslashes!

[VarSet,GoZBrushPath,[StrExtract,publicPath,0,([StrFind,"Documents",publicPath]-1)]]
[VarSet,GoZBrushPath,[StrMerge,GoZBrushPath,"Pixologic/GoZBrush/"]]
[VarSet,GoZBrushPath,[StrMerge,publicPath,"/GoZBrush/"]]
[RoutineCall,AdjustPath,GoZBrushPath]//just as Notes don't display backslashes!

//[Note,[StrMerge, "\nThe GoZ Projects path is: \n ", GoZProjectsPath],,reportDuration]
//[Note,[StrMerge, "\nThe GoZ objects list path is: \n ", GoZBrushPath],,reportDuration]
]
]


[VarDef,variablesFile,[StrMerge,GoZProjectsPath,"GoB_variables.zvr"]]
// load variables from GoB export
/* File: Gob_variables.zvr
Expand All @@ -105,7 +243,7 @@ author: Daniel Grauer
[Note,[StrMerge,"\n\nGoB_variables.zvr not Found", "\naborting import"],,reportDuration]
[Exit]
]
[Note,[StrMerge, "\CFFFFFFGoB Version: ",gobVersion, "\n"],,reportDuration]
//[Note,[StrMerge, "\CFFFFFFGoB Version: ",gobVersion, "\n"],,reportDuration]


[RoutineDef,LoadTextures,
Expand All @@ -116,17 +254,17 @@ author: Daniel Grauer
[If,[FileExists,diffTexture],
[IPress,Tool:Texture Map:TextureMap]
[FileNameSetNext,diffTexture] [IPress,Texture:Import]
[Note, [StrMerge, "\n Texture: ", [StrMerge,objectName,diffSuffix,textureFormat]],, reportDuration]
//[Note, [StrMerge, "\n Texture: ", [StrMerge,objectName,diffSuffix,textureFormat]],, reportDuration]
]
[If,[FileExists,dispTexture],
[IPress,Tool:Displacement Map:DisplacementMap]
[FileNameSetNext,dispTexture] [IPress,Alpha:Import]
[Note, [StrMerge, "\n Texture: ", [StrMerge,objectName,dispSuffix,textureFormat]],, reportDuration]
//[Note, [StrMerge, "\n Texture: ", [StrMerge,objectName,dispSuffix,textureFormat]],, reportDuration]
]
[If,[FileExists,normTexture],
[IPress,Tool:Normal Map:Normal Map]
[FileNameSetNext,normTexture] [IPress,Texture:Import]
[Note, [StrMerge, "\n Texture: ", [StrMerge,objectName,dispSuffix,textureFormat]],, reportDuration]
//[Note, [StrMerge, "\n Texture: ", [StrMerge,objectName,dispSuffix,textureFormat]],, reportDuration]
]
]

Expand Down Expand Up @@ -258,7 +396,7 @@ author: Daniel Grauer
[TransformGet, xPos, yPos, zPos, xSc, ySc, zSc, xRot, yRot, zRot ]
[TransformSet, (Document:Width/2), (Document:Height/2), zPos, xSc, ySc, zSc, xRot, yRot, zRot]

[Note,[StrMerge, "\n\C00FF00 Created new tool: ", objectName],,reportDuration]
//[Note,[StrMerge, "\n\C00FF00 Created new tool: ", objectName],,reportDuration]
, objectName, objectPath]


Expand Down Expand Up @@ -289,7 +427,7 @@ author: Daniel Grauer
]
]

[Note,[StrMerge,"\n\C2200FF Created new Subtool: \CFFFFFF", objectName] ,,reportDuration]
//[Note,[StrMerge,"\n\C2200FF Created new Subtool: \CFFFFFF", objectName] ,,reportDuration]
, objectName, objectPath]


Expand All @@ -301,7 +439,7 @@ author: Daniel Grauer
[IPress,Tool:Import]
[RoutineCall, LoadTextures]
]
[Note,[StrMerge,"\n\CFFEE00 Updated Subtool: \CFFFFFF",objectName],,reportDuration]
//[Note,[StrMerge,"\n\CFFEE00 Updated Subtool: \CFFFFFF",objectName],,reportDuration]
, objectName, objectPath, subtoolCount]


Expand Down Expand Up @@ -395,10 +533,6 @@ author: Daniel Grauer
]
]/*End of ZScript*/





//[SubToolGetFolderName,4] //return the folder name that the 5th subtool was in, or an empty string if it wasn’t in a folder.
// [SubtoolGetFolderIndex]

Expand Down Expand Up @@ -447,4 +581,4 @@ author: Daniel Grauer
]
]
, isVisible]
*/
*/
Binary file modified ZScripts/GoB_Import.zsc
Binary file not shown.
Binary file added ZScripts/GoB_Import_Settings.zvr
Binary file not shown.
Binary file added ZScripts/MyPluginData/ZFileUtils.lib
Binary file not shown.
Binary file added ZScripts/MyPluginData/ZFileUtils64.dll
Binary file not shown.