private void btnSelAbstand_Click(object sender, EventArgs e) { try { _AcAp.DocumentCollection dm = _AcAp.Application.DocumentManager; _AcAp.Document doc = dm.MdiActiveDocument; Editor ed = doc.Editor; #if NEWSETFOCUS doc.Window.Focus(); #else Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); // previous 2014 AutoCAD - Versions #endif PromptDoubleResult per = ed.GetDistance("\nTextabstand zeigen: "); if (per.Status == PromptStatus.OK) { _FensterOptions.TextAbstand = per.Value; txtAbstand.Text = _FensterOptions.TextAbstandString; } _AcAp.Application.DocumentManager.MdiActiveDocument.Editor.WriteMessage("\n"); } catch (Exception ex) { _AcAp.Application.ShowAlertDialog(ex.Message); } }
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 void btnAG_Click(object sender, EventArgs e) { try { _AcAp.DocumentCollection dm = _AcAp.Application.DocumentManager; _AcAp.Document doc = dm.MdiActiveDocument; Editor ed = doc.Editor; #if NEWSETFOCUS _AcAp.Application.DocumentManager.MdiActiveDocument.Window.Focus(); #else Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); // previous 2014 AutoCAD - Versions #endif PromptEntityResult per = ed.GetEntity("\nAbzugsfläche wählen: "); if (per.Status == PromptStatus.OK) { Transaction tr = doc.TransactionManager.StartTransaction(); using (tr) { string layer = string.Empty; DBObject obj = tr.GetObject(per.ObjectId, OpenMode.ForRead); layer = GetPolylineLayer(obj); if (string.IsNullOrEmpty(layer)) { return; } if (string.Compare(txtFG.Text, layer, StringComparison.OrdinalIgnoreCase) == 0) { _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Die Layer für Flächengrenze und Abzugsfläche müssen unterschiedlich sein.")); return; } txtAG.Text = layer; tr.Commit(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void InitDocEvents() { try { _AcAp.DocumentCollection dc = _AcAp.Application.DocumentManager as _AcAp.DocumentCollection; dc.DocumentActivated -= dc_DocumentActivated; dc.DocumentActivated += dc_DocumentActivated; //dc.DocumentCreated -= dc_DocumentCreated; //dc.DocumentCreated += dc_DocumentCreated; //dc.DocumentCreateStarted -= dc_DocumentCreateStarted; //dc.DocumentCreateStarted += dc_DocumentCreateStarted; } catch (Exception ex) { log.Error(ex.Message, ex); } }
private bool GetHeightFromVermBlocks(ref double height) { _AcAp.DocumentCollection dm = _AcAp.Application.DocumentManager; _AcAp.Document doc = dm.MdiActiveDocument; Editor ed = doc.Editor; #if NEWSETFOCUS doc.Window.Focus(); #else Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); // previous 2014 AutoCAD - Versions #endif PromptEntityResult per = ed.GetEntity("\nErsten Vermessungsblock wählen: "); //DocumentLock loc = dm.MdiActiveDocument.LockDocument(); //using (loc) //{ //} bool blockFound = false; double height1 = 0.0; double height2 = 0.0; if (per.Status == PromptStatus.OK) { Transaction tr = doc.TransactionManager.StartTransaction(); using (tr) { DBObject obj = tr.GetObject(per.ObjectId, OpenMode.ForRead); BlockReference br = obj as BlockReference; if (br == null) { return(false); } if (br.Name == "GEOINOVA") { blockFound = true; height1 = br.Position.Z; br.Highlight(); } if (blockFound) { blockFound = false; per = ed.GetEntity("\nZweiten Vermessungsblock wählen: "); if (per.Status == PromptStatus.OK) { obj = tr.GetObject(per.ObjectId, OpenMode.ForRead); BlockReference br2 = obj as BlockReference; if (br2 == null) { return(false); } if (br2.Name == "GEOINOVA") { blockFound = true; height2 = br2.Position.Z; } } if (blockFound) { height = Math.Abs(height1 - height2); } br.Unhighlight(); } tr.Commit(); } if (!blockFound) { return(false); } return(true); } return(false); }
static public void Plan2AutoIdAssignments() { try { if (!OpenAutoIdPalette()) { return; } var opts = Globs.TheAutoIdOptions; _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 SetAssignmentsDict(); _AutoIdPalette.SetLvZuweisungen(); //bool attSelected = false; //while (!attSelected) //{ // PromptNestedEntityOptions peo = new PromptNestedEntityOptions("\nZu-Raum-ID-Attribut wählen: "); // PromptNestedEntityResult per = ed.GetNestedEntity(peo); // if (per.Status == _AcEd.PromptStatus.OK) // { // using (var tr = doc.TransactionManager.StartTransaction()) // { // DBObject obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead); // _AcDb.AttributeReference attRef = obj as _AcDb.AttributeReference; // if (attRef != null) // { // attSelected = true; // opts.SetZuRaumIdAtt(attRef.Tag); // } // else // { // ed.WriteMessage("\nDas gewählte Element ist kein Attribut."); // } // tr.Commit(); // } // } // else // { // break; // } //} } } catch (System.Exception ex) { _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Fehler in Plan2AutoIdAssignments aufgetreten! {0}", ex.Message)); } }
static public void Plan2AutoIdSelPolygonLayer() { try { if (!OpenAutoIdPalette()) { return; } var opts = Globs.TheAutoIdOptions; _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.PromptNestedEntityOptions peo = new _AcEd.PromptNestedEntityOptions("\nPolylinie wählen: "); //peo.SetRejectMessage("\nDas gewählte Element ist keine Polylinie."); //peo.AddAllowedClass(typeof(Polyline), true); //peo.AddAllowedClass(typeof(Polyline2d), true); //peo.AddAllowedClass(typeof(Polyline3d), true); _AcEd.PromptEntityResult per = ed.GetNestedEntity(peo); if (per.Status == _AcEd.PromptStatus.OK) { using (var tr = doc.TransactionManager.StartTransaction()) { _AcDb.DBObject obj = tr.GetObject(per.ObjectId, _AcDb.OpenMode.ForRead); _AcDb.Entity ent = obj as _AcDb.Entity; if (ent != null) { if (ent is _AcDb.Polyline || ent is _AcDb.Polyline2d || ent is _AcDb.Polyline3d) { opts.SetPolygonLayer(Engine.RemoveXRefPart(ent.Layer)); } else { ed.WriteMessage("\nDas gewählte Element ist keine Polylinie."); } } tr.Commit(); } } } } catch (System.Exception ex) { _AcAp.Application.ShowAlertDialog(string.Format(CultureInfo.CurrentCulture, "Fehler in Plan2AutoIdSelPolygonLayer aufgetreten! {0}", ex.Message)); } }
private void btnSelectBlock_Click(object sender, EventArgs e) { try { _AcAp.DocumentCollection dm = _AcAp.Application.DocumentManager; _AcAp.Document doc = dm.MdiActiveDocument; Editor ed = doc.Editor; #if NEWSETFOCUS _AcAp.Application.DocumentManager.MdiActiveDocument.Window.Focus(); #else Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView(); // previous 2014 AutoCAD - Versions #endif PromptEntityResult per = ed.GetEntity("\nRaumblock wählen: "); //DocumentLock loc = dm.MdiActiveDocument.LockDocument(); //using (loc) //{ //} if (per.Status == PromptStatus.OK) { Transaction tr = doc.TransactionManager.StartTransaction(); using (tr) { DBObject obj = tr.GetObject(per.ObjectId, OpenMode.ForRead); BlockReference br = obj as BlockReference; if (br == null) { return; } txtBlockname.Text = Plan2Ext.Globs.GetBlockname(br, tr); tr.Commit(); } per = ed.GetNestedEntity("\nAttribut wählen: "); if (per.Status == PromptStatus.OK) { tr = doc.TransactionManager.StartTransaction(); using (tr) { DBObject obj = tr.GetObject(per.ObjectId, OpenMode.ForRead); AttributeReference ar = obj as AttributeReference; if (ar == null) { return; } txtAttribute.Text = ar.Tag; tr.Commit(); } } } } catch (Exception ex) { _AcAp.Application.ShowAlertDialog(ex.Message); } }