static public void Plan2CenterBlockSelBlock() { try { if (!OpenPalette()) { return; } var opts = Globs.TheOptions; _AcAp.Document doc = _AcAp.Application.DocumentManager.MdiActiveDocument; using (_AcAp.DocumentLock m_doclock = doc.LockDocument()) { _AcAp.DocumentCollection dm = _AcAp.Application.DocumentManager; if (doc == null) { return; } _AcEd.Editor ed = doc.Editor; #if NEWSETFOCUS doc.Window.Focus(); #else Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); // previous 2014 AutoCAD - Versions #endif _AcEd.PromptNestedEntityResult per = ed.GetNestedEntity("\nBlock wählen: "); if (per.Status == _AcEd.PromptStatus.OK) { using (var tr = doc.TransactionManager.StartTransaction()) { _AcDb.DBObject obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead); _AcDb.BlockReference br = obj as _AcDb.BlockReference; if (br == null) { br = Plan2Ext.Globs.GetBlockFromItsSubentity(tr, per); if (br == null) { return; } } opts.SetBlockname(br.Name); tr.Commit(); } } } } catch (System.Exception ex) { _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Fehler in Plan2CenterBlockSelBlock aufgetreten! {0}", ex.Message)); } }
private static bool GetAttributeInfos(_AcEd.Editor ed, _AcAp.Document doc) { bool ok = false; _BlockName = string.Empty; _AttributeName = string.Empty; _AttributeValue = string.Empty; _AcEd.PromptNestedEntityResult per = ed.GetNestedEntity("\nZu änderndes Attribut wählen: "); if (per.Status == _AcEd.PromptStatus.OK) { using (var tr = doc.TransactionManager.StartTransaction()) { _AcDb.DBObject obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead); _AcDb.AttributeReference ar = obj as _AcDb.AttributeReference; if (ar != null && !ar.IsConstant) { _AcDb.BlockReference br = Plan2Ext.Globs.GetBlockFromItsSubentity(tr, per); if (br != null) { ed.WriteMessage(string.Format(CultureInfo.CurrentCulture, "\nBlockname: {0}, Attributname: {1}.", Plan2Ext.Globs.GetBlockname(br, tr), ar.Tag)); var prompt = new _AcEd.PromptStringOptions("\nText in Attribut: "); prompt.AllowSpaces = true; var prefixUserRes = ed.GetString(prompt); if (prefixUserRes.Status == _AcEd.PromptStatus.OK) { _AttributeValue = prefixUserRes.StringResult; _AttributeName = ar.Tag; _BlockName = Plan2Ext.Globs.GetBlockname(br, tr); log.InfoFormat(CultureInfo.CurrentCulture, "Block: {0}, Attribut: {1}, Wert: '{2}'", _BlockName, _AttributeName, _AttributeValue); ok = true; } } } tr.Commit(); } } return(ok); }