Share

AcDbDatabase::purge

C++

Acad::ErrorStatus purge(
    AcDbObjectIdGraph& idGraph
);

Description

This version of the purge() method works in one pass. The method looks for references between the objects passed in so that it does not need to be called multiple times. In other words, if a Layer and a Linetype are passed in, and the only reference to the Linetype is from the Layer, then the graph returned will indicate that both the Layer and the Linetype can be purged. (The older AcDbObjectIdArray version of purge() would first indicate that only the Layer could be purged. Then a second call, after erasing the Layer, would say that the Linetype could be purged.)

A graph is returned so that you do not need to erase all the objects passed back, just like in the other purge(). However, if you want to selectively erase only part of the objects passed back, you must only erase root-type nodes on the graph. In other words, from the above example, the graph passed back would contain both the Layer and Linetype nodes, but there would be an edge from the Layer to the Linetype. Thus only the Layer would be a root-type node, with no incoming edges. That means that you could erase the Layer by itself, but not the Linetype. If you want to erase the Linetype, then you must also erase the Layer. That's why the return data is in a graph.

Note

  • Since the AcDbObjectIdGraph version (this method) does more checking, it is slower than the AcDbObjectIdArray version.
  • If only one type of symbol is being checked through purge(), and it is not a BTR (which can have references to each other), then the older, faster AcDbObjectIdArray purge() should be used.
  • Only use this version in cases where there were loops before. In other words, if the types of symbols being passed in can reference each other, then the purge(AcDbObjectIdArray) function would have had to have been called multiple times. Even though this function is slower, since it only has to be called once, it ends up being faster for this inter-reference case.
  • If you intend to always erase everything returned, then you do not have to examine the graph. You can just iterate on graph nodes and erase the objects, but you must erase all of them. The graph edges only need to be examined if part of the graph is to be erased, to make sure that no edges, or inter-references, are left dangling. In such a case, only nodes with no incoming edges (root-type nodes) can be erased.

Parameters

Parameters Description
idGraph Input graph of objects in the database. The graph will be returned containing only those objects that may safely be removed from the database.

Links

AcDbDatabase Class

Was this information helpful?