Untitled
unknown
csharp
a month ago
5.0 kB
4
Indexable
Never
[CommandMethod("LOTEMASTER")] public void LOTEMASTER() { #region REALIZA A SELEÇÃO DAS POLYLINES PromptSelectionOptions Opts = new PromptSelectionOptions(); Opts.MessageForAdding = "\nSelecione as POLYLINES dos LOTES"; Opts.MessageForRemoval = "\nApenas Polylines"; TypedValue[] Tipos = new TypedValue[11]; Tipos.SetValue(new TypedValue((int)DxfCode.Operator, "<OR"), 0); Tipos.SetValue(new TypedValue((int)DxfCode.Operator, "<AND"), 1); Tipos.SetValue(new TypedValue((int)DxfCode.Start, "ARC"), 2); Tipos.SetValue(new TypedValue((int)DxfCode.Operator, "AND>"), 3); Tipos.SetValue(new TypedValue((int)DxfCode.Operator, "<AND"), 4); Tipos.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 5); Tipos.SetValue(new TypedValue((int)DxfCode.Operator, "AND>"), 6); Tipos.SetValue(new TypedValue((int)DxfCode.Operator, "<AND"), 7); Tipos.SetValue(new TypedValue((int)DxfCode.Start, "LINE"), 8); Tipos.SetValue(new TypedValue((int)DxfCode.Operator, "AND>"), 9); Tipos.SetValue(new TypedValue((int)DxfCode.Operator, "OR>"), 10); SelectionFilter SF = new SelectionFilter(Tipos); PromptSelectionResult Sel = Manager.DocEditor.GetSelection(Opts, SF); if (Sel.Status != PromptStatus.OK) { return; } #endregion ObjectId IDSiteTemp = ObjectId.Null; using (Transaction TransCAD = Manager.DocData.TransactionManager.StartTransaction()) { BlockTableRecord Model = (BlockTableRecord)TransCAD.GetObject(Manager.DocData.CurrentSpaceId, OpenMode.ForWrite); // RECEBE TODAS AS POLYLINES EM FORMATO DE CLASSE PARA VERIFICAÇÃO IDSiteTemp = Autodesk.Civil.DatabaseServices.Site.Create(Manager.DocCivil, Guid.NewGuid().ToString()); Autodesk.Civil.DatabaseServices.Site Site = (Site)TransCAD.GetObject(IDSiteTemp, OpenMode.ForWrite); dynamic SiteACAD = Site.AcadObject; dynamic SiteParcelLines = SiteACAD.ParcelSegments(); for (int i = 0; i < Sel.Value.Count; i++) { Autodesk.AutoCAD.DatabaseServices.Entity PL = (Autodesk.AutoCAD.DatabaseServices.Entity)TransCAD.GetObject(Sel.Value[i].ObjectId, OpenMode.ForRead); var Segmentos = SiteParcelLines.AddFromEntity(PL.AcadObject, true); Segmentos.Name = "Lote " + i.ToString(); } TransCAD.Commit(); } string NomeSite = string.Empty; using (Transaction TransCAD = Manager.DocData.TransactionManager.StartTransaction()) { BlockTableRecord Model = (BlockTableRecord)TransCAD.GetObject(Manager.DocData.CurrentSpaceId, OpenMode.ForWrite); // RECEBE TODAS AS POLYLINES EM FORMATO DE CLASSE PARA VERIFICAÇÃO Autodesk.Civil.DatabaseServices.Site Site = (Site)TransCAD.GetObject(IDSiteTemp, OpenMode.ForRead); NomeSite = Site.Name; foreach (ObjectId IDParcel in Site.GetParcelIds()) { Autodesk.Civil.DatabaseServices.Parcel Parcela = (Autodesk.Civil.DatabaseServices.Parcel)TransCAD.GetObject(IDParcel, OpenMode.ForWrite); try { Polyline LimiteParcel = (Polyline)Parcela.BaseCurve; if (LimiteParcel != null) { LimiteParcel.ColorIndex = 4; Model.AppendEntity(LimiteParcel); TransCAD.AddNewlyCreatedDBObject(LimiteParcel, true); } } catch { } } TransCAD.Commit(); } var str = GetCivilAppString("Land"); dynamic acadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication; dynamic aeccApp = acadApp.GetInterfaceObject(str); dynamic aeccDoc = aeccApp.ActiveDocument; dynamic sites = aeccDoc.Sites; try { sites.Remove(NomeSite); } catch { } } string GetCivilAppString(string module) { var retval = ""; var ucm = HostApplicationServices.Current.UserRegistryProductRootKey; var lm = "HKEY_LOCAL_MACHINE\\" + ucm; var hj = Registry.LocalMachine.OpenSubKey(ucm); var c3d = (string)hj.GetValue("Release"); c3d = c3d.Substring(0, c3d.IndexOf(".", (c3d.IndexOf(".") + 1))); hj.Close(); retval = "AeccXUi" + module + ".Aecc" + (module == "Land" ? "" : module) + "Application." + c3d; return retval; }
Leave a Comment