[V8i] Add and Delete Design Links within a CellElement

Hello,

I want to create Design Links (not the ‘engineering links’) to some Elements that are in a CellElement.
Here in the forum I found just a command "ELEMENT CREATE LINK URL xxx" which is only working on a selected Element.
Unfortunately I could not find any API or examples to that topic.


Is that possible to create the DesingLinks with for example an ElementID or elementRef in V8?

Thanks and Regards!

Lukas

Parents
  • I could not find any API or examples [about Design Links]

    The MicroStation V8i API won't help you.  But, with MicroStation CONNECT you can find the DgnLinkManager class in the C++ MicroStationAPI: The Drawing Set interface allows programs to manipulate drawing sets and drawing links stored in dgn idx files.

    I can't see anything similar in the DgnPlatformNet API.

     
    Regards, Jon Summers
    LA Solutions

    Answer Verified By: Robert Hook 

  • Thanks Jon!
    I was hoping that there is something that I couldn't find. In the CONNECT there are more possibilities but unfortunately I need that for the V8i.

    Regards,

    Lukas

  • Just as Jon mentioned, there is no public APIs for the design link in V8i. Below example is for CE.

    void addDgnFileLink(WCharCP unparsed)
    {
    	ElementHandle eh(2733L, ACTIVEMODEL);  //Here MUST use ElementHandle
    	if (!eh.IsValid())
    	{
    		mdlDialog_dmsgsPrint(L"ElementHandle is invalid.");
    		return;
    	}
    	DgnLinkTreeSpecPtr spec = DgnLinkManager::CreateTreeSpec(eh);
    	DgnLinkTreePtr linkTree = DgnLinkManager::ReadLinkTree(*spec, true);
    	DgnLinkTreeBranchR root = linkTree->GetRootR();
    
    	StatusInt status;
    	auto leaf = DgnLinkManager::CreateLink(status, DGNLINK_TYPEKEY_File);
    	DgnDocumentMonikerPtr moniker = DgnDocumentMoniker::CreateFromFileName(L"C:\\temp\\test.dgn");
    	DgnLinkP link = leaf->GetLinkP();
    	DgnFileLinkP fileLink = dynamic_cast<DgnFileLinkP>(link);
    	fileLink->SetMoniker(moniker.get(), true);
    
    	WString name = link->BuildSuggestedName(&root, true);
    	WString uniqueName = root.GetUniqueChildName(name.GetWCharCP());
    	leaf->SetName(uniqueName.GetWCharCP());
    	
    	root.AddChild(*leaf, 0);
    	DgnLinkManager::WriteLinkTree(*linkTree);
    }



    Answer Verified By: Robert Hook 

Reply
  • Just as Jon mentioned, there is no public APIs for the design link in V8i. Below example is for CE.

    void addDgnFileLink(WCharCP unparsed)
    {
    	ElementHandle eh(2733L, ACTIVEMODEL);  //Here MUST use ElementHandle
    	if (!eh.IsValid())
    	{
    		mdlDialog_dmsgsPrint(L"ElementHandle is invalid.");
    		return;
    	}
    	DgnLinkTreeSpecPtr spec = DgnLinkManager::CreateTreeSpec(eh);
    	DgnLinkTreePtr linkTree = DgnLinkManager::ReadLinkTree(*spec, true);
    	DgnLinkTreeBranchR root = linkTree->GetRootR();
    
    	StatusInt status;
    	auto leaf = DgnLinkManager::CreateLink(status, DGNLINK_TYPEKEY_File);
    	DgnDocumentMonikerPtr moniker = DgnDocumentMoniker::CreateFromFileName(L"C:\\temp\\test.dgn");
    	DgnLinkP link = leaf->GetLinkP();
    	DgnFileLinkP fileLink = dynamic_cast<DgnFileLinkP>(link);
    	fileLink->SetMoniker(moniker.get(), true);
    
    	WString name = link->BuildSuggestedName(&root, true);
    	WString uniqueName = root.GetUniqueChildName(name.GetWCharCP());
    	leaf->SetName(uniqueName.GetWCharCP());
    	
    	root.AddChild(*leaf, 0);
    	DgnLinkManager::WriteLinkTree(*linkTree);
    }



    Answer Verified By: Robert Hook 

Children
No Data