i got a problem to use XCAF

Hi folks.

I have a run time error when using TDocStd_Document.

Handle(TDocStd_Application) anApp;
Handle(TDocStd_Document) aDoc;

anApp->NewDocument ("XmlXCAF", aDoc);

when i access to aDoc as line 3, Access violation is encountered.

Error message is;

Unhandled exception at 0x011b5d23 in testCSdis.exe: 0xC0000005: Access violation reading location 0xfefd0000.

I followed the example in the references, but i got an error.

Can anyone help me ??

Thanks in advance

tmacedo29's picture

Hi UlikeM,

I think you should instantiate anApp before to use it.
Try this

Handle(TDocStd_Document) aDoc;
Handle(XCAFApp_Application) anApp = XCAFApp_Application::GetApplication();
anApp->NewDocument("XmlXCAF", aDoc);

Hope this helps.

kms05's picture

Thanks for your help, Thiago Macedo.

It was so stupid question, haha

I didn't initialize the document, which makes access violation.

Thanks again !