[CONNECT C++] How to add SheetModel to SheetIndex

Hi,I want to know how to add a sheet model to sheet index.

I have read the sdk validateSheetLinks example, and another question about dgnlink:https://communities.bentley.com/communities/other_communities/chinafirst/f/microstation-projectwise/169104/msce-c-links

But i still can't find out how to add a sheet model to sheet index.

Do any one can tell me about it?

Parents
  • Hi ,

    I am checking with development to see if we can publish an API currently internally only at this time.

    Management of sheet links uses the DgnLinkTree API.  The MicroStation SDK provides (1) example (..\Miscellaneous\validateSheetLinks) that shows how to extract SheetLink information stored in a DgnLinkTree, but at this time (no public API) we do not have an example showing full Create, Read, Update, Delete (CRUD) operations.

    I will update you if it will be possible to publish the API mentioned in a future release when hear back.

    HTH,
    Bob

    [20200623-RH-UPDATE]  Enhancement 1099748 has been filed to address this request.



    Answer Verified By: wanglin 

Reply
  • Hi ,

    I am checking with development to see if we can publish an API currently internally only at this time.

    Management of sheet links uses the DgnLinkTree API.  The MicroStation SDK provides (1) example (..\Miscellaneous\validateSheetLinks) that shows how to extract SheetLink information stored in a DgnLinkTree, but at this time (no public API) we do not have an example showing full Create, Read, Update, Delete (CRUD) operations.

    I will update you if it will be possible to publish the API mentioned in a future release when hear back.

    HTH,
    Bob

    [20200623-RH-UPDATE]  Enhancement 1099748 has been filed to address this request.



    Answer Verified By: wanglin 

Children
  • Thank you for telling me about this. And hope the API can publish soon.

    I have worked for a while about how to add sheetModel to sheetIndex. And i got some code which let me feel that it just need the last shot.

    When i call DgnModelLink::SefFileLink(),it return 32768 which means don't SUCCESS.

    StatusInt status;
    
    #pragma region create dgnFileLink
    	auto dgnFileLeaf = DgnLinkManager::CreateLink(status, DGNLINK_TYPEKEY_File);
    	if (status != SUCCESS)
    		return;
    
    	DgnFileLinkP fileLinkP = dynamic_cast<DgnFileLinkP>(dgnFileLeaf->GetLinkP());
    	if (fileLinkP == NULL)
    		return;
    
    	WString fileName = ISessionMgr::GetActiveDgnFile()->GetFileName();
    	DgnDocumentMonikerPtr fileMoniker = DgnDocumentMoniker::CreateFromFileName(fileName.GetWCharCP());
    	if (!fileMoniker.IsValid())
    		return;
    
    	fileLinkP->SetMoniker(fileMoniker.get(), false);
    
    #pragma endregion
    
    #pragma region create modelLink
    
    	auto modelLeaf = DgnLinkManager::CreateLink(status, DGNLINK_TYPEKEY_Model);
    	if (status != SUCCESS)
    		return;
    
    	DgnModelLinkP modelLinkP = dynamic_cast<DgnModelLinkP>(modelLeaf->GetLinkP());
    	if (modelLinkP == NULL)
    		return;
    
    	modelLinkP->SetModelName(L"xxDrawing");
    	modelLinkP->SetModelType(DgnModelType::Sheet);
    
    	status = modelLinkP->SetFileLink(fileLinkP);//return:32768
    	if (status != SUCCESS)
    		return;
    
    	WString name = modelLinkP->BuildSuggestedName(&treeRootR, true);
    	WString uniqueName = treeRootR.GetUniqueChildName(name.GetWCharCP());
    	modelLeaf->SetName(uniqueName.GetWCharCP());
    
    #pragma endregion