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: 

Create Polyline from Figure using .BaseCurve method

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
stacy.dunn
1181 Views, 8 Replies

Create Polyline from Figure using .BaseCurve method

Partha,

 

in reference to your post http://adndevblog.typepad.com/infrastructure/2012/10/getting-civil-3d-land-featureline-vertices.html

 

You said that there is no need to flatten, but each method I have tried does not produce a polyline with curves.

 

I tried:

survfig.BaseCurve

survfig.BaseCurve.GetProjectedCurve

survig.BaseCurve.GetOrthoprojectedCurve

 

If if manually flatten the figure using a dummy suface with the AeccFeatureElevsFromSurf command, the polyline derived from survfig.BaseCurve will then have actual arc segments.

 

Is there another method or a way to flatten the figure programatically first?

 

Thank you,

Stacy

Stacy Dunn
8 REPLIES 8
Message 2 of 9
Partha.Sarkar
in reply to: stacy.dunn

Hi Stacy,

 

Is it possible for you to upload a small data set to investigate the issue ?

 

Thanks,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 3 of 9
stacy.dunn
in reply to: Partha.Sarkar

Partha,

 

The attached drawing contains regular figures and one that I have manually flattened to a surface plane at zero elevation.  The regular figures will end up with line segments that represent the arcs, while the flattened figure will have actual arcs.

 

Thank you,

Stacy

Stacy Dunn
Message 4 of 9
Jeff_M
in reply to: stacy.dunn

Stacy, rather than flattening the figure or featureline I created some extension methods to recreate the polyline based on the actual segments from those objects. I offer them here for anyone to use. Yes, they are written in c# but should be easily portable to VB.NET.

 

/// 
/// Created by Jeff Mishler
/// Copyright © 2007-2012 Quux Software LLC
/// http://www.quuxsoft.com
/// All rights reserved.
/// 

using System.Collections.Generic;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;

namespace Quux.C3DUtilities.Extensions
{
    /// <summary>
    /// These are mainly for use in C3D2012+, as the Featureline & Surface objects were not exposed to .NET until then.
    /// </summary>
    public static class FeaturelineExtensions
    {
        /// <summary>
        /// Method to get the 2D Polyline represented by the featureline
        /// </summary>
        /// <param name="fl"></param>
        /// <returns></returns>
        public static Polyline BaseCurve2d(this FeatureLine fl)
        {
            Polyline poly = fl.BaseCurve as Polyline;
            if (poly != null)
                return poly;
            object line = fl.AcadObject;
            poly = new Polyline();
            object[] args = new object[1];
            args[0] = 1;
            double[] vertices = (double[])line.GetType().InvokeMember("GetPoints", System.Reflection.BindingFlags.InvokeMethod, null, line, args);

            for (int i = 0, j = 0; i < vertices.Length; i = i + 3, j++)
            {
                Point2d pt = new Point2d(vertices[i], vertices[i + 1]);
                Point3d pt3d = new Point3d(vertices[i], vertices[i + 1], vertices[i + 2]);
                args[0] = pt3d.ToArray();
                double bulge = (double)line.GetType().InvokeMember("GetBulgeAtPoint", System.Reflection.BindingFlags.InvokeMethod, null, line, args);
                poly.AddVertexAt(j, pt, bulge, 0, 0);
            }

            return poly;
        }
    }
}

/// 
/// Created by Jeff Mishler
/// Copyright © 2012 Quux Software LLC
/// http://www.quuxsoft.com
/// 

using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.Civil.DatabaseServices;

namespace Quux.C3DUtilities.Extensions
{
    public static class SurveyFigureExtensions
    {
        /// <summary>
        /// Method to get the 2D Polyline represented by the SurveyFigure
        /// </summary>
        /// <returns></returns>
        public static Polyline BaseCurve2d(this SurveyFigure fig)
        {
            Polyline poly = fig.BaseCurve as Polyline;
            if (poly != null)
                return poly;
            // A surveyfigure derives from a featureline so use it's extension method for the BaseCurve2d
            FeatureLine fl = fig as FeatureLine;
            poly = fl.BaseCurve2d();
            return poly;
        }
    }
}

 

Jeff_M, also a frequent Swamper
EESignature
Message 5 of 9
Partha.Sarkar
in reply to: stacy.dunn

Hi Stacy,

 

I tested my code snippet ( from the same blog post ) on your sample DWG file and I see they are perfectly converted to a polyline, of course, in this case they are converted to a 3D polyline as there are valid elevations attached to Survey Figure objects.

 

I have attached the screenshot from my investigation on your DWG file.

 

Civil3D_SurveyFig_Converted_To_3DPolyline.png

 

Cheers,

Partha



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 6 of 9

And if you want to remove the elevations from the 3dpolyline just run this command -

 

FLATTEN
Select objects to convert to 2d...

 

Cheers,

Partha

 

 



Partha Sarkar
Developer Technical Services
Autodesk Developer Network

Message 7 of 9
stacy.dunn
in reply to: Jeff_M

As always, thank you Jeff!

Stacy Dunn
Message 8 of 9
stacy.dunn
in reply to: Partha.Sarkar

Partha,

 

My issue is not really with generating the polyline, it is with generating the polyline with true arc segments instead of short lines that represent an arc.

 

Thank you,

Stacy

Stacy Dunn
Message 9 of 9
joantopo
in reply to: stacy.dunn

"Is there another method or a way to flatten the figure programatically first?"

 

You can previously select entities in drawing and then use a command method "RaiseLowerFeatures\nE " and value=0 to flatten.

 

 

Autocad C3D 2019 SP3, 2020 & 2021
Intel I9 9900K with frontal watercooler alphacool eisbaer 360 (original fans mounted in pull)- 3 fans Corsair 120 ML PRO in push.
MOBO Gygabyte Z390 Aorus Master- Corsair RGB Vengeance 64GB RAM (4x16) CL16
Nvidia Quadro RTX 4000
Samsung 970 EVO PLUS 1TB (unit C). Samsung 970 PRO 512GB (for data)
Power Supply: Corsair TX850M PLUS


Descubre mi programa VisorNET para Civil 3D:
https://apps.autodesk.com/CIV3D/es/Detail/Index?id=appstore.exchange.autodesk.com%3avisornet_windows32and64%3aes

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

Post to forums  

Rail Community


 

Autodesk Design & Make Report