Ejemplo n.º 1
0
Archivo: Sect.cs Proyecto: 15831944/EM
 addSections(this ObjectId idAlign, ObjectId idSLG, double offLeft, double offRight)
 {
     try
     {
         using (Transaction tr = BaseObjs.startTransactionDb())
         {
             SampleLineGroup group = (SampleLineGroup)tr.GetObject(idSLG, OpenMode.ForWrite);
             foreach (ObjectId id in group.GetSampleLineIds())
             {
                 SampleLine SL = (SampleLine)tr.GetObject(id, OpenMode.ForRead);
                 foreach (ObjectId idSection in SL.GetSectionIds())
                 {
                     Section section = (Section)tr.GetObject(idSection, OpenMode.ForWrite);
                     section.UpdateMode      = SectionUpdateType.Dynamic;
                     section.LeftSwathWidth  = offLeft;
                     section.RightSwathWidth = offRight;
                     section.StyleName       = section.Name;
                     section.Layer           = string.Format("{0}-SURFACE-SEC", section.Name);
                 }
             }
             tr.Commit();
         }
     }
     catch (System.Exception ex)
     {
         BaseObjs.writeDebug(string.Format("{0} Sect.cs: line: 50", ex.Message));
     }
 }
        public SampleLine GetSampleLine()
        {
            PromptEntityOptions peo = new PromptEntityOptions("\nSelect the SampleLine");

            peo.SetRejectMessage("\nOnly SampleLine");
            peo.AddAllowedClass(typeof(SampleLine), true);
            PromptEntityResult res = Ed.GetEntity(peo);

            if (res.Status != PromptStatus.OK)
            {
                return(null);
            }
            using (Transaction ts = Dwg.TransactionManager.StartTransaction())
            {
                try
                {
                    SampleLine smpLine = ts.GetObject(res.ObjectId, OpenMode.ForRead) as SampleLine;
                    return(smpLine);
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 3
0
Archivo: Sect.cs Proyecto: 15831944/EM
        addSampleLineGroupAndSampleLines(this ObjectId idAlign, string name)
        {
            ObjectId idSLG = ObjectId.Null;

            try
            {
                using (Transaction tr = BaseObjs.startTransactionDb())
                {
                    Alignment align = (Alignment)tr.GetObject(idAlign, OpenMode.ForWrite);
                    idSLG = SampleLineGroup.Create(name, idAlign);
                    SampleLineGroup group = (SampleLineGroup)tr.GetObject(idSLG, OpenMode.ForWrite);

                    Station[] stations = align.GetStationSet(StationTypes.All);
                    foreach (Station station in stations)
                    {
                        ObjectId   idSL = SampleLine.Create(string.Format("SL{0}", station.RawStation), idSLG, station.RawStation);
                        SampleLine SL   = (SampleLine)tr.GetObject(idSL, OpenMode.ForWrite);
                        SL.StyleName = name;
                    }
                    tr.Commit();
                }
            }
            catch (System.Exception ex)
            {
                BaseObjs.writeDebug(string.Format("{0} Sect.cs: line: 30", ex.Message));
            }
            return(idSLG);
        }
        public void Point2Sec()
        {
            SampleLine smpLine = GetSampleLine();
            SampleLineVertexCollection smpVertices = smpLine.Vertices;
            List <Point3d>             pntList     = new List <Point3d>();

            Autodesk.AutoCAD.DatabaseServices.Polyline pl = new Autodesk.AutoCAD.DatabaseServices.Polyline();
            foreach (SampleLineVertex item in smpVertices)
            {
                pntList.Add(item.Location);
            }
            Line l = new Line(pntList[0], pntList[2]);
            ObjectIdCollection sectionViewID = smpLine.GetSectionViewIds();
            Boolean            loopControl   = true;

            while (loopControl)
            {
                using (Transaction ts = Dwg.TransactionManager.StartTransaction())
                {
                    try
                    {
                        PromptPointResult pnt = Ed.GetPoint("\nSelect the point");
                        if (pnt.Status == PromptStatus.Cancel)
                        {
                            return;
                        }
                        Point3d     pntOnSampleLine = l.GetClosestPointTo(pnt.Value, false);
                        Double      dist            = Math.Sqrt(Math.Pow((pntList[0].X - pntOnSampleLine.X), 2) + Math.Pow(pntList[0].Y - pntOnSampleLine.Y, 2));
                        SectionView sectionView     = ts.GetObject(sectionViewID[0], OpenMode.ForRead) as SectionView;
                        Point3d     pntOnSec        = sectionView.Location;
                        Double      left            = sectionView.OffsetLeft;
                        Point3d     startPoint      = new Point3d(sectionView.Location.X + left, sectionView.Location.Y, sectionView.Location.Z);
                        Point3d     targetPoint     = new Point3d(startPoint.X + dist, startPoint.Y, startPoint.Z);
                        Point3d     targetPoint2    = new Point3d(targetPoint.X, targetPoint.Y - 5, targetPoint.Z);
                        Xline       xl = new Xline();
                        xl.BasePoint   = targetPoint;
                        xl.SecondPoint = targetPoint2;
                        AppendEntity(Db.BlockTableId, xl);
                        ts.Commit();
                    }
                    catch (System.Exception)
                    {
                        throw;
                    }
                }
            }
        }
        public void SampleLines()
        {
            Alignment          algn   = GetAlignment();
            ObjectIdCollection slgIds = algn.GetSampleLineGroupIds();

            using (Transaction ts = Dwg.TransactionManager.StartTransaction())
            {
                try
                {
                    // sample line groups
                    foreach (ObjectId item in slgIds)
                    {
                        SampleLineGroup slg = ts.GetObject(item, OpenMode.ForRead) as SampleLineGroup;

                        //sample lines
                        ObjectIdCollection smpLinesIds = slg.GetSampleLineIds();
                        foreach (ObjectId smpLineId in smpLinesIds)
                        {
                            SampleLine sl = ts.GetObject(smpLineId, OpenMode.ForRead) as SampleLine;
                            // her bir sampleline da örneklenmiş sectionlar döndürülür.
                            ObjectIdCollection sectionIds = sl.GetSectionIds();

                            foreach (ObjectId sectionId in sectionIds)
                            {
                                Autodesk.Civil.DatabaseServices.Section sction = ts.GetObject(sectionId, OpenMode.ForRead) as
                                                                                 Autodesk.Civil.DatabaseServices.Section;
                            }
                        }
                    }
                }
                catch (System.Exception)
                {
                    throw;
                }
            }
        }
Ejemplo n.º 6
0
        cmdSections(ObjectId idAlign, double dblOffR, double dblOffL)
        {
            ObjectId idSectionStyleEXIST   = default(ObjectId);
            ObjectId idSectionStyleEXIST90 = default(ObjectId);
            ObjectId idSectionStyleCPNT    = default(ObjectId);
            ObjectId idSectionStyleSG      = default(ObjectId);
            ObjectId idSectionStyleOX      = default(ObjectId);
            ObjectId idSectionStyleOXg     = default(ObjectId);
            ObjectId idSectionStyleBOT     = default(ObjectId);
            ObjectId idSectionStyleMID     = default(ObjectId);

            ObjectIdCollection idsSurface = new ObjectIdCollection();

            bool     exists         = false;
            ObjectId idSurfaceEXIST = Surf.getSurface("EXIST", out exists);

            if (!exists)
            {
                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Surface EXIST is missing - exiting!");
                return;
            }
            else
            {
                idsSurface.Add(idSurfaceEXIST);
                idSectionStyleEXIST = Sect_Style.getSectionStyleId("EXIST");
            }

            ObjectId idSurfaceEXIST90 = Surf.getSurface("EXIST90", out exists);

            if (!exists)
            {
                //  MsgBox "Surface EXIST is missing - exiting!"
                //  Exit Sub
            }
            else
            {
                idsSurface.Add(idSurfaceEXIST90);
                idSectionStyleEXIST90 = Sect_Style.getSectionStyleId("EXIST90");
            }

            ObjectId idSurfaceCPNT = Surf.getSurface("CPNT-ON", out exists);

            if (!exists)
            {
                //  MsgBox "Surface CPNT-ON is missing - exiting!"
                //  Exit Sub
            }
            else
            {
                idsSurface.Add(idSurfaceCPNT);
                idSectionStyleCPNT = Sect_Style.getSectionStyleId("CPNT");
            }

            ObjectId idSurfaceSG = Surf.getSurface("SG", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceSG);
                idSectionStyleSG = Sect_Style.getSectionStyleId("SG");
            }

            ObjectId idSurfaceOX = Surf.getSurface("OX", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceOX);
                idSectionStyleOX = Sect_Style.getSectionStyleId("OX");
            }

            ObjectId idSurfaceOXg = Surf.getSurface("OXg", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceOXg);
                idSectionStyleOXg = Sect_Style.getSectionStyleId("OXg");
            }

            ObjectId idSurfaceBOT = Surf.getSurface("BOT", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceBOT);
                idSectionStyleBOT = Sect_Style.getSectionStyleId("BOT");
            }

            if (idSectionStyleBOT == ObjectId.Null)
            {
                EW_Utility1.copyEWstyles();
            }

            ObjectId idSurfaceMID = Surf.getSurface("MIDGRADE", out exists);

            if (!exists)
            {
            }
            else
            {
                idsSurface.Add(idSurfaceMID);
                idSectionStyleMID = Sect_Style.getSectionStyleId("EXIST90");
            }

            idAlign.removeSampleLineGroups();
            ObjectId idSLG = idAlign.addSampleLineGroupAndSampleLines("EW");

            idSLG.removeSampledSurfaces();

            idSLG.addSurfaceToSample(idsSurface);

            idAlign.addSections(idSLG, dblOffL, dblOffR);

            ObjectId idGroupPlotStyle             = ObjectId.Null;
            GroupPlotStyleCollection grpPltStyles = BaseObjs._civDoc.Styles.GroupPlotStyles;

            if (!grpPltStyles.Contains("EW"))
            {
                EW_Utility1.copyEWstyles();
                idGroupPlotStyle = BaseObjs._civDoc.Styles.GroupPlotStyles["EW"];
            }

            SampleLineStyleCollection sampleLineStyles = BaseObjs._civDoc.Styles.SampleLineStyles;
            ObjectId idSampleLineStyle = sampleLineStyles["Standard"];

            SectionLabelSetStyleCollection sectionLabelSetStyles = BaseObjs._civDoc.Styles.LabelSetStyles.SectionLabelSetStyles;

            double dblWidth  = 0;
            double dblHeight = 0;

            Autodesk.AutoCAD.DatabaseServices.Table objTable = default(Autodesk.AutoCAD.DatabaseServices.Table);

            SelectionSet objSSet = default(SelectionSet);

            objSSet  = EW_Utility1.buildSSetTable();
            objTable = (Autodesk.AutoCAD.DatabaseServices.Table)objSSet.GetObjectIds()[0].getEnt();

            Point3d varPntIns = objTable.Position;

            dblWidth  = objTable.Width;
            dblHeight = objTable.Height;

            Point3d dblPntBase = new Point3d(varPntIns.X + dblWidth + 600, varPntIns.Y - dblHeight, 0);

            SectionViewStyle objSectionViewStyle = Sect_Style.getSectionViewStyle("EW");

            if (objSectionViewStyle == null)
            {
                EW_Utility1.copyEWstyles();
                objSectionViewStyle = objSectionViewStyle = Sect_Style.getSectionViewStyle("EW");
            }

            SectionViewBandSetStyle objSectionViewBandSetStyle = Sect_Style.getSectionViewBandSetStyle("Standard");

            double dblOffX = 0;
            double dblOffY = 0;

            bool boolFirstPass = false;

            boolFirstPass = true;

            dblOffX = 0;
            dblOffY = 0;

            Point3d dblPntIns = Pub.pnt3dO;

            int j = 0;
            ObjectIdCollection idsSampleLine = idSLG.getSampleLineIDs();

            using (var tr = BaseObjs.startTransactionDb()) {
                for (int i = 0; i < idsSampleLine.Count; i += 5)
                {
                    SampleLine sl = (SampleLine)tr.GetObject(idsSampleLine[i], OpenMode.ForRead);

                    dblPntIns = new Point3d(dblPntBase.X + i / 5 * dblOffX, dblPntBase.Y, 0);
                    int k = -1;

                    while (j < idsSampleLine.Count)
                    {
                        k = k + 1;

                        ObjectId    idSectionView  = SectionView.Create(string.Format("SV-{0}", j), sl.ObjectId, dblPntIns);
                        SectionView objSectionView = (SectionView)tr.GetObject(idSectionView, OpenMode.ForWrite);
                        if (boolFirstPass)
                        {
                            dblOffX       = System.Math.Abs(objSectionView.OffsetLeft) + objSectionView.OffsetRight + 30;
                            boolFirstPass = false;
                        }

                        Extents3d ext3d = (Extents3d)objSectionView.Bounds;

                        dblOffY = ext3d.MaxPoint.Y - ext3d.MinPoint.Y + 30;

                        dblPntIns      = new Point3d(dblPntIns.X, dblPntIns.Y + dblOffY, 0);//increment Y after placing first section in column
                        objSectionView = null;

                        j = j + 1;

                        if (k == 4)
                        {
                            break;
                        }
                    }
                }

                tr.Commit();
            }

            BaseObjs.acadActivate();

            return;
        }
Ejemplo n.º 7
0
        drawSections()
        {
            Alignment objAlign = default(Alignment);

            try {
                objAlign = fWall1.ACTIVEALIGN;

                if ((objAlign == null))
                {
                    MessageBox.Show("Select Alignment");
                    return;
                }
            }
            catch (System.Exception) {
                MessageBox.Show("Select Alignment");
                return;
            }
            bool exists = false;

            TinSurface objSurfaceEXIST = Surf.getTinSurface("EXIST", out exists);
            TinSurface objSurfaceCPNT  = Surf.getTinSurface("CPNT-ON", out exists);

            //ObjectId objSectionStyleEXISTId = Sect.getSectionStyleId("EXIST");
            //ObjectId objSectionStyleCPNTId = Sect.getSectionStyleId("CPNT");
            //GroupPlotStyle objGroupPlotStyle = Sect.getGroupPlotStyle("WALL");
            //SampleLineStyle objSampleLineStyle = Sect.getSampleLineStyle("Standard");
            //SectionLabelSetStyle objSampleLabelSetStyle = Sect.getSampleLineLabelStyle("Standard");

            double dblLen = objAlign.Length;

            Sect.removeSampleLineGroups(objAlign.ObjectId);

            string strLayer = string.Format("{0}-SEC", objAlign.Name);

            Layer.manageLayers(strLayer);

            ObjectId idSLG = Sect.addSampleLineGroupAndSampleLines(objAlign.ObjectId, "SLG-1");

            idSLG.removeSampledSurfaces();

            ObjectIdCollection idSurfaces = new ObjectIdCollection();

            idSurfaces.Add(objSurfaceCPNT.ObjectId);
            idSurfaces.Add(objSurfaceEXIST.ObjectId);

            idSLG.addSurfaceToSample(idSurfaces);

            Sect.addSections(objAlign.ObjectId, idSLG, 20.0, 20.0);

            SampleLine objSampleLine = default(SampleLine);

            Autodesk.Civil.DatabaseServices.Section objSection = default(Autodesk.Civil.DatabaseServices.Section);

            ObjectIdCollection idsSampleLine = idSLG.getSampleLineIDs();

            using (var tr = BaseObjs.startTransactionDb()) {
                foreach (ObjectId idSampleLine in idsSampleLine)
                {
                    objSampleLine = (SampleLine)tr.GetObject(idSampleLine, OpenMode.ForRead);
                    foreach (ObjectId idSection in objSampleLine.GetSectionIds())
                    {
                        objSection       = (Section)tr.GetObject(idSection, OpenMode.ForWrite);
                        objSection.Layer = strLayer;
                    }
                }
                tr.Commit();
            }

            Autodesk.Civil.DatabaseServices.Styles.SectionViewStyle objSectionViewStyle = default(Autodesk.Civil.DatabaseServices.Styles.SectionViewStyle);

            try {
                objSectionViewStyle = Sect_Style.getSectionViewStyle("WALL");
            }
            catch (System.Exception) {
                objSectionViewStyle = Sect_Style.getSectionViewStyle("Standard");
            }

            SectionViewBandSetStyle objSectionViewBandStyleSet = Sect_Style.getSectionViewBandSetStyle("Standard");

            double dblOffX = 0;
            double dblOffY = 0;

            bool boolFirstPass = true;

            //Dim objStationRange As New StationRange
            //With objStationRange
            //    .UseSampleIncrements = True
            //    .SampleAtHighLowPoints = False
            //    .SampleAtHorizontalGeometryPoints = False
            //    .SampleAtSuperelevationCriticalStations = False
            //    .SampleAtRangeEnd = True
            //    .SampleAtRangeStart = True
            //    .StartRangeAtAlignmentStart = True
            //    .EndRangeAtAlignmentEnd = True
            //    .StartRange = 0.0
            //    .EndRange = dblLen - 1
            //    .IncrementTangent = 50.0
            //    .SwathWidthLeft = 20.0
            //    .SwathWidthRight = 20.0
            //    .SampleLineDefaultDirection = DirectionFromType.DirectionFromBaseAlignment
            //End With

            //objStationRange.SampleLineStyle = objSampleLineStyle

            //objSLG.SampleLines.AddByStationRange("SL-1", SampleLineDuplicateActionType.SampleLineDuplicateActionOverwrite, objStationRange)

            PromptStatus ps        = default(PromptStatus);
            Point3d      pnt3dBase = default(Point3d);

            try {
                BaseObjs.acadActivate();
                pnt3dBase = UserInput.getPoint("Select Insertion Point for Sections", out ps, osMode: 0);
            }
            catch (System.Exception) {
                return;
            }

            SectionView objSectionView = null;
            Point3d     pnt3dIns       = default(Point3d);

            using (var tr1 = BaseObjs.startTransactionDb()) {
                int j = 0;
                for (int i = 0; i < idsSampleLine.Count; i += 5)
                {
                    objSampleLine = (SampleLine)tr1.GetObject(idsSampleLine[i], OpenMode.ForRead);

                    //dblPntIns(0) = pnt3dBase.X + i / 5 * dblOffX

                    int k = -1;

                    while (j < idsSampleLine.Count)
                    {
                        k++;

                        pnt3dIns = new Point3d(pnt3dBase.X + i / 5 * dblOffX, pnt3dBase.Y + k * dblOffY, 0.0);

                        try {
                            ObjectId idSectionView = SectionView.Create("SV" + Convert.ToString(j), idsSampleLine[i], pnt3dIns);
                            objSectionView             = (SectionView)tr1.GetObject(idSectionView, OpenMode.ForWrite);
                            objSectionView.OffsetLeft  = 20.0;
                            objSectionView.OffsetRight = 20.0;
                            objSectionView.StyleId     = objSectionViewStyle.ObjectId;
                        }
                        catch (Autodesk.AutoCAD.Runtime.Exception) {
                        }

                        if (boolFirstPass)
                        {
                            dblOffX       = System.Math.Abs(objSectionView.OffsetLeft) + objSectionView.OffsetRight + 30;
                            dblOffY       = (objSectionView.ElevationMax - objSectionView.ElevationMin) + 20;
                            boolFirstPass = false;
                        }

                        j++;

                        if (k == 4)
                        {
                            break;
                        }
                    }
                }

                tr1.Commit();
            }
        }
Ejemplo n.º 8
0
        public static void MillingDepthToProfileView()
        {
            CivilDocument civilDoc = CivilApplication.ActiveDocument;
            Editor        ed       = Application.DocumentManager.MdiActiveDocument.Editor;

            List <string> resultForFile = new List <string>();

            using (Transaction ts = Application.DocumentManager.MdiActiveDocument.
                                    Database.TransactionManager.StartTransaction())
            {
                // dterminate location of section view profiles
                // ask user to select Alignment
                PromptEntityOptions opt = new PromptEntityOptions("\nSelect an Alignment");
                opt.SetRejectMessage("\nObject must be an alignment.\n");
                opt.AddAllowedClass(typeof(Alignment), false);
                ObjectId alignID = ed.GetEntity(opt).ObjectId;

                try
                {
                    Alignment          myAlignment            = ts.GetObject(alignID, OpenMode.ForRead) as Alignment;
                    ObjectIdCollection sampleLineIdCollection = myAlignment.GetSampleLineGroupIds();
                    SampleLineGroup    sampleLineGroup        = sampleLineIdCollection[0].GetObject(OpenMode.ForRead) as SampleLineGroup; //if you have problem chech here

                    foreach (ObjectId sampleLineId in sampleLineGroup.GetSampleLineIds())
                    {
                        SampleLine sampleLine = ts.GetObject(sampleLineId, OpenMode.ForRead) as SampleLine;

                        foreach (ObjectId sectionId in sampleLine.GetSectionIds())
                        {
                            Section section = ts.GetObject(sectionId, OpenMode.ForWrite) as Section;
                            ed.WriteMessage("Section {0} elevation max: {1} min: {2}\n", section.Name, section.MaximumElevation, section.MinmumElevation);
                            // set the section update mode:
                            //section.UpdateMode = SectionUpdateType.Dynamic;
                        }
                    }

                    SectionViewGroupCollection sectionViewGrouopColection = sampleLineGroup.SectionViewGroups;

                    int sectionViewNumber = 0;
                    try
                    {
                        string askString = String.Format("\nEnter number of ACTIVE SectionViewGroup (1-{0}): ", sectionViewGrouopColection.Count);
                        sectionViewNumber = Convert.ToInt32(GetStringFromUser(ed, askString));
                        if (sectionViewNumber < 1 || sectionViewNumber > sectionViewGrouopColection.Count)
                        {
                            throw new ArgumentOutOfRangeException("Value is out of range!");
                        }
                    }
                    catch (System.Exception)
                    {
                        ed.WriteMessage("Please enter valid value!");
                        return;
                    }
                    SectionViewGroup   theSectionViewGroup    = sectionViewGrouopColection[sectionViewNumber - 1];
                    ObjectIdCollection sectionViewIdColection = theSectionViewGroup.GetSectionViewIds();

                    // create milling Elements
                    MillingDataEngine.DataStruct.RoadSection theRoadSection = MillingDataEngine.Func.ExcelDataRead.RoadSectionElementsBuilder(MillingDataEngine.Func.ExcelDataRead.ReadData());

                    foreach (ObjectId sectionViewId in sectionViewIdColection)
                    {
                        SectionView theSectionView = ts.GetObject(sectionViewId, OpenMode.ForWrite) as SectionView;

                        theSectionView.IsElevationRangeAutomatic = false;
                        string minRangeElevation = theSectionView.ElevationMin.ToString();
                        theSectionView.IsElevationRangeAutomatic = true;

                        MillingDataEngine.DataStruct.ThreeDPoint theLocation = new MillingDataEngine.DataStruct.ThreeDPoint(theSectionView.Location.X, theSectionView.Location.Y, Convert.ToInt32(theSectionView.Location.Z));
                        double baseElevation = Convert.ToDouble(minRangeElevation);

                        double station = MillingDataEngine.Func.SectionViews.ConvertNameToStationLocation(theSectionView.Name);

                        double range = 0.5; //+- range of stations

                        // search maching of cross section in drowing ana xls tanble
                        MillingDataEngine.DataStruct.Cross_section tempCross = theRoadSection.CrossSections.Find((x) => ((x.Station >= station - range && x.Station <= station) ||
                                                                                                                         (x.Station <= station + range && x.Station >= station)));
                        if (tempCross != null && tempCross.MillingElements.Count > 0) //if there is milling elements go next
                        {
                            MillingDataEngine.DataStruct.Cross_section_for_sectionView tempCrossForCV = new MillingDataEngine.DataStruct.Cross_section_for_sectionView(tempCross, theLocation, baseElevation);
                            theRoadSection.AddCrossSectionview(tempCrossForCV);
                        }
                    }

                    DrowToSectionViews(theRoadSection);
                }
                catch (System.Exception e)
                {
                    //throw new System.Exception(e.Message);
                    ed.WriteMessage(e.Message);
                    //return;
                }

                // Save the changes and dispose of the transaction
                ts.Commit();
            }
            ed.WriteMessage("\nOK!");
        }
Ejemplo n.º 9
0
        public void genscs()
        {
            //Definitii generale
            Document      acadDoc  = Application.DocumentManager.MdiActiveDocument;
            CivilDocument civilDoc = CivilApplication.ActiveDocument;
            Database      db       = HostApplicationServices.WorkingDatabase;
            Editor        ed       = acadDoc.Editor;

            //Verificarea existentei macar a unui singur grup de sectiuni transversale
            //SectionViewGroupCollection SVGColl = civilDoc.get
            //SelectionSet SS =

            //Gasirea caii documentului curent
            string caleDocAcad = acadDoc.Database.Filename;

            //Daca fisierul este unul nou, ne salvat inca, calea apartine sablonului folosit pentru acesta.
            //Se verifica daca fisierul este unul sablon, se atentioneaza utilizatorul si se paraseste programul.
            if (caleDocAcad.EndsWith(".dwt") == true)
            {
                ed.WriteMessage("\nThe current drawing is a template file (*.dwt). Exiting program! ");
                return;
            }
            caleDocAcad = HostApplicationServices.Current.FindFile(acadDoc.Name, acadDoc.Database, FindFileHint.Default);


            //Selectarea grupului de sectiuni transversale
            ed.WriteMessage("\nCommand for generating section coordinate systems file (*.SCS) from section view groups");
            PromptEntityOptions PEO = new PromptEntityOptions("\nSelect a section view belonging to the desired section view group: ");

            PEO.SetRejectMessage("\nThe selected object is not a section view! Select object: ");
            PEO.AddAllowedClass(typeof(SectionView), true);

            PromptEntityResult PER = ed.GetEntity(PEO);

            if (PER.Status != PromptStatus.OK)
            {
                ed.WriteMessage("\nInvalid selection! Aborting.");
                return;
            }

            //Inceperea tranzactiei pentru interogarea sectiunilor transversale
            using (Transaction trans = db.TransactionManager.StartTransaction())
            {
                SectionView SV = PER.ObjectId.GetObject(OpenMode.ForRead) as SectionView;     //Sectiunea selectata
                SampleLine  SL = SV.ParentEntityId.GetObject(OpenMode.ForRead) as SampleLine; //Pichetul de care apartine sectiunea

                //Gasirea grupului de sectiuni din care face parte sectiunea, folosindu-ne de numarul acesteia
                int nrSect                = int.Parse(SV.Name.Substring(SV.Name.IndexOf('(') + 1).Replace(")", ""));
                ObjectIdCollection ids    = SL.GetSectionViewIds();
                List <int>         seturi = new List <int>();
                foreach (ObjectId id in ids)
                {
                    string SVname = ((SectionView)id.GetObject(OpenMode.ForRead)).Name;
                    seturi.Add(int.Parse(SVname.Substring(SVname.IndexOf('(') + 1).Replace(")", "")));
                }
                int set = seturi.IndexOf(nrSect);


                SampleLineGroup    SLG  = SL.GroupId.GetObject(OpenMode.ForRead) as SampleLineGroup;
                ObjectIdCollection OIDS = SLG.GetSampleLineIds();

                //Obtinerea sistemelor de coordonate si scrierea lor in fisierul SCS
                string       caleSCS  = caleDocAcad.Remove(caleDocAcad.LastIndexOf('.')) + ".SCS";
                StreamWriter scriitor = new StreamWriter(caleSCS, false);
                foreach (ObjectId OID in OIDS)
                {
                    SampleLine  SLcurr = OID.GetObject(OpenMode.ForRead) as SampleLine;
                    SectionView SVcurr = SLcurr.GetSectionViewIds()[set].GetObject(OpenMode.ForRead) as SectionView;
                    double      x = -999; double y = -999;
                    SVcurr.FindXYAtOffsetAndElevation(0, 0, ref x, ref y);
                    string km = SVcurr.Name.Remove(SVcurr.Name.IndexOf('(') - 1).Replace("+", "");
                    scriitor.WriteLine(string.Format("{0},{1},{2}", km, x, y));
                }
                scriitor.Dispose();
                ed.WriteMessage("\nCoordinate System File written succesfully.");
            }
        }