[CONNECT U13] DependencyManager: When the Root Element status is changed (DEPENDENCY_STATUS_CHANGED) is the "pre-changed" root element available?

SORRY FOR THE DUPLICATE POST - I CANNOT REMOVE IT

When a Root Element of a Dependency Linkage is modified, is the "pre-modified" version of that Root Element cached anywhere where one can obtain a ElementHandle to it?. The Dependent Element is passed into the OnRootsChanged() function, and one can use "dependencyLinkage.root.elemid[]" to get the Root Element(s), but these are the Root Element(s) AFTER they've been changed. Can you get the state of the element PRIOR to the current CHANGE?

My Root Element can be moved (positional change only) or modified (scaled/etc). It's the case where the Root's size is changed that it would be helpful to be able to have access to the original sized element.

Bruce

  • Can you get the state of the element PRIOR to the current CHANGE?

    There may be a better answer from the gold nugget mine, but think about SetElmDscrToFileFunction instead or as well as Dependency Manager. If something of interest is changed, I assume (you may want to verify my assumption) that ElmDscrToFile will be called before the dependency chain is shaken. Your callback SystemFunc_ElmDscrToFile can inspect the element and the change status. If that status is ELMDTF_ACTION_DELETE or ELMDTF_ACTION_REPLACE you can save the relevant information since you are given a before and after element descriptor. You can also call elementRef_getDependents to check whether any dependent is your dependent.

     
    Regards, Jon Summers
    LA Solutions

  • Initial test did not work. The ElmDscrToFile() callback DID fire before the Dependency Manager, but the dependency code crashed inside the dependency callback function. When I removed the enabling of the ElmDscrToFile() function, things were back "not crashing"..,

    ElmDscrToFile_Status	elmDscrToFile(ElmDscrToFile_Actions action, 
    		DgnModelRefP modelRef,		// model containing this element 
    		UInt32 filePos,				// file pos to modify
    		MSElementDescrP newEdP,		// the new element being written to the file (or NULL when action==ELMDTF_ACTION_DELETE) 
    		MSElementDescrCP oldEdP,	// the element in it's original state, in the case 
    									// of ELMDTF_ACTION_DELETE or ELMDTF_ACTION_REPLACE.
    									// (NULL in the case of ELMDTF_ACTION_APPEND). 
    		MSElementDescrH replacementEdPP)	// a pointer to a pointer to an element 
    									// descriptor that is allocated and then returned
    									// by userSystem_elmDscrToFile. If userSystem_elmDscrToFile
    									// returns ELMDTF_STATUS_REPLACE, MicroStation write
    									// this element descriptor to the file rather than
    									// the one pointed to by newEdP. Ownership of replacementEdP
    									// is passed to MicroStation. It frees this elemen
    									// descriptor when it is done with it. 
    {
    	// Action:
    	// ELMDTF_ACTION_APPEND  New elements are added to the end of the file.  
    	// ELMDTF_ACTION_DELETE  Existing elements are deleted from the file.
    	// ELMDTF_ACTION_REPLACE  Elements are overwritten in place.
    
    	wprintf(L"elmDscrToFile(), type=%d\n", mdlElement_getType(&oldEdP->el));
    	return ElmDscrToFile_Status::ELMDTF_STATUS_SUCCESS;
    }
    
    
    bool	unloadProgram(UnloadProgramReason reason)
    {
    	DependencyManagerLinkage::RemoveRootsChangedCallback(DEPENDENCYAPPID_Srs);
    	SystemCallback::SetElmDscrToFileFunction(nullptr);
    	return false;	// return true to prevent app from unloading
    }
    
    
    extern	"C"		DLLEXPORT void MdlMain
    (
    int				argc,
    WCharCP         argv[]
    )
    {
    //...
    SystemCallback::SetUnloadProgramFunction(unloadProgram);
    SystemCallback::SetElmDscrToFileFunction(elmDscrToFile);
    DependencyManagerLinkage::RegisterRootsChangedCallback(DEPENDENCYAPPID_Srs, &s_myChangedCallback);
    //...
    }