this.format = new AFormat(format, (int)crat, orientation);
string fileName = "Test.dwg", blockName = "Test";
try
{
using (DocumentLock acLckDoc = this.document.LockDocument())
{
using (Transaction acTrans = this.database.TransactionManager.StartTransaction())
{
BlockTable acBlkTbl = acTrans.GetObject(this.database.BlockTableId, OpenMode.ForRead) as BlockTable;
ObjectId blkRecId = ObjectId.Null;
blkRecId = acBlkTbl[blockName];
this.format = new AFormat(format, crat, orientation);
this.BRef = new BlockReference(new Point3d(0, 0, 0), blkRecId);
DynamicBlockReferencePropertyCollection blkPropCollect = this.BRef.DynamicBlockReferencePropertyCollection;
foreach (DynamicBlockReferenceProperty prop in blkPropCollect)
{
object[] values = prop.GetAllowedValues();
if (prop.PropertyName == "Width" && !prop.ReadOnly)
{
if (this.format.Orientation == "HEIGHT")
prop.Value = values[this.format.index];
else
prop.Value = values[this.format.index+1];
}
if (prop.PropertyName == "Height" && !prop.ReadOnly)
{
if (this.format.Orientation == "HEIGHT")
prop.Value = values[this.format.index+1];
else
prop.Value = values[this.format.index];
}
editor.WriteMessage("\n" + prop.PropertyName);
}
BlockJig entJig = new BlockJig(this.BRef);
BlockTableRecord ms = (BlockTableRecord)acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
PromptResult pr = this.editor.Drag(entJig);
if (pr.Status == PromptStatus.OK)
{
ms.AppendEntity(this.BRef);
acTrans.AddNewlyCreatedDBObject(this.BRef, true);
}
acTrans.Commit();
}
}
}
catch (System.Exception e)
{
MessageBox.Show(e.Message);
}