static public void SpaceOnAttributeName() { // Получение текущего документа и базы данных App.Document acDoc = App.Application.DocumentManager.MdiActiveDocument; Db.Database acCurDb = acDoc.Database; Ed.Editor acEd = acDoc.Editor; // старт транзакции using (Db.Transaction acTrans = acCurDb.TransactionManager.StartOpenCloseTransaction()) { Db.TypedValue[] acTypValAr = new Db.TypedValue[1]; acTypValAr.SetValue(new Db.TypedValue((int)Db.DxfCode.Start, "INSERT"), 0); Ed.SelectionFilter acSelFtr = new Ed.SelectionFilter(acTypValAr); Ed.PromptSelectionResult acSSPrompt = acDoc.Editor.GetSelection(acSelFtr); if (acSSPrompt.Status == Ed.PromptStatus.OK) { Ed.SelectionSet acSSet = acSSPrompt.Value; foreach (Ed.SelectedObject acSSObj in acSSet) { if (acSSObj != null) { if (acSSObj.ObjectId.ObjectClass.IsDerivedFrom(Rtm.RXClass.GetClass(typeof(Db.BlockReference)))) { Db.BlockReference acEnt = acTrans.GetObject(acSSObj.ObjectId, Db.OpenMode.ForRead) as Db.BlockReference; Db.BlockTableRecord blr = acTrans.GetObject(acEnt.BlockTableRecord, Db.OpenMode.ForRead) as Db.BlockTableRecord; if (acEnt.IsDynamicBlock) { blr = acTrans.GetObject(acEnt.DynamicBlockTableRecord, Db.OpenMode.ForRead) as Db.BlockTableRecord; } if (blr.HasAttributeDefinitions) { foreach (Db.ObjectId id in blr) { if (id.ObjectClass.IsDerivedFrom(Rtm.RXClass.GetClass(typeof(Db.AttributeDefinition)))) { Db.AttributeDefinition acAttrRef = acTrans.GetObject(id, Db.OpenMode.ForWrite) as Db.AttributeDefinition; if (acAttrRef != null) { acAttrRef.Tag = acAttrRef.Tag.Replace('_', ' '); } } } } } } } } acTrans.Commit(); } }
private void HideButton_Click(object sender, EventArgs e) { Parent.Parent.Parent.Hide(); // this is not mandatory ApplicationServices.Document document = ApplicationServices.Application.DocumentManager.MdiActiveDocument; EditorInput.PromptSelectionResult promptSelectionResult = document.Editor.GetSelection(); if (promptSelectionResult.Status == EditorInput.PromptStatus.OK) { document.Editor.WriteMessage(promptSelectionResult.Value.Count.ToString() + "\n"); } Parent.Parent.Parent.Show(); // this is mandatory if the form have been hidden }
public static List <AcadDB.ObjectId> PickEnts() { AcadApp.DocumentManager.MdiActiveDocument.Window.Focus(); using (AcadApp.DocumentManager.MdiActiveDocument.LockDocument()) { using (AcadDB.Transaction tr = AcadFuncs.GetActiveDoc().TransactionManager.StartTransaction()) { AcadEd.PromptSelectionResult prmpt_ret = AcadFuncs.GetEditor().GetSelection(); if (AcadEd.PromptStatus.Cancel == prmpt_ret.Status) { tr.Abort(); tr.Dispose(); return(new List <AcadDB.ObjectId>()); } tr.Commit(); return(prmpt_ret.Value.GetObjectIds().ToList()); } } }