using Autodesk.Aec.Building.Piping.DatabaseServices;
using Autodesk.AutoCAD.DatabaseServices;
namespace TheSwamp.Mep.OverRules
{
public class PipeOverrule : ObjectOverrule<Pipe>
{
public override void Close(DBObject dbObject)
{
if (dbObject.IsWriteEnabled && dbObject.IsModified && !dbObject.IsUndoing && !dbObject.IsErased)
{
var pipe = dbObject as Pipe;
if(pipe != null)
{
var database = dbObject.Database;
using (var transaction = database.TransactionManager.StartOpenCloseTransaction())
{
var pipeSystemId = transaction.GetObject(pipe.SystemId, OpenMode.ForRead) as PipeSystemDefinition;
if (pipeSystemId != null)
{
PipeOverRuleHelper.SetInsulationThickness(pipeSystemId, pipe);
}
else
{
PipeOverRuleHelper.ErrorMessage("** Error ** Unable to determine piping system.");
}
transaction.commit();
}
}
else
{
PipeOverRuleHelper.ErrorMessage("** Error ** Unable to obtain pipe information.");
}
}
base.Close(dbObject);
}
}
}