Relation between element and view

Relation between element and view

tobias.floescher
Contributor Contributor
221 Views
2 Replies
Message 1 of 3

Relation between element and view

tobias.floescher
Contributor
Contributor

Hi all,

 

Following situation: I have a MEPSystem with some element. One of them is the main element. My plugin do things to this mep system, including of generation a new isometric View3D. Named after the mep system. works fine so far.

 

Now the problem: If I delete the mep system completely, how does the related View3D knows what to do? It should delete as well. I could link the mep system and the view with some attached storage, and listen to document changes, delete the view if necessary. Possible, but not elegant.

Is there a built in relationship model? Best would be a Revit native dialog pops up on deleting the mep system (or main element) saying "there is a linked view, delete as well?" like a floor plan is deleted if the user delete a level..

 

Any hints are welcome, thanks

Tobi

0 Likes
Accepted solutions (1)
222 Views
2 Replies
Replies (2)
Message 2 of 3

jeremy_tammik
Alumni
Alumni
Accepted solution

Yes, I see your point. That makes sense.

  

Off-hand, two possible approaches come to mind, more or less fully automated:

  

  • Use extensible storage markers and explicit clean-up
  • Use the dynamic model updater DMU framework for full automation

  

The first approach matches the idea you describe: Mark the associated elements in some manner, e.g., by storing specific data in extensible storage. For instance, you could store a reference to the MEP system somewhere in the view. The reference can be an element id, a unique id, or some other identifier. Secondly, implement an external command to clean up dangling objects. To use it, whenever you like, execute the command. It searched all MEP systems to check whether the corresponding views exist, and it checks all views to see whether the MEP system is still there, cleaning up as necessary.

  

The second approach automates the whole thing so that everything is always kep up to date automatically. The DynamicModelUpdate demonstrates how that can be achieved, and other discussions on DMU are presented by The Building Coder:

  

  

Even if you do decide to use DMU, you can implement it as a stand-alone external command for testing purposes first, and then modify it for DMU once you are sure it works as intended.

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes
Message 3 of 3

tobias.floescher
Contributor
Contributor

Hi @jeremy_tammik, thank you for your thoughts.

I guess best would be a DMU combined with an attached storage in the view, containing a reference as element id or similar to the mep system. In this flavor, it is not needed to couple the two objects with name compare. And it runs fully automatic, triggered by specific filter based rules.

0 Likes