Hi, this is a question regarding exchange sharp.
I’m currently working on reading multiple PRC streams from a 3D PDF. I had no trouble following and implementing the example in the C++ programming guide (2.1 Simple Load and Export). When trying to replicate in C# however, I’ve run into an issue.
Up until the API call to A3DAsmModelFileLoadFromPrcStream, everything works as expected. I’m able to marshal the data from IntPtr to A3DStream3DPDFData and the m_acstream (“PRC \u001b”) and m_uiStreamSize both appear to be correct based on the working solution’s data in C++. The call to A3DAsmModelFileLoadFromPrcStream however, does not set the model file pointer to any model, and instead points to IntPtr.Zero.
Strangely, ppPrcReadHelper IS modified to point to some assigned address by the call, but the ppModelFile is not.
Finally, the API call to A3DAsmModelFileLoadFromPrcStream returns the status A3D_LOADPRC_INITIALIZATION_FAILURE. Any help/tips on likely suspects would be appreciated. Below is a snippet of code covering my attempt at a simple use case. Thanks,
A3DStream3DPDFData d;
API.Initialize(out d);
//Create IntPtr to stream
IntPtr pdfPtr = Marshal.AllocHGlobal(d.m_usStructSize);
Marshal.StructureToPtr(d, pdfPtr, false); //Unnecessary line I think
int iNumStreams;
API.A3DGet3DPDFStreams(pcFileName, pdfPtr, out iNumStreams);
if(iNumStreams == 0) { return; }
IntPtr ptr = Marshal.ReadIntPtr(pdfPtr);
//Only testing first prc stream for now
var file = (A3DStream3DPDFData)Marshal.PtrToStructure(ptr, typeof(A3DStream3DPDFData));
//If type of embedded model is prc
if (file.m_bIsPrc)
{
IntPtr ppModelFile;
IntPtr ppReadHelper;
//Load the model file from prcstream
// m_acStream = "PRC \u001b"
API.A3DAsmModelFileLoadFromPrcStream(file.m_acStream, file.m_uiStreamSize, out ppReadHelper, out ppModelFile);
//At this point ppModelFile unexpectedly points to nothing
}