AutoCAD auto cleanup – a script on close

Research links:

  • talk of general cleanup that one should do
  • triggers in AutoCAD are called reactors (this is a good starter article)
  • A colleague mentioned not to do anything that takes up too much time on a document close reactor – because it triggers AFTER the close has been issued.
    • I suggested on a save? And the answer was yes, overwrite the qsave function and call a qsave at the end of that routine.
  • we are looking for a drawing reactor – when the doc saves. It mentions to use the vlr-types command to return a complete list of available reactor types.
  • a “before close” reactor … almost exists – read this. Yes – this is the ticket. Change “CLOSE” to “QSAVE” or “QUIT” … or all 3 if you wish. It works.

What is being attempted at the end of the day is to overcome shortcomings in Bentley’s AutoPLANT when components in the dwg model exist and are not synced to the database and vice-versa. Here are some general Bentley clean up articles.

  • Repairing Missing Component Data In AutoPLANT 3D 2004 Edition [CS] (it is 2004 but not much has changed I noticed – the commands referenced in there are being blogged/discussed in 2009, 2010 and 2011) . It describes the the  AT_DBPIPE_REPAIRRELATIONSHIPS command which I needed a long time ago.
  • AT_DBPIPE_RECOVERDATA – not quite sure what this does yet…
  • AT_PROJECTDB_REPAIR – this is another command to get things synced but seems to be a last ditch effort