马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
- [CommandMethod("SetDynamicBlkProperty")]
- static public void SetDynamicBlkProperty()
- {
- Document doc = Application.DocumentManager.MdiActiveDocument;
- Database db = doc.Database;
- Editor ed = doc.Editor;
- PromptEntityOptions prEntOptions = new PromptEntityOptions(
- "Select a dynamic block reference...");
- PromptEntityResult prEntResult = ed.GetEntity(prEntOptions);
- if (prEntResult.Status != PromptStatus.OK)
- {
- ed.WriteMessage("Error...");
- return;
- }
- using(Transaction Tx = db.TransactionManager.StartTransaction())
- {
- BlockReference bref = Tx.GetObject(
- prEntResult.ObjectId,
- OpenMode.ForWrite)
- as BlockReference;
- if (bref.IsDynamicBlock)
- {
- DynamicBlockReferencePropertyCollection props =
- bref.DynamicBlockReferencePropertyCollection;
- foreach (DynamicBlockReferenceProperty prop in props)
- {
- object[] values = prop.GetAllowedValues();
- //Switch Property
- if (prop.PropertyName == "Visibility" && !prop.ReadOnly)
- {
- if (prop.Value.ToString() == values[0].ToString())
- prop.Value = values[1];
- else
- prop.Value = values[0];
- }
- }
- }
- Tx.Commit();
- }
- }
|