We did it in AutoCAD, but failed in RealDWG.
the methodology is find the dynamic block definition and re-generate all dimensions, after re-generate, the hatch and dimension will update it automatically.
Who know how to do it in RealDWG?
the C# code is following:
Dictionary<string, object> updatePropertys = new Dictionary<string, object>();
updatePropertys.Add("Seg_L", 18);
updatePropertys.Add("Seg_H", 20);
Document doc = AcadApp.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
bool IsModify = false;
List<ObjectId> RefreshBlock = new List<ObjectId>();
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
foreach (ObjectId id in btr)
{
if (id.IsErased || id.IsNull || !id.IsValid)
continue;
Entity ent = (Entity)tr.GetObject(id, OpenMode.ForWrite);
if (!ent.Visible)
continue;
if (ent is BlockReference)
{
BlockReference block = ent as BlockReference;
if (!block.Name.Equals("CC_101"))
continue;
if (block.IsDynamicBlock)
{
DynamicBlockReferencePropertyCollection dbc = block.DynamicBlockReferencePropertyCollection;
foreach (DynamicBlockReferenceProperty dp in dbc)
{
if (dp.ReadOnly)
{
continue;
}
if (updatePropertys.Keys.Contains(dp.PropertyName))
{
try
{
if (!RefreshBlock.Contains(block.BlockTableRecord))
RefreshBlock.Add(block.BlockTableRecord);
dp.Value = updatePropertys[dp.PropertyName];
IsModify = true;
}
catch (Autodesk.AutoCAD.Runtime.Exception ex)
{
}
}
}
}
}
}
if (IsModify)
{
tr.Commit();
}
}
if (RefreshBlock.Count > 0)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
foreach (ObjectId bid in RefreshBlock)
{
BlockTableRecord btrs = (BlockTableRecord)tr.GetObject(bid, OpenMode.ForRead);
foreach (ObjectId obd in btrs)
{
Entity ents = (Entity)tr.GetObject(obd, OpenMode.ForRead);
if (ents is Dimension)
{
Dimension dim = ents as Dimension;
dim.UpgradeOpen();
}
}
}
tr.Commit();
}
}