Exemplo n.º 1
0
        public ObjectId GetSiteId(ObjectId surfaceId)
        {
            var site = ObjectId.Null;

            using (Transaction tr = CivilApplicationManager.StartTransaction())

            {
                Autodesk.AutoCAD.DatabaseServices.Database db = CivilApplicationManager.WorkingDatabase;
                var doc = CivilDocument.GetCivilDocument(db);
                ObjectIdCollection siteIds = doc.GetSiteIds();
                if (siteIds != null && siteIds.Count != 0)
                {
                    site = (from s in siteIds.Cast <ObjectId>()
                            select s).FirstOrDefault();
                }

                if (site == ObjectId.Null)
                {
                    site = C3DLandDb.Site.Create(doc, "Site-ALL");
                }

                tr.Commit();
            }
            return(site);
        }
Exemplo n.º 2
0
        public void AddCivil2016Breakline(ObjectId SurfaceId, ObjectId polyId, ObjectId siteId, string name)
        {
            using (Transaction tr = CivilApplicationManager.StartTransaction())
            {
                ObjectId featureId            = ObjectId.Null;
                C3DLandDb.FeatureLine feature = null;

                var checkPoly = polyId.GetObject(OpenMode.ForRead, false, true) as Polyline;

                if (checkPoly != null)
                {
                    featureId = C3DLandDb.FeatureLine.Create(GetFeatureLineName(), polyId, siteId);
                }

                feature = (C3DLandDb.FeatureLine)featureId.GetObject(OpenMode.ForRead);
                feature.AssignElevationsFromSurface(SurfaceId, true);
                var p3Dcollection = feature.GetPoints(FeatureLinePointType.AllPoints);

                //Polyline3d poly = new Polyline3d(Poly3dType.SimplePoly, p3Dcollection, true);
                //tr.AddNewlyCreatedDBObject(poly,true);

                C3DLandDb.TinSurface surface = SurfaceId.GetObject(OpenMode.ForWrite) as C3DLandDb.TinSurface;

                //ObjectIdCollection entities = new ObjectIdCollection();
                //entities.Add(poly.ObjectId);
                surface.BreaklinesDefinition.AddStandardBreaklines(p3Dcollection, 1.0, 2.0, 1.0, 0.0);
                tr.Commit();
            }
        }
Exemplo n.º 3
0
 public void SelectProcessCommand(Autodesk.AutoCAD.DatabaseServices.ObjectId id)
 {
     if (_processCommandsIdx.ContainsKey(id))
     {
         processCommandBindingSource.Position = _processCommandsIdx[id] - _startIdx;
     }
 }
Exemplo n.º 4
0
        public string ReadDWGFile(string dwgPath)
        {
            string pResult = string.Empty;

            //打开
            Autodesk.AutoCAD.DatabaseServices.Database pDwgDB = new Autodesk.AutoCAD.DatabaseServices.Database(false, true);
            pDwgDB.ReadDwgFile(dwgPath, System.IO.FileShare.ReadWrite, true, null);

            //为了让插入块的函数在多个图形文件打开的情况下起作用,你必须使用下面的函数把Dwg文件关闭
            pDwgDB.CloseInput(true);

            Autodesk.AutoCAD.DatabaseServices.Transaction pTransaction = pDwgDB.TransactionManager.StartTransaction();

            //打开源的块表
            Autodesk.AutoCAD.DatabaseServices.BlockTable pBlockTable =
                (Autodesk.AutoCAD.DatabaseServices.BlockTable)pTransaction.GetObject(
                    pDwgDB.BlockTableId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);

            //打开模型空间块表记录
            Autodesk.AutoCAD.DatabaseServices.BlockTableRecord pBlockTableRecord =
                (Autodesk.AutoCAD.DatabaseServices.BlockTableRecord)pTransaction.GetObject(
                    pBlockTable[Autodesk.AutoCAD.DatabaseServices.BlockTableRecord.ModelSpace], Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead);



            foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId pObjID in pBlockTableRecord)
            {
                Autodesk.AutoCAD.DatabaseServices.DBObject pDBObject =
                    (Autodesk.AutoCAD.DatabaseServices.DBObject)pTransaction.GetObject(pObjID, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead, false, true);

                if (pDBObject.GetRXClass().DxfName.ToUpper() == "INSERT")
                {
                    Autodesk.AutoCAD.DatabaseServices.BlockReference pBlockReference = (Autodesk.AutoCAD.DatabaseServices.BlockReference)pDBObject;
                    if (pBlockReference.AttributeCollection.Count != 0)
                    {
                        System.Collections.IEnumerator pEnumerator = pBlockReference.AttributeCollection.GetEnumerator();
                        while (pEnumerator.MoveNext())
                        {
                            Autodesk.AutoCAD.DatabaseServices.ObjectId pObjectID = (Autodesk.AutoCAD.DatabaseServices.ObjectId)pEnumerator.Current;

                            Autodesk.AutoCAD.DatabaseServices.AttributeReference pAttributeReference =
                                (Autodesk.AutoCAD.DatabaseServices.AttributeReference)pTransaction.GetObject(
                                    pObjectID, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead, false, true);

                            pResult += pAttributeReference.TextString;
                        }
                    }
                }


                pTransaction.Commit();
                pBlockTableRecord.Dispose();
                pBlockTable.Dispose();
                pDwgDB.Dispose();
            }

            return(pResult);
        }
Exemplo n.º 5
0
        private static string GetCadEntityidString(CadObjId cadobjid)
        {
            if (cadobjid == null)
            {
                return(null);
            }
            long enid = (long)cadobjid.OldIdPtr;

            return(enid.ToString());
        }
Exemplo n.º 6
0
        public ObjectId FindCivilTinSurface(string surfaceName)
        {
            ObjectId requested = findSurface(surfaceName);

            if (requested == ObjectId.Null)
            {
                return(ObjectId.Null);
            }

            return(requested);
        }
Exemplo n.º 7
0
 public void AddStandardBreakline(ObjectId SurfaceId, ObjectId polyId, string name)
 {
     using (Transaction tr = CivilApplicationManager.StartTransaction())
     {
         C3DLandDb.TinSurface surface  = SurfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
         ObjectIdCollection   entities = new ObjectIdCollection();
         entities.Add(polyId);
         surface.BreaklinesDefinition.AddStandardBreaklines(entities, 1.0, 1.0, 1.0, 0.0);
         tr.Commit();
     }
 }
Exemplo n.º 8
0
        public ObjectId GetFeatureLineSiteId(ObjectId featureId)
        {
            Debug.WriteLine("Starting GetFeatureLineSiteId");

            using (Transaction tr = CivilApplicationManager.StartTransaction())
            {
                var feature = (C3DLandDb.FeatureLine)featureId.GetObject(OpenMode.ForRead, false, true);
                var siteid  = feature.SiteId;

                Debug.WriteLine("Ending GetFeatureLineSiteId");
                return(siteid);
            }
        }
Exemplo n.º 9
0
        public void AddFeatureLinesToAllSurface(ObjectIdCollection featureIds, ObjectId surfaceId)
        {
            Debug.WriteLine("Starting AddFeatureLinesToAllSurface");
            using (Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                using (Transaction tr = CivilApplicationManager.StartTransaction())
                {
                    C3DLandDb.TinSurface surface = surfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
                    surface.UpgradeOpen();
                    surface.BreaklinesDefinition.AddStandardBreaklines(featureIds, 1.0, 2.0, 2.0, 0.0);
                    surface.DowngradeOpen();

                    tr.Commit();
                    Debug.WriteLine("Ending AddFeatureLinesToAllSurface");
                }
            }
        }
Exemplo n.º 10
0
        public ObjectId AddCivil2016BreaklineByTrans(ObjectId SurfaceId, ObjectId polyId, ObjectId siteId, string name)
        {
            ObjectId featureId = ObjectId.Null;

            C3DLandDb.FeatureLine feature = null;
            var layername = "";

            Debug.WriteLine("Starting AddCivil2016BreaklineByTrans");

            using (Application.DocumentManager.MdiActiveDocument.LockDocument())
            {
                using (Transaction tr = CivilApplicationManager.StartTransaction())
                {
                    var checkPoly = polyId.GetObject
                                        (OpenMode.ForRead, false, true) as Polyline;

                    if (checkPoly != null)
                    {
                        featureId = C3DLandDb.FeatureLine.Create
                                        (GetFeatureLineName(), polyId, siteId);

                        layername = checkPoly.Layer;
                        var color = checkPoly.Color;

                        feature = featureId.GetObject(OpenMode.ForWrite) as C3DLandDb.FeatureLine;

                        feature.Layer = layername;
                        feature.Color = color;
                        feature.Name += layername + "-" + String.Format("A{0:0#}A", feature.Area) + "-" + DateTime.Now.Millisecond;
                    }
                    else
                    {
                        tr.Abort();
                        Debug.WriteLine("Aborted AddCivil2016BreaklineByTrans " +
                                        layername + " Count: " + checkPoly.NumberOfVertices);
                    }

                    tr.Commit();

                    Debug.WriteLine("Ending AddCivil2016BreaklineByTrans" +
                                    layername + " Count: " + checkPoly.NumberOfVertices);

                    return(featureId);
                }
            }
        }
Exemplo n.º 11
0
        private static bool UpdateOneEntityId(long vportnumber, CadObjId penid)
        {
            string updateSql = "REPLACE INTO pentity (mobjectid,vportnumber) VALUES(@mobjectid,@vportnumber)";
            Dictionary <string, object> ups = new Dictionary <string, object>();


            ups.Add("mobjectid", penid);
            ups.Add("vportnumber", vportnumber);
            int count = ExecuteNonQuery(updateSql, ups);

            if (count > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 12
0
        public object OpenFeatureLineForSave(ObjectId featureId)
        {
            Debug.WriteLine("Starting OpenFeatureLineForSave");

            using (Transaction tr = CivilApplicationManager.StartTransaction())
            {
                var feature       = (C3DLandDb.FeatureLine)featureId.GetObject(OpenMode.ForWrite, false, true);
                var p3Dcollection = feature.GetPoints(FeatureLinePointType.AllPoints);

                var poly3d = new Polyline3d(Poly3dType.SimplePoly, p3Dcollection, true);
                poly3d.Layer = feature.Layer;
                poly3d.Color = feature.Color;
                _polylines.Add(poly3d);

                //C3DLandDb.TinSurface surface = surfaceId.GetObject(OpenMode.ForWrite) as C3DLandDb.TinSurface;
                //surface.BreaklinesDefinition.AddStandardBreaklines(p3Dcollection, 1.0, 2.0, 5.0, 0.0);

                tr.Commit();
                Debug.WriteLine("Ending OpenFeatureLineForSave");
                return(poly3d);
            }
        }
Exemplo n.º 13
0
 public bool AddStandardBoundary(ObjectId polyId, string name, ObjectId surfaceId)
 {
     try
     {
         PasteSurfaces pasteSurfaces = new PasteSurfaces();
         var           db            = CivilApplicationManager.WorkingDatabase;
         var           doc           = CivilDocument.GetCivilDocument(db);
         using (Transaction tr = db.TransactionManager.StartTransaction())
         {
             C3DLandDb.TinSurface surface = surfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;
             //surface.UpgradeOpen();
             pasteSurfaces.AddStandardBoundary(polyId, name, surface);
             //surface.DowngradeOpen();
             tr.Commit();
         }
         return(true);
     }
     catch (Exception ex)
     {
         MessengerManager.MessengerManager.LogException(ex);
     }
     return(false);
 }
Exemplo n.º 14
0
        private void btnSelect_Click(object sender, EventArgs e)
        {
            Editor ed            = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
            Guid   StartPoleCode = Guid.Empty;

            Autodesk.AutoCAD.DatabaseServices.ObjectId _BranchOi = Autodesk.AutoCAD.DatabaseServices.ObjectId.Null;
            int _vol = 0;

            //gClamp.Visible = false;
            //gConsol.Visible = false;
            BranchesData.Clear();

            this.Hide();

            PromptSelectionOptions pso = new PromptSelectionOptions();

            pso.MessageForAdding = "Select Branches Please";

            //PromptEntityOptions PEO = new PromptEntityOptions(": \n");
            //PromptEntityResult PER = ed.GetEntity(PEO);
            PromptSelectionResult PSR = ed.GetSelection(pso);

            SelectdEntities.Clear();
            if (PSR.Status == PromptStatus.OK)
            {
                SelectionSet ss = PSR.Value;
                ////////if (ss.Count > 0)
                ////////{
                ////////    Atend.Base.Acad.AT_INFO SelectedBranchInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(ss[0].ObjectId);
                ////////    if (SelectedBranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor)
                ////////    {
                ////////        IsConductor = true;
                ////////    }
                ////////    else
                ////////    {
                ////////        IsConductor = false;
                ////////    }
                ////////}
                //MessageBox.Show("NUmber of selected entity : " + ss.Count.ToString());
                foreach (SelectedObject so in ss)
                {
                    ConsolsOIs.Clear();
                    ClampsOIs.Clear();
                    Atend.Base.Acad.AT_INFO BranchInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(so.ObjectId);
                    if (BranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor)
                    {
                        //MessageBox.Show("it was conductor");
                        //gConsol.Visible = true;
                        Atend.Base.Acad.AT_SUB BranchSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(so.ObjectId);
                        foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId oi in BranchSub.SubIdCollection)
                        {
                            Atend.Base.Acad.AT_INFO ConsolInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi);
                            if (ConsolInfo.NodeType == (int)Atend.Control.Enum.ProductType.Consol)
                            {
                                Atend.Base.Equipment.EConsol ConsolData = Atend.Base.Equipment.EConsol.AccessSelectByCode(ConsolInfo.ProductCode);
                                if (ConsolData.ConsolType == 0 || ConsolData.ConsolType == 1)
                                {
                                    ConsolsOIs.Add(oi);
                                    Autodesk.AutoCAD.DatabaseServices.Line BranchEntity = Atend.Global.Acad.UAcad.GetEntityByObjectID(so.ObjectId) as Autodesk.AutoCAD.DatabaseServices.Line;
                                    if (BranchEntity != null)
                                    {
                                        if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == BranchEntity.StartPoint)
                                        {
                                            StartPoleCode = new Guid(ConsolInfo.ParentCode);
                                            _BranchOi     = so.ObjectId;
                                            _vol          = ConsolData.VoltageLevel;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    else if (BranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper)
                    {
                        //MessageBox.Show("it was self keeper");
                        //gClamp.Visible = true;
                        Atend.Base.Acad.AT_SUB BranchSub = Atend.Base.Acad.AT_SUB.SelectBySelectedObjectId(so.ObjectId);
                        foreach (Autodesk.AutoCAD.DatabaseServices.ObjectId oi in BranchSub.SubIdCollection)
                        {
                            Atend.Base.Acad.AT_INFO ClampInfo = Atend.Base.Acad.AT_INFO.SelectBySelectedObjectId(oi);
                            if (ClampInfo.NodeType == (int)Atend.Control.Enum.ProductType.Kalamp)
                            {
                                Atend.Base.Equipment.EClamp ClampData = Atend.Base.Equipment.EClamp.AccessSelectByCode(ClampInfo.ProductCode);
                                if (ClampData.Type != 5)
                                {
                                    ClampsOIs.Add(oi);
                                    Autodesk.AutoCAD.DatabaseServices.Line BranchEntity = Atend.Global.Acad.UAcad.GetEntityByObjectID(so.ObjectId) as Autodesk.AutoCAD.DatabaseServices.Line;
                                    if (BranchEntity != null)
                                    {
                                        if (Atend.Global.Acad.UAcad.CenterOfEntity(Atend.Global.Acad.UAcad.GetEntityByObjectID(oi)) == BranchEntity.StartPoint)
                                        {
                                            StartPoleCode = new Guid(ClampInfo.ParentCode);
                                            _BranchOi     = so.ObjectId;
                                            _vol          = ClampData.VoltageLevel;
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (ConsolsOIs.Count == 2 || ClampsOIs.Count == 2)
                    {
                        //if (IsConductor)
                        //{
                        //    if (BranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.Conductor)
                        //    {
                        SelectdEntities.Add(Atend.Global.Acad.UAcad.GetEntityByObjectID(so.ObjectId));


                        DataRow NewDataRow = BranchesData.NewRow();
                        NewDataRow["BranchCode"] = BranchInfo.NodeCode;
                        NewDataRow["BranchType"] = Convert.ToInt32(BranchInfo.NodeType);
                        NewDataRow["BranchOI"]   = _BranchOi.ToString().Substring(1, _BranchOi.ToString().Length - 2);
                        //NewDataRow["IsSelected"] = true;
                        NewDataRow["Type"]     = (Convert.ToInt32(BranchInfo.NodeType) == (int)Atend.Control.Enum.ProductType.Conductor ? "سیم" : "کابل خودنگهدار");
                        NewDataRow["Voltage"]  = _vol;
                        NewDataRow["PoleCode"] = StartPoleCode;
                        BranchesData.Rows.Add(NewDataRow);

                        //int NewRowIndex = gvBranches.Rows.Add();
                        //gvBranches.Rows[NewRowIndex].Cells["BranchCode"].Value = BranchInfo.ProductCode;
                        //gvBranches.Rows[NewRowIndex].Cells["BranchType"].Value = Convert.ToInt32(BranchInfo.NodeType);
                        //gvBranches.Rows[NewRowIndex].Cells["BranchOI"].Value = _BranchOi.ToString().Substring(1, _BranchOi.ToString().Length - 2);
                        //gvBranches.Rows[NewRowIndex].Cells["IsSelected"].Value = true;
                        //gvBranches.Rows[NewRowIndex].Cells["Type"].Value = (Convert.ToInt32(BranchInfo.NodeType) == (int)Atend.Control.Enum.ProductType.Conductor ? "سیم" : "کابل خودنگهدار");
                        //gvBranches.Rows[NewRowIndex].Cells["Voltage"].Value = _vol;


                        //    }
                        //    gConsol.Visible = true;
                        //    gClamp.Visible = false;
                        //}
                        //else
                        //{
                        //    if (BranchInfo.NodeType == (int)Atend.Control.Enum.ProductType.SelfKeeper)
                        //    {
                        //        SelectdEntities.Add(Atend.Global.Acad.UAcad.GetEntityByObjectID(so.ObjectId));
                        //    }
                        //    gConsol.Visible = false;
                        //    gClamp.Visible = true;
                        //}
                    }
                } //end for
            }     // end if (PSR.Status == PromptStatus.OK)
            this.Show();
            DataView dv = new DataView(BranchesData);

            dv.RowFilter          = "BranchType=" + (cboBranchType.SelectedIndex == 0 ? (int)Atend.Control.Enum.ProductType.Conductor : (int)Atend.Control.Enum.ProductType.SelfKeeper);
            gvBranches.DataSource = dv;
            //MessageBox.Show("count:" + SelectdEntities.Count.ToString());
        }
Exemplo n.º 15
0
 ExtDictId(string label, Autodesk.AutoCAD.DatabaseServices.ObjectId val)
     :   base(label, val)
 {
     m_val = val;
 }
Exemplo n.º 16
0
        public static CadObjId[] GetViewportObjects(long vportnumber)
        {
            string sql = "SELECT * FROM pentity WHERE vportnumber =@vportnumber;";
            Dictionary <string, object> parameters = new Dictionary <string, object>();

            parameters.Add("vportnumber", vportnumber);

            DataTable          dt = ExecuteQuery(sql, parameters);
            CadObjId           cadobjid;
            CadObjIdCollection cadobjidls;
            long   pobjid;
            int    i = 0;
            string arraystring;
            int    pc = dt.Rows.Count;

            string[] tokens;// = values.Split(',');
            long[]   myItems;
            if (dt.Rows.Count > 0)
            {
                cadobjidls = new CadObjIdCollection();

                arraystring = dt.Rows[0].Field <string>("mobjectid");
                tokens      = arraystring.Split(',');
                myItems     = Array.ConvertAll <string, long>(tokens, long.Parse);
                foreach (long lid in myItems)
                {
                    cadobjid = new CadObjId((IntPtr)lid);
                    cadobjidls.Add(cadobjid);
                }
                CadObjId[] cabids = new CadObjId[cadobjidls.Count];
                cadobjidls.CopyTo(cabids, 0);
                return(cabids);
            }
            else
            {
                return(null);
            }


            //string sql = "SELECT * FROM pentity WHERE vportnumber =@vportnumber;";
            //Dictionary<string, object> parameters = new Dictionary<string, object>();
            //parameters.Add("vportnumber", vportnumber);

            //DataTable dt = ExecuteQuery(sql, parameters);
            //CadObjId cadobjid;
            //CadObjIdCollection cadobjidls;
            //long pobjid,pid1;
            //int i = 0;
            //int pc = dt.Rows.Count;
            //if (dt.Rows.Count > 0)
            //{
            //    cadobjidls = new CadObjIdCollection();

            //    foreach (DataRow dr in dt.Rows)
            //    {
            //        pobjid = dr.Field<long>("mobjectid");
            //        cadobjid = new CadObjId((IntPtr)pobjid);
            //        cadobjidls.Add(cadobjid);
            //    }
            //    return cadobjidls;
            // // pobjid= dt.Rows[0].Field<long>("mobjectid");
            //  ///pid1 = dt.Rows[1].Field<long>("mobjectid");
            //}
            //else
            //return null;
        }
Exemplo n.º 17
0
        /// <summary>
        /// Removes the pasted objects.
        /// </summary>
        /// <param name="entRes">The surface id resource.</param>
        /// <exception cref="System.ArgumentNullException"></exception>
        public void RemoveBoundaryOperations(ObjectId entRes)
        {
            #region SDI Non-Session
            // Document doc = Application.DocumentManager.MdiActiveDocument;
            //Editor ed = doc.Editor;
            #endregion

            CivilDocument doc = CivilDocument.GetCivilDocument(CivilApplicationManager.WorkingDatabase);

            Autodesk.AutoCAD.DatabaseServices.Database db = CivilApplicationManager.WorkingDatabase;

            try
            {
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    C3DLandDb.TinSurface surf = (C3DLandDb.TinSurface)entRes.GetObject(OpenMode.ForRead);
                    if (surf == null)
                    {
                        throw new ArgumentNullException(nameof(surf));
                    }

                    C3DLandDb.SurfaceOperationCollection  ops  = surf.Operations;
                    C3DLandDb.SurfaceDefinitionBoundaries ops1 = surf.BoundariesDefinition;
                    #region Surface Add Boundary Operation
                    for (int i = 0; i < ops.Count; i++)

                    {
                        C3DLandDb.SurfaceOperationAddBoundary op = ops[i] as C3DLandDb.SurfaceOperationAddBoundary;

                        if (op == null)
                        {
                            continue;
                        }
                        if (op.Count > 0)
                        {
                            ops.Remove(op);
                            break;
                        }
                    }
                    #endregion

                    #region Surface Existing Boundary Definitions
                    for (int i = 0; i < ops1.Count; i++)

                    {
                        if (ops1.Count == 0)
                        {
                            continue;
                        }
                        if (ops1.Count > 0)
                        {
                            ops1.RemoveAt(i);
                            break;
                        }
                    }

                    #endregion

                    surf.Rebuild();
                    tr.Commit();
                }
            }
            catch (Exception ex)
            {
                PGA.MessengerManager.MessengerManager.LogException(ex);
            }
        }
Exemplo n.º 18
0
        public void AddCivil2016ElevationsToFeature(ObjectId surfaceId, ObjectId featureId, ObjectId siteId,
                                                    object o)
        {
            try
            {
                PGA.MessengerManager.MessengerManager.AddLog("Starting AddCivil2016ElevationsToFeature");
                using (Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    using (Transaction tr = CivilApplicationManager.StartTransaction())
                    {
                        var feature = (C3DLandDb.FeatureLine)featureId.GetObject(OpenMode.ForRead);

                        if (feature == null)
                        {
                            return;
                        }

                        feature.UpgradeOpen();
                        feature.AssignElevationsFromSurface(surfaceId, false);
                        feature.DowngradeOpen();

                        //Check and Refine Zeros from Breakline
                        FeatureLineManager.SendMessage(feature);
                        FeatureLineManager.CheckElevFromFeatureLine(feature.ObjectId);

                        var p3Dcollection = feature.GetPoints(FeatureLinePointType.AllPoints);

                        C3DLandDb.TinSurface surface = surfaceId.GetObject(OpenMode.ForRead) as C3DLandDb.TinSurface;

                        if (surface == null)
                        {
                            return;
                        }

                        surface.UpgradeOpen();
                        ///Todo:Handle Breaklines for Water and Bulkhead
                        ///
                        surface.BuildOptions.NeedConvertBreaklines             = true;
                        surface.BuildOptions.ExecludeMinimumElevation          = true;
                        surface.BuildOptions.MinimumElevation                  = 0.1;
                        surface.BuildOptions.CrossingBreaklinesElevationOption =
                            CrossingBreaklinesElevationType.UseLast; ///Todo: Changed 2/19/17 from None.
                        surface.BreaklinesDefinition.AddStandardBreaklines(p3Dcollection, 1.0, 2.0, 2.0, 0.0);
                        surface.DowngradeOpen();

                        tr.Commit();
                        PGA.MessengerManager.MessengerManager.AddLog("Ending AddCivil2016ElevationsToFeature");
                    }
                }
            }
            catch (Autodesk.AutoCAD.Runtime.Exception ex)
            {
                PGA.MessengerManager.MessengerManager.LogException(ex);
            }
            catch (System.AccessViolationException ex)
            {
                PGA.MessengerManager.MessengerManager.LogException(ex);
            }
            catch (System.Exception ex)
            {
                PGA.MessengerManager.MessengerManager.LogException(ex);
            }
        }