I want to attach a reference file that includes a raster attachment. I use these few lines of code:
DgnAttachmentP newAttachment; DgnDocumentMonikerPtr moniker = DgnDocumentMoniker::CreatePortableMoniker(L"RefFile.dgn", NULL, NULL, NULL, NULL, DgnPlatform::RelativePathPreference::CreateIfPossible); ISessionMgr::GetActiveDgnModelRefP()->CreateDgnAttachment(newAttachment, *moniker, nullptr, true); newAttachment->SetNestDepth(99); newAttachment->WriteToModel();
It seems to work fine but the raster attachment in the reference file is not displayed and it is not listed in the Raster Manager dialogbox. However, if I keyin the command "newfile" the raster attachment will be displayed and it is lislted in the Raster Manager dialogbox.
To illustrate my problem I've created a small test case: I've attached a ZIP file with 4 files: MasterFile.dgn, RefFile.dgn, the rasterfile "DDOland 2014.jpeg" and the corresponding .jgw file. If you open MasterFile.dgn and execute the lines listed above you will see that only the outline of the raster attachment is displayed.
If you attach the reference file manually it works just fine. What am I missing in my code ?
Regards, Evan
TestFiles.zip
Hi Evan,
I was able to reproduce this issue and while investigating this issue we tested different WriteToModel signatures:
WriteToModel (bool loadRasterRefs = false, bool treatAsNew = false);
Please try to use these parameters, this worked fine for us:
newAttachment->WriteToModel(true, true);
I hope this helps?
Best regards,Artur
Answer Verified By: EvanH