Ejemplo n.º 1
0
        public ObjectId GetNewSiteId()
        {
            var    site = ObjectId.Null;
            Random rand = new Random();

            try
            {
                using (Application.DocumentManager.MdiActiveDocument.LockDocument())
                {
                    using (Transaction tr = CivilApplicationManager.StartTransaction())
                    {
                        var num = rand.Next(1000, 9999).ToString();

                        Autodesk.AutoCAD.DatabaseServices.Database db = CivilApplicationManager.WorkingDatabase;
                        var doc = CivilDocument.GetCivilDocument(db);

                        site = C3DLandDb.Site.Create(doc, "Site-" + num);

                        tr.Commit();
                    }
                }
            }
            catch (System.ArgumentException)
            {
                GetNewSiteId();
            }

            return(site);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        public void RaiseNetworkTo3d()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;

            if (doc == null)
            {
                return;
            }

            Database db = doc.Database;

            Editor ed = doc.Editor;

            CivilDocument cdok = CivilDocument.GetCivilDocument(doc.Database);

            try
            {
                ConfigureNetworkCreationView      configView = new ConfigureNetworkCreationView();
                ConfigureNetworkCreationViewModel viewModel  = new ConfigureNetworkCreationViewModel(doc, cdok, configView);
                configView.DataContext = viewModel;
                Application.ShowModalWindow(configView);
                //if (viewModel.AcceptBtnIsEnabled && viewModel.ConfigurationsAccepted)
                //{}
            }
            catch (System.Exception ex)
            {
                CommonException(ex, "Ошибка при создании модели сети");
            }
        }
Ejemplo n.º 4
0
 internal Document(acadAppSvcs.Document acadDoc)
 {
     m_AcadDocument      = acadDoc;
     m_CivilDocument     = CivilDocument.GetCivilDocument(m_AcadDocument.Database);
     m_DocumentLock      = null;
     m_ActiveTransaction = null;
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Initializes the object from an AutoCAD document and a Civil 3D
 /// document.
 /// </summary>
 /// <param name="acadDoc">Represented AutoCAD document.</param>
 /// <param name="civilDoc">Represented Civil 3D document.</param>
 /// <para>
 /// The class encapsulates access to the AutoCAD and Civil 3D
 /// document objects. The Document object is instantiated by the
 /// 'DocumentManager' class, which access the AutoCAD and Civil 3D
 /// document objects representing the same drawing and instantiates
 /// a new Document wrapper.
 /// </para>
 internal Document(acadappsvcs.Document acadDoc)
 {
     m_ThisAcadDocument  = acadDoc;
     m_ThisCivilDocument = CivilDocument.GetCivilDocument(
         m_ThisAcadDocument.Database);
     m_ActiveTransaction = null;
 }
Ejemplo n.º 6
0
    /// <summary>
    /// Create a corridor based on a switch name
    /// </summary>
    public static CivilCorridor CreateSwitchCorridor(string alignmentName, string prefix, string[] switches, Document document)
    {
        if (string.IsNullOrEmpty(alignmentName))
        {
            return(null);
        }
        if (string.IsNullOrEmpty(prefix))
        {
            return(null);
        }
        if (switches == null)
        {
            return(null);
        }
        if (document == null)
        {
            return(null);
        }

        var db  = document.AcDocument.Database;
        var doc = CivilDocument.GetCivilDocument(db);

        using (var ctx = new DocumentContext(db))
        {
            var id = ElementBinder.GetObjectIdFromTrace(ctx.Database);

            var switchList = "Connected Switches: ";

            foreach (var @switch in switches)
            {
                switchList += "-" + @switch;
            }

            if (id.IsValid && !id.IsErased)
            {
                using (var trans = db.TransactionManager.StartTransaction())
                {
                    var switchCorridor = (Corridor)trans.GetObject(id, OpenMode.ForWrite, false, true);
                    switchCorridor.Name        = prefix + alignmentName;
                    switchCorridor.Description = switchList;
                    trans.Commit();
                }
            }
            else
            {
                using (var trans = db.TransactionManager.StartTransaction())
                {
                    var corridorName = prefix + alignmentName;
                    id = doc.CorridorCollection.Add(corridorName);
                    var switchCorridor = (Corridor)trans.GetObject(id, OpenMode.ForWrite, false, true);
                    switchCorridor.Description = switchList;
                    trans.Commit();
                }
            }

            var corridor = ctx.GetTransaction().GetObject(id, OpenMode.ForRead, false, true) as Corridor;
            return(corridor != null ? new CivilCorridor(corridor, true) : null);
        }
    }
        public static List <HorizontalGeometryPointLabel> GetProfileLabels(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <HorizontalGeometryPointLabel> retLabels = new List <HorizontalGeometryPointLabel>();

            foreach (DBObject dbObj in GetLabelStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.LabelStyles.ProfileLabelStyles.HorizontalGeometryPointLabelStyles))
            {
                HorizontalGeometryPointLabel labelObject = new HorizontalGeometryPointLabel(dbObj, false);
                retLabels.Add(labelObject);
            }
            return(retLabels);
        }
Ejemplo n.º 8
0
        public static List <SectionViewTotalVolumeTable> GetSectionViewTotalVolumeTables(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <SectionViewTotalVolumeTable> retList = new List <SectionViewTotalVolumeTable>();

            foreach (DBObject dbOb in GetStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.TableStyles.SectionViewTotalVolumeTableStyles))
            {
                SectionViewTotalVolumeTable style = new SectionViewTotalVolumeTable(dbOb, false);
                retList.Add(style);
            }
            return(retList);
        }
        public static List <ViewFrameLabel> GetViewFrameLabels(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <ViewFrameLabel> retLabels = new List <ViewFrameLabel>();

            foreach (DBObject dbObj in GetLabelStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.LabelStyles.ViewFrameLabelStyles.LabelStyles))
            {
                ViewFrameLabel labelObject = new ViewFrameLabel(dbObj, false);
                retLabels.Add(labelObject);
            }
            return(retLabels);
        }
Ejemplo n.º 10
0
        public static List <SurfaceUserDefinedContourTable> GetSurfaceUserDefinedContourTables(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <SurfaceUserDefinedContourTable> retList = new List <SurfaceUserDefinedContourTable>();

            foreach (DBObject dbOb in GetStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.TableStyles.SurfaceUserDefinedContourTableStyles))
            {
                SurfaceUserDefinedContourTable style = new SurfaceUserDefinedContourTable(dbOb, false);
                retList.Add(style);
            }
            return(retList);
        }
        public static List <PVStationElevationLabel> GetProfileViewElevationLabels(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <PVStationElevationLabel> retLabels = new List <PVStationElevationLabel>();

            foreach (DBObject dbObj in GetLabelStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.LabelStyles.ProfileViewLabelStyles.StationElevationLabelStyles))
            {
                PVStationElevationLabel labelObject = new PVStationElevationLabel(dbObj, false);
                retLabels.Add(labelObject);
            }
            return(retLabels);
        }
        public static List <QTOMaterialTable> GetQTOMaterialTables(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <QTOMaterialTable> retList = new List <QTOMaterialTable>();

            foreach (DBObject dbOb in GetStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.TableStyles.QuantityTakeoffMaterialTableStyles))
            {
                QTOMaterialTable style = new QTOMaterialTable(dbOb, false);
                retList.Add(style);
            }
            return(retList);
        }
        public static List <CivilDynamoTools.LabelStyles.Alignments.TangentIntersectionLabel> GetTangentIntersectionLabels(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <CivilDynamoTools.LabelStyles.Alignments.TangentIntersectionLabel> retLabels = new List <CivilDynamoTools.LabelStyles.Alignments.TangentIntersectionLabel>();

            foreach (DBObject dbObj in GetLabelStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.LabelStyles.AlignmentLabelStyles.TangentIntersectionLabelStyles))
            {
                TangentIntersectionLabel labelObject = new TangentIntersectionLabel(dbObj, false);
                retLabels.Add(labelObject);
            }
            return(retLabels);
        }
Ejemplo n.º 14
0
        public static List <ParcelAreaTable> GetParcelAreaTables(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <ParcelAreaTable> retList = new List <ParcelAreaTable>();

            foreach (DBObject dbOb in GetStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.TableStyles.ParcelAreaTableStyles))
            {
                ParcelAreaTable style = new ParcelAreaTable(dbOb, false);
                retList.Add(style);
            }
            return(retList);
        }
Ejemplo n.º 15
0
        public static List <SurveyFigureLineLabel> GetSurveyFigureLineLabels(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <SurveyFigureLineLabel> retLabels = new List <SurveyFigureLineLabel>();

            foreach (DBObject dbObj in GetLabelStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.LabelStyles.GetSurveyLabelStyles().LineLabelStyles))
            {
                SurveyFigureLineLabel labelObject = new SurveyFigureLineLabel(dbObj, false);
                retLabels.Add(labelObject);
            }
            return(retLabels);
        }
        public static List <CivilDynamoTools.LabelStyles.Alignments.Station.SuperelevationCriticalPointsLabel> GetSuperelevationCriticalPointsLabels(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <CivilDynamoTools.LabelStyles.Alignments.Station.SuperelevationCriticalPointsLabel> retLabels = new List <CivilDynamoTools.LabelStyles.Alignments.Station.SuperelevationCriticalPointsLabel>();

            foreach (DBObject dbObj in GetLabelStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.LabelStyles.AlignmentLabelStyles.SuperelevationCriticalPointsLabelStyles))
            {
                SuperelevationCriticalPointsLabel labelObject = new SuperelevationCriticalPointsLabel(dbObj, false);
                retLabels.Add(labelObject);
            }
            return(retLabels);
        }
Ejemplo n.º 17
0
        public static List <SectionGradeBreakLabel> GetSectionGradeBreakLabels(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <SectionGradeBreakLabel> retLabels = new List <SectionGradeBreakLabel>();

            foreach (DBObject dbObj in GetLabelStylesAsDBObjects(document, CivilDocument.GetCivilDocument(document.AcDocument.Database).Styles.LabelStyles.SectionLabelStyles.GradeBreakLabelStyles))
            {
                SectionGradeBreakLabel labelObject = new SectionGradeBreakLabel(dbObj, false);
                retLabels.Add(labelObject);
            }
            return(retLabels);
        }
Ejemplo n.º 18
0
        public static ProfileViewBandSet ByName(Autodesk.AutoCAD.DynamoNodes.Document document, string labelStyleName)
        {
            ProfileViewBandSet retLabel;
            Database           db = document.AcDocument.Database;
            ProfileViewBandSetStyleCollection bandRoot = CivilDocument.GetCivilDocument(db).Styles.ProfileViewBandSetStyles;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                retLabel = new ProfileViewBandSet(trans.GetObject(bandRoot[labelStyleName], OpenMode.ForRead), false);
                trans.Commit();
            }
            return(retLabel);
        }
Ejemplo n.º 19
0
        public static SectionLabelSet ByName(Autodesk.AutoCAD.DynamoNodes.Document document, string labelStyleName)
        {
            SectionLabelSet                retLabel;
            Database                       db        = document.AcDocument.Database;
            LabelSetStylesRoot             root      = CivilDocument.GetCivilDocument(db).Styles.LabelSetStyles;
            SectionLabelSetStyleCollection alignRoot = root.SectionLabelSetStyles;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                retLabel = new SectionLabelSet(trans.GetObject(alignRoot[labelStyleName], OpenMode.ForRead), false);
                trans.Commit();
            }
            return(retLabel);
        }
        public static AlignmentLabelSet ByIndex(Autodesk.AutoCAD.DynamoNodes.Document document, int index)
        {
            AlignmentLabelSet  retLabel;
            Database           db   = document.AcDocument.Database;
            LabelSetStylesRoot root = CivilDocument.GetCivilDocument(db).Styles.LabelSetStyles;
            AlignmentLabelSetStyleCollection alignRoot = root.AlignmentLabelSetStyles;

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                retLabel = new AlignmentLabelSet(trans.GetObject(alignRoot[index], OpenMode.ForRead), false);
                trans.Commit();
            }
            return(retLabel);
        }
Ejemplo n.º 21
0
        //public void SetSurfaceBuildOptions()
        //{
        //    CrossingBreaklinesElevationType crossing = CrossingBreaklinesElevationType.UseNone;

        //}

        public void SetCrossingPolylinesSetting()
        {
            try
            {
                using (var doc = CivilDocument.GetCivilDocument(CivilApplicationManager.WorkingDatabase))
                {
                    //var options =
                    //    doc.Settings.GetSettings<C3DLandDb.SurfaceBuildOptions>();
                }
            }

            catch (Exception ex)
            {
                MessengerManager.MessengerManager.LogException(ex);
            }
        }
Ejemplo n.º 22
0
        public static List <CivilDynamoTools.LabelStyles.ProfileViews.ProfileViewBandSet> GetProfileViewBandSets(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <CivilDynamoTools.LabelStyles.ProfileViews.ProfileViewBandSet> alignmentLabels = new List <CivilDynamoTools.LabelStyles.ProfileViews.ProfileViewBandSet>();
            Database db = document.AcDocument.Database;
            ProfileViewBandSetStyleCollection bandRoot = CivilDocument.GetCivilDocument(db).Styles.ProfileViewBandSetStyles;

            foreach (ObjectId setStyle in bandRoot)
            {
                using (Transaction trans = db.TransactionManager.StartTransaction())
                {
                    ProfileViewBandSet labelSet = new ProfileViewBandSet(trans.GetObject(setStyle, OpenMode.ForRead), false);
                    alignmentLabels.Add(labelSet);
                    trans.Commit();
                }
            }
            return(alignmentLabels);
        }
Ejemplo n.º 23
0
 public void HideAmbientSettingsShowEvntVwer()
 {
     try
     {
         using (Application.DocumentManager.MdiActiveDocument.LockDocument())
         {
             using (var doc = CivilDocument.GetCivilDocument(CivilApplicationManager.WorkingDatabase))
             {
                 var ambientSettings = doc.Settings.DrawingSettings.AmbientSettings;
                 ambientSettings.General.ShowEventViewer.Value = false;
             }
         }
     }
     catch (Exception ex)
     {
     }
 }
Ejemplo n.º 24
0
        public static List <Surface> GetSurfaces(Autodesk.AutoCAD.DynamoNodes.Document document)
        {
            List <Surface> surfaces = new List <Surface>();

            Autodesk.AutoCAD.ApplicationServices.Document acDoc = document.AcDocument;
            Database           db            = acDoc.Database;
            CivilDocument      civilDocument = CivilDocument.GetCivilDocument(db);
            ObjectIdCollection surfaceIds    = civilDocument.GetSurfaceIds();

            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                foreach (ObjectId surfaceId in surfaceIds)
                {
                    surfaces.Add(new Surface((Autodesk.Civil.DatabaseServices.Entity)trans.GetObject(surfaceId, OpenMode.ForRead), false));
                }
            }
            return(surfaces);
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Get an alignments in the drawing by name
        /// </summary>
        /// <param name="document">Document</param>
        /// <param name="alignmentName">The name of an alignment</param>
        /// <returns></returns>
        public static Alignment GetAlignmentByName(Document document, string alignmentName)
        {
            if (document is null)
            {
                throw new ArgumentNullException("document is null!");
            }
            if (alignmentName is null)
            {
                throw new ArgumentNullException("alignmentName is null!");
            }

            using (var context = new DocumentContext(document.AcDocument))
            {
                CivilDocument cdoc = CivilDocument
                                     .GetCivilDocument(context.Database);

                Transaction tr = context.Transaction;

                ObjectIdCollection alignIds = cdoc.GetAlignmentIds();

                foreach (ObjectId alignId in alignIds)
                {
                    if (!alignId.IsValid ||
                        alignId.IsErased ||
                        alignId.IsEffectivelyErased)
                    {
                        continue;
                    }

                    if (tr.GetObject(alignId, OpenMode.ForRead, false, true)
                        is C3dDb.Alignment align)
                    {
                        if (align.Name.Equals(alignmentName, StringComparison.OrdinalIgnoreCase))
                        {
                            return(new Alignment(align));
                        }
                    }
                }
            }

            return(null);
        }
Ejemplo n.º 26
0
        /// <summary>
        /// Get all networks in the drawing
        /// </summary>
        /// <param name="document">Document</param>
        /// <param name="allowReference">Add referenced networks to result</param>
        /// <returns></returns>
        public static IList <Network> GetNetworks(Document document, bool allowReference)
        {
            if (document is null)
            {
                throw new ArgumentNullException("document is null!");
            }

            IList <Network> nets = new List <Network>();

            using (var context = new DocumentContext(document.AcDocument))
            {
                CivilDocument cdoc = CivilDocument
                                     .GetCivilDocument(context.Database);

                Transaction tr = context.Transaction;

                using (ObjectIdCollection netIds = cdoc.GetPipeNetworkIds())
                {
                    foreach (ObjectId netId in netIds)
                    {
                        if (!netId.IsValid ||
                            netId.IsErased ||
                            netId.IsEffectivelyErased)
                        {
                            continue;
                        }

                        if (tr.GetObject(netId, OpenMode.ForRead, false, true)
                            is C3dDb.Network net)
                        {
                            if (allowReference ||
                                (!net.IsReferenceObject && !net.IsReferenceSubObject))
                            {
                                nets.Add(new Network(net));
                            }
                        }
                    }
                }
            }

            return(nets);
        }
Ejemplo n.º 27
0
    /// <summary>
    /// Get the ObjectId for the given label set style name
    /// </summary>
    public static ObjectId GetLabelSetStyleId(Document document, string type, string styleName)
    {
        if (document == null)
        {
            return(ObjectId.Null);
        }
        if (string.IsNullOrEmpty(type))
        {
            return(ObjectId.Null);
        }
        if (string.IsNullOrEmpty(styleName))
        {
            return(ObjectId.Null);
        }

        var db  = document.AcDocument.Database;
        var doc = CivilDocument.GetCivilDocument(db);

        if (type == "AlignmentLabel")
        {
            if (doc.Styles.LabelSetStyles.AlignmentLabelSetStyles.Contains(styleName))
            {
                return(doc.Styles.LabelSetStyles.AlignmentLabelSetStyles[styleName]);
            }
        }
        else if (type == "ProfileLabel")
        {
            if (doc.Styles.LabelSetStyles.ProfileLabelSetStyles.Contains(styleName))
            {
                return(doc.Styles.LabelSetStyles.ProfileLabelSetStyles[styleName]);
            }
        }
        else if (type == "SectionLabel")
        {
            if (doc.Styles.LabelSetStyles.SectionLabelSetStyles.Contains(styleName))
            {
                return(doc.Styles.LabelSetStyles.SectionLabelSetStyles[styleName]);
            }
        }

        return(ObjectId.Null);
    }
Ejemplo n.º 28
0
 /// <exclude />
 public bool AddStandardBoundary(ObjectId polyId, string name, ObjectId surfaceId)
 {
     try
     {
         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();
             FeatureLineIssues.AddStandardBoundary(polyId, name, surface);
             tr.Commit();
         }
         return(true);
     }
     catch (Exception ex)
     {
     }
     return(false);
 }
Ejemplo n.º 29
0
        /// <summary>
        /// Gets the names of all alignments in the drawing
        /// </summary>
        /// <param name="document">Drawing document</param>
        /// <param name="allowReference">Include the referenced alignment to the result</param>
        /// <returns>List of alignments names</returns>
        public static IList <string> GetAllAlignmentNames(Document document, bool allowReference)
        {
            if (document is null)
            {
                throw new ArgumentNullException("document is null!");
            }

            IList <string> alignNames = new List <string>();

            using (var context = new DocumentContext(document.AcDocument))
            {
                CivilDocument cdoc = CivilDocument
                                     .GetCivilDocument(context.Database);

                Transaction tr = context.Transaction;

                ObjectIdCollection alignIds = cdoc.GetAlignmentIds();

                foreach (ObjectId alignId in alignIds)
                {
                    if (!alignId.IsValid ||
                        alignId.IsErased ||
                        alignId.IsEffectivelyErased)
                    {
                        continue;
                    }

                    if (tr.GetObject(alignId, OpenMode.ForRead, false, true)
                        is C3dDb.Alignment align)
                    {
                        if (allowReference ||
                            (!align.IsReferenceObject && !align.IsReferenceSubObject))
                        {
                            alignNames.Add(align.Name);
                        }
                    }
                }
            }

            return(alignNames);
        }
Ejemplo n.º 30
0
    /// <summary>
    /// Get the ObjectId for the given profile style name
    /// </summary>
    public static ObjectId GetProfileStyleId(Document document, string styleName)
    {
        if (document == null)
        {
            return(ObjectId.Null);
        }
        if (string.IsNullOrEmpty(styleName))
        {
            return(ObjectId.Null);
        }

        var db  = document.AcDocument.Database;
        var doc = CivilDocument.GetCivilDocument(db);

        var styleId = ObjectId.Null;

        if (doc.Styles.ProfileStyles.Contains(styleName))
        {
            styleId = doc.Styles.ProfileStyles[styleName];
        }

        return(styleId);
    }