Skip to content

Commit

Permalink
Improved Unicode filename support
Browse files Browse the repository at this point in the history
  • Loading branch information
danielbui78 committed Oct 6, 2024
1 parent 9f7cf63 commit 4fce917
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
bl_info = {
"name": "DazToBlender",
"author": "Daz 3D | https://www.daz3d.com",
"version": (2024, 2, 8, 63),
"version": (2024, 2, 9, 68),
"blender": (2, 80, 0),
"location": "3DView > ToolShelf",
"description": "Daz 3D transfer to Blender",
Expand Down
43 changes: 27 additions & 16 deletions DazStudioPlugin/DzBlenderAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ bool DzBlenderUtils::GenerateBlenderBatchFile(QString batchFilePath, QString sBl
QFile batchFileOut(batchFilePath);
bool bResult = batchFileOut.open(QIODevice::WriteOnly | QIODevice::OpenModeFlag::Truncate);
if (bResult) {
batchFileOut.write(sBatchString.toAscii().constData());
batchFileOut.write(sBatchString.toUtf8().constData());
batchFileOut.close();
}
else {
Expand Down Expand Up @@ -312,7 +312,9 @@ DzError DzBlenderExporter::write(const QString& filename, const DzFileIOSettings
tr("Export from Daz Studio complete."), QMessageBox::Ok);

#ifdef WIN32
ShellExecuteA(NULL, "open", sBlenderOutputPath.toLocal8Bit().data(), NULL, NULL, SW_SHOWDEFAULT);
// ShellExecuteA(NULL, "open", sBlenderOutputPath.toUtf8().data(), NULL, NULL, SW_SHOWDEFAULT);
std::wstring wcsBlenderOutputPath(reinterpret_cast<const wchar_t*>(sBlenderOutputPath.utf16()));
ShellExecuteW(NULL, L"open", wcsBlenderOutputPath.c_str(), NULL, NULL, SW_SHOWDEFAULT);
#elif defined(__APPLE__)
QStringList args;
args << "-e";
Expand All @@ -339,16 +341,18 @@ DzError DzBlenderExporter::write(const QString& filename, const DzFileIOSettings
sErrorString += QString("An error occured while running the Blender Python script (ExitCode=%1).\n").arg(pBlenderAction->m_nBlenderExitCode);
sErrorString += QString("\nPlease check log files at : %1\n").arg(pBlenderAction->m_sDestinationPath);
sErrorString += QString("\nYou can rerun the Blender command-line script manually using: %1").arg(batchFilePath);
QMessageBox::critical(0, "Blender Exporter", tr(sErrorString.toLocal8Bit()), QMessageBox::Ok);
QMessageBox::critical(0, "Blender Exporter", tr(sErrorString.toUtf8()), QMessageBox::Ok);
}
else {
QString sErrorString;
sErrorString += QString("An error occured during the export process (ExitCode=%1).\n").arg(pBlenderAction->m_nBlenderExitCode);
sErrorString += QString("Please check log files at : %1\n").arg(pBlenderAction->m_sDestinationPath);
QMessageBox::critical(0, "Blender Exporter", tr(sErrorString.toLocal8Bit()), QMessageBox::Ok);
QMessageBox::critical(0, "Blender Exporter", tr(sErrorString.toUtf8()), QMessageBox::Ok);
}
#ifdef WIN32
ShellExecuteA(NULL, "open", pBlenderAction->m_sDestinationPath.toLocal8Bit().data(), NULL, NULL, SW_SHOWDEFAULT);
// ShellExecuteA(NULL, "open", pBlenderAction->m_sDestinationPath.toUtf8().data(), NULL, NULL, SW_SHOWDEFAULT);
std::wstring wcsDestinationPath(reinterpret_cast<const wchar_t*>(pBlenderAction->m_sDestinationPath.utf16()));
ShellExecuteW(NULL, L"open", wcsDestinationPath.c_str(), NULL, NULL, SW_SHOWDEFAULT);
#elif defined(__APPLE__)
QStringList args;
args << "-e";
Expand Down Expand Up @@ -838,7 +842,11 @@ void DzBlenderAction::writeConfiguration()

QString DTUfilename = m_sDestinationPath + m_sExportFilename + ".dtu";
QFile DTUfile(DTUfilename);
DTUfile.open(QIODevice::WriteOnly);
if (!DTUfile.open(QIODevice::WriteOnly)) {
QString sErrorMessage = tr("ERROR: DzBridge: writeConfigureation(): unable to open file for writing: ") + DTUfilename;
dzApp->log(sErrorMessage);
return;
}
DzJsonWriter writer(&DTUfile);
writer.startObject(true);

Expand Down Expand Up @@ -1124,18 +1132,20 @@ FbxNode* GetMeshRootBone(FbxMesh* meshNode) {
bool DzBlenderAction::postProcessFbx(QString fbxFilePath)
{
bool result = DzBridgeAction::postProcessFbx(fbxFilePath);
// if (!result) return false;
if (!result) return false;

if (m_bPostProcessFbx == false)
return false;

OpenFBXInterface* openFBX = OpenFBXInterface::GetInterface();
FbxScene* pScene = openFBX->CreateScene("Base Mesh Scene");
if (openFBX->LoadScene(pScene, fbxFilePath.toLocal8Bit().data()) == false)
if (openFBX->LoadScene(pScene, fbxFilePath.toUtf8().data()) == false)
{
if (m_nNonInteractiveMode == 0) QMessageBox::warning(0, "Error",
"An error occurred while processing the Fbx file...", QMessageBox::Ok);
printf("\n\nAn error occurred while processing the Fbx file...");
QString sFbxErrorMessage = tr("ERROR: DzBridge: openFBX->LoadScene(): ")
+ QString("[%1] %2").arg(openFBX->GetErrorCode()).arg(openFBX->GetErrorString());
dzApp->log(sFbxErrorMessage);
if (m_nNonInteractiveMode == 0) QMessageBox::warning(0, tr("Error"),
tr("An error occurred while processing the Fbx file:\n\n") + sFbxErrorMessage, QMessageBox::Ok);
return false;
}

Expand Down Expand Up @@ -1210,12 +1220,13 @@ bool DzBlenderAction::postProcessFbx(QString fbxFilePath)
}
}

if (openFBX->SaveScene(pScene, fbxFilePath.toLocal8Bit().data()) == false)
if (openFBX->SaveScene(pScene, fbxFilePath.toUtf8().data()) == false)
{
if (m_nNonInteractiveMode == 0) QMessageBox::warning(0, "Error",
"An error occurred while processing the Fbx file...", QMessageBox::Ok);

printf("\n\nAn error occurred while processing the Fbx file...");
QString sFbxErrorMessage = tr("ERROR: DzBridge: openFBX->SaveScene(): ")
+ QString("[%1] %2").arg(openFBX->GetErrorCode()).arg(openFBX->GetErrorString());
dzApp->log(sFbxErrorMessage);
if (m_nNonInteractiveMode == 0) QMessageBox::warning(0, tr("Error"),
tr("An error occurred while processing the Fbx file:\n\n") + sFbxErrorMessage, QMessageBox::Ok);
return false;
}

Expand Down
6 changes: 5 additions & 1 deletion DazStudioPlugin/DzBlenderDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include "DzBlenderDialog.h"
#include "DzBridgeMorphSelectionDialog.h"
#include "DzBridgeSubdivisionDialog.h"
#include "DzBridgeAction.h"

#include "version.h"

Expand Down Expand Up @@ -547,7 +548,10 @@ QMessageBox::Abort);
}

bool bInstallSuccessful = false;
bInstallSuccessful = installEmbeddedArchive(sBinariesFile, sPluginsPath);
// bInstallSuccessful = installEmbeddedArchive(sBinariesFile, sPluginsPath);
QString sEmbeddedFilePath = m_sEmbeddedFilesPath + "/" + sBinariesFile;
bInstallSuccessful = DZ_BRIDGE_NAMESPACE::DzBridgeAction::InstallEmbeddedArchive(sEmbeddedFilePath, sPluginsPath);


if (bInstallSuccessful)
{
Expand Down
Binary file modified DazStudioPlugin/Resources/blenderaddon.zip
Binary file not shown.
4 changes: 2 additions & 2 deletions DazStudioPlugin/real_version.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#define PRODUCT_VERSION_STRING "2024 version 2.8"
#define VER_MAJOR 2024
#define VER_MINOR 2
#define VER_REV 8
#define VER_BUILD 63
#define VER_REV 9
#define VER_BUILD 68

#define TOSTRING(x) #x
#define VERSION_STRING TOSTRING(VER_MAJOR) "." TOSTRING(VER_MINOR) "." TOSTRING(VER_REV) "." TOSTRING(VER_BUILD)

0 comments on commit 4fce917

Please sign in to comment.