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
Solved! Go to Solution.
Solved by Jeff_M. Go to Solution.
Hi Stacy,
Is it possible for you to upload a small data set to investigate the issue ?
Thanks,
Partha
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, 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; } } }
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.
Cheers,
Partha
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,
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
"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.