Community
Civil 3D Customization
Welcome to Autodesk’s AutoCAD Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D Customization topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Extract ground points section to model or file like land does.

25 REPLIES 25
SOLVED
Reply
Message 1 of 26
e_omairquliey
950 Views, 25 Replies

Extract ground points section to model or file like land does.

Hallo guys i have problem that i can't extract the ground points section from civil 3d , i have searched the report section a lot of times and i couldn't extract them to model or file like land help me...

25 REPLIES 25
Message 21 of 26
TerryDotson
in reply to: e_omairquliey

i need to extract the ground points which view in sample sections every 25 meters. 

Try the attached points (DWG & XLSx files).

Message 22 of 26

I do know that order from future line but it's very difficult to arrange it in Excel.

as well as some stations there is no 0m offset for them.

I hope Autodesk solve this issue soon.  

Message 23 of 26
e_omairquliey
in reply to: TerryDotson

I am v thankful for your help .

I will check the points with the ground section and i will back to tell you if they are correct.

Message 24 of 26
hosneyalaa
in reply to: e_omairquliey

 

Maybe

Use this code And arrange it as you like

 

https://forums.autodesk.com/t5/civil-3d-customization/get-section-points-problem/m-p/6000784

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Geometry;
using aGi = Autodesk.AutoCAD.GraphicsInterface;
using Autodesk.AutoCAD.Runtime;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
using CivDb = Autodesk.Civil.DatabaseServices;

namespace Extensions_Section
{
    public class Extensions_Section
    {
        [CommandMethod("testExtensions_Section")]
        public void stExtensions_SectiondA()
        {
            Document doc = Application.DocumentManager.MdiActiveDocument;

            Database db = doc.Database;
            CivilDocument civdoc = CivilApplication.ActiveDocument;

            Editor ed = doc.Editor;
            PromptEntityOptions entOpts = new PromptEntityOptions("Select section:");
            entOpts.SetRejectMessage("...not a section, try again.");
            entOpts.AddAllowedClass(typeof(CivDb.Section), true);
            PromptEntityResult entRes = ed.GetEntity(entOpts);
            if (entRes.Status != PromptStatus.OK)
                return;
            using (Transaction tr = db.TransactionManager.StartTransaction())
            {
                CivDb.Section sec = (CivDb.Section)entRes.ObjectId.GetObject(OpenMode.ForRead);

                var LL = sec.GetSectionLinks();
                var LLPOINT = sec.GetValidSectionPoints();


                tr.Commit();
            }
        }
    }


    public static class ExtensionsSection
    {
        public static IEnumerable<SectionPoint> GetValidSectionPoints(this CivDb.Section section)
        {
            var valid = new HashSet<Point3d>();
            dynamic comSec = section.AcadObject; // AeccSection
            dynamic comLinks = comSec.Links; // AeccSectionLinks
            for (int i = 0; i < comLinks.Count; i++)
            {
                dynamic comLink = comLinks.Item(i); // AeccSectionLink
                if (comLink.Type != 1)
                {
                    valid.Add(new Point3d(comLink.StartPointX, comLink.StartPointY, comLink.StartPointZ));
                    valid.Add(new Point3d(comLink.EndPointX, comLink.EndPointY, comLink.EndPointZ));
                }
            }
            return (from sp in section.SectionPoints
                    where valid.Contains(sp.Location)
                    select sp);
        }

        public static IEnumerable<Section.SectionLink> GetSectionLinks(this CivDb.Section section)
        {
            dynamic comSec = section.AcadObject; // AeccSection
            dynamic comLinks = comSec.Links; // AeccSectionLinks
            for (int i = 0; i < comLinks.Count; i++)
            {
                dynamic comLink = comLinks.Item(i); // AeccSectionLink
                var start = (from sp in section.SectionPoints
                             where sp.Location.IsEqualTo(new Point3d(comLink.StartPointX, comLink.StartPointY, comLink.StartPointZ))
                             select sp).First();
                var end = (from sp in section.SectionPoints
                           where sp.Location.IsEqualTo(new Point3d(comLink.EndPointX, comLink.EndPointY, comLink.EndPointZ))
                           select sp).First();
                if (start != null && end != null)
                {
                    yield return new Section.SectionLink(start, end, i, comLink.Type);
                }
            }
        }

        public static IEnumerable<Section.SectionLink> GetValidSectionLinks(this CivDb.Section section)
        {
            return (from sl in section.GetSectionLinks()
                    where sl.Type != SectionLinkType.NoDraw
                    select sl);
        }
    }

    public static partial class Section
    {
        public class SectionLink
        {
            public SectionPoint StartPoint;
            public SectionPoint EndPoint;
            public readonly int Index;
            public readonly SectionLinkType Type;

            public SectionLink(SectionPoint startPoint, SectionPoint endPoint, int index, SectionLinkType type)
            {
                StartPoint = startPoint;
                EndPoint = endPoint;
                Index = index;
                Type = type;
            }
        }
    }

    public enum SectionLinkType
    {
        None = 0, // aeccSectionLinkNone
        NoDraw = 1, // aeccSectionLinkNoDraw
        All = 2 // aeccSectionLinkAll
    }
}

 

Message 25 of 26
e_omairquliey
in reply to: hosneyalaa

Wow that is code to solve it. really amazing. 

Where i can paste this code in lisp or visualbasic? 

Message 26 of 26
hosneyalaa
in reply to: e_omairquliey

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report