Skip navigation
Currently Being Moderated

How to use GetProjectPath (and other A_UTF16Char) properly?

Feb 28, 2012 12:23 AM

Tags: #mac #strings #aegp_api

Hi there,

 

I'm trying to get the current project path and store it to wstring variable, and later convert it to A_Char to show it on reportinfo.

 

Following code works correctly on Windows 7 64bit and project path is displayed with ReportInfo dialog box, but on macosx 10.6.8, projectPathW.length() is always nonzero even when no project is opened. And ReportInfo always shows empty string.

 

 

AEGP_ProjectH project;

AEGP_MemHandle pathH;

 

suites.ProjSuite5()->AEGP_GetProjectByIndex(0, &project);

 

if (project) {

err = suites.ProjSuite5()->AEGP_GetProjectPath(project, &pathH);

if (!err)

{

A_UTF16Char *pathText;

 

err = suites.MemorySuite1()->AEGP_LockMemHandle(pathH, (void**)&pathText);

 

if (!err)

{

wstring projectPathW((wchar_t*)pathText);

if (projectPathW.length() == 0)

{

suites.UtilitySuite3()->AEGP_ReportInfo(S_my_id,"empty string");

}

else

{

char *fileName = (char *)malloc( AEGP_MAX_PATH_SIZE );

wcstombs( fileName, projectPathW.c_str(), AEGP_MAX_PATH_SIZE );

suites.UtilitySuite3()->AEGP_ReportInfo(S_my_id,fileName);

free(fileName);

}

}

suites.MemorySuite1()->AEGP_UnlockMemHandle(pathH);

ERR(suites.MemorySuite1()->AEGP_FreeMemHandle(pathH));

}

}

 
Replies
  • Currently Being Moderated
    Feb 28, 2012 5:43 PM   in reply to PSuuraho

    I have the same problem.  The manual or documentation somewhere says that AEGP_GetProjectPath only returns valid data after recently saving the project.  Usually I get NULL for a response so I moved on. 

     
    |
    Mark as:
  • Currently Being Moderated
    May 15, 2013 3:16 PM   in reply to BillClag

    I'm coming in a bit late on this one... but it's worth noting that wchar_t is 16-bit on Win, but 32-bit on MacOS.  So  A_UTF16Char and wchar_t are not interchangable on MacOS.  Search for the sample code copyConvertStringLiteralIntoUTF16() in the SDK for a not-so-pretty example of how to handle this.

     
    |
    Mark as:
  • Currently Being Moderated
    May 15, 2013 3:31 PM   in reply to Zac Lam

    Zac:

     

    There are two two issues here: 

     

    Mac uses UTF-8 and Windows needs UTF-16.  After Effects gives UTF-16 but it is easy to convert for Mac plug-ins.  This is not a problem.  We are used to that.  wchar_t is an issue on the Mac so I aviod wchar_t and stick with UTF-16. 

     

    The real problem is that we do not get the GetProjectPath() in AE until rendering.  That means we have no idea of that until too late.  GetProjectPath() returns NULL. 

     
    |
    Mark as:
  • Currently Being Moderated
    May 16, 2013 9:14 AM   in reply to BillClag

    True, it does sound like we're talking about two different issues here.  Although I replied to your post, my feedback was based on PSuuraho's code in the original post.

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points