[CommandMethod("TestDynParams")]
public void TestDynParamsRun()
{
Document adoc = Application.DocumentManager.MdiActiveDocument;
Database db = adoc.Database;
Editor ed = adoc.Editor;
PromptEntityOptions blkSelOpt = new PromptEntityOptions("\nSelect block: ");
blkSelOpt.SetRejectMessage("\nThis is not block!");
blkSelOpt.AddAllowedClass(typeof(BlockReference), true);
PromptEntityResult blkSelRes = ed.GetEntity(blkSelOpt);
if (blkSelRes.Status == PromptStatus.OK)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockReference blkRef = tr.GetObject(blkSelRes.ObjectId, OpenMode.ForRead) as BlockReference;
if (blkRef.IsDynamicBlock)
{
DynamicBlockReferencePropertyCollection dynPropCol = blkRef.DynamicBlockReferencePropertyCollection;
foreach (DynamicBlockReferenceProperty prop in dynPropCol)
{
// Свойство отражения
if (prop.UnitsType == DynamicBlockReferencePropertyUnitsType.NoUnits && prop.PropertyTypeCode == 3)
{
ed.WriteMessage("Name: {0}, value: {1}", prop.PropertyName, prop.Value);
}
}
}
tr.Commit();
}
}
}