<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Import shapefile to polylines in C# .NET framework in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227381#M7394</link>
    <description>&lt;P&gt;I think OSGEO FDO is what you are looking for.&amp;nbsp; The APIs (OSGeo.FDO.dll, OSGeo.FDO.Geometry.dll, OSGeo.FDO.Common.dll) are installed with C3D to&amp;nbsp; C:\Program Files\Autodesk\AutoCAD 2023\Map\bin\FDO (on my pc).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe you can download the APIs separately but have never tried.&lt;/P&gt;&lt;P&gt;Check this link:&amp;nbsp;&lt;A href="https://svn.osgeo.org/fdo/tags/3.3_S010/www/docs/FDO_API_managed/main.htm" target="_blank" rel="noopener"&gt;https://svn.osgeo.org/fdo/tags/3.3_S010/www/docs/FDO_API_managed/main.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Sep 2023 13:25:18 GMT</pubDate>
    <dc:creator>fieldguy</dc:creator>
    <dc:date>2023-09-08T13:25:18Z</dc:date>
    <item>
      <title>Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227269#M7393</link>
      <description>&lt;P&gt;Hello,&amp;nbsp; I don't find how to import a shapefile layer, and then convert it to a 2D polyline through a #C language&amp;nbsp; code. I know that in Autacad/C3D it's "mapimport".&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 12:44:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227269#M7393</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2023-09-08T12:44:28Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227381#M7394</link>
      <description>&lt;P&gt;I think OSGEO FDO is what you are looking for.&amp;nbsp; The APIs (OSGeo.FDO.dll, OSGeo.FDO.Geometry.dll, OSGeo.FDO.Common.dll) are installed with C3D to&amp;nbsp; C:\Program Files\Autodesk\AutoCAD 2023\Map\bin\FDO (on my pc).&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I believe you can download the APIs separately but have never tried.&lt;/P&gt;&lt;P&gt;Check this link:&amp;nbsp;&lt;A href="https://svn.osgeo.org/fdo/tags/3.3_S010/www/docs/FDO_API_managed/main.htm" target="_blank" rel="noopener"&gt;https://svn.osgeo.org/fdo/tags/3.3_S010/www/docs/FDO_API_managed/main.htm&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 13:25:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227381#M7394</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2023-09-08T13:25:18Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227526#M7395</link>
      <description>&lt;P&gt;If you use AutoCAD Map/C3D, it comes with Map .NET API for importing/exporting from/to shape file, exactly the same way as Map's command "MAPIMPORT/MAPEXPORT". The API classes are in Autdesk.Gis.Map.ImportExport namespace of ManagedMapApi.dll, which you can find in "C:\Program Files\Autodesk\[AutoCAD version folder]\Map". However, if you use plain AutoCAD, or other flavors of AutoCAD, you need find third party APIs.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 14:07:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227526#M7395</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-09-08T14:07:57Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227925#M7396</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13127191"&gt;@m.chavet7MJRB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you attached example drawing&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Sep 2023 16:43:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12227925#M7396</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2023-09-08T16:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12228994#M7397</link>
      <description>&lt;P&gt;Thank you for you answers!&lt;/P&gt;&lt;P&gt;It's just a bunch of Polylines. I'm trying to automate the process from an importation of one shapefile of lines to polylines, then to alignements and then profiles.&lt;/P&gt;&lt;P&gt;But I'm a beginner with #C on .NET framework. Do you know how can I find the functions to do that? (with managedmapapi or OSGEO). For the first one, I don't find sample codes and in general, I don't know how to find these functions.&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 09 Sep 2023 11:05:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12228994#M7397</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2023-09-09T11:05:16Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229012#M7398</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13127191"&gt;@m.chavet7MJRB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;see this&lt;/P&gt;&lt;P&gt;&lt;A title="Read coordinates of line features with Map 3D API" href="https://adndevblog.typepad.com/infrastructure/2014/07/read-coordinates-of-line-features-with-map-3d-api.html" target="_blank" rel="noopener"&gt;Read coordinates of line features with Map 3D API&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.Gis.Map.Platform.Interop;
using Autodesk.Gis.Map.Platform;
using OSGeo.MapGuide;
 
// This line is not mandatory, but improves loading performances
[assembly: CommandClass(typeof(GetFeatureType.MyCommands))]
 
namespace GetFeatureType
{
 
public class MyCommands
{
 
 
// Modal Command with localized name
[CommandMethod("getPolylineCoordinates")]
public void MyCommand() // This method can have any name
{
    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application
        .DocumentManager.MdiActiveDocument.Editor;
 
    Transaction trans = Autodesk.AutoCAD.ApplicationServices.Application
        .DocumentManager.MdiActiveDocument.Database.TransactionManager
        .StartTransaction();
 
    using (trans)
    {
        // Get the Map Object
        AcMapMap currentMap = AcMapMap.GetCurrentMap();
 
        // Prompt user to Select Feature in Map
        PromptSelectionOptions psop = new PromptSelectionOptions();
        psop.MessageForAdding = "Select the FDO Feature in Map 3D to read Data : ";
        psop.SingleOnly = true;
        PromptSelectionResult psResult = ed.GetSelection(psop);
 
        if (psResult.Status == PromptStatus.OK)
        {
            SelectionSet selSet = psResult.Value;
 
            // Get Map Selectionset from AutoCAD SelectionSet
            MgSelectionBase mapSelBase = AcMapFeatureEntityService
                .GetSelection(selSet);
            AcMapLayer mapLayer = AcMapFeatureEntityService
                .GetLayer(psResult.Value[0].ObjectId);
 
            //Get the ID of the selected Parcel
            MgFeatureReader ftrRdr = mapSelBase.GetSelectedFeatures(
                mapLayer, mapLayer.FeatureClassName, false);
 
            while (ftrRdr.ReadNext())
            {
                MgClassDefinition cd = ftrRdr.GetClassDefinition();
 
                //the geomety property name maybe different for your 
                //data source 
                MgByteReader byteRdr = ftrRdr.GetGeometry("Geometry");
                MgAgfReaderWriter wtr = new MgAgfReaderWriter();
 
                MgGeometry geom = wtr.Read(byteRdr);
 
                if (geom is OSGeo.MapGuide.MgCurveString)
                {
                    var cs = geom as MgCurveString;
 
                    ed.WriteMessage("\n geo is MgCurveString.");
 
                    for (int i = 0, segmentCount = cs.Count; i &amp;lt; segmentCount; i++)
                    {
                        var seg = cs.GetSegment(i);
                        if (seg is MgArcSegment)
                        {
                            ed.WriteMessage("\nthis is an Arc Segment.");
                            var arcSeg = seg as MgArcSegment;
 
                            string msg = string.Format(
                                "\nstart point: x= {0}, y={1}",
                                arcSeg.StartCoordinate.X,
                                arcSeg.StartCoordinate.Y);
                            ed.WriteMessage(msg);
 
                            msg = string.Format(
                                "\ncontrol point  x= {0}, y={1}",
                                arcSeg.ControlCoordinate.X,
                                arcSeg.ControlCoordinate.Y);
                            ed.WriteMessage(msg);
 
                            msg = string.Format(
                                "\nend point: x= {0}, y={1}",
                                arcSeg.EndCoordinate.X,
                                arcSeg.EndCoordinate.Y);
                            ed.WriteMessage(msg);
                        }
                        if (seg is MgLinearSegment)
                        {
                            ed.WriteMessage("\nthis is a linear Segment.");
 
                            var linearSeg = seg as MgLinearSegment;
                            var interator = linearSeg.GetCoordinates();
                            while (interator.MoveNext())
                            {
                                var x = interator.GetCurrent().X;
                                var y = interator.GetCurrent().Y;
 
                                ed.WriteMessage(string.Format(
                                    "\n x = {0}, y={1} ", x, y));
                            }
                        }
 
                    }
                }
                if (geom is OSGeo.MapGuide.MgLineString)
                {
                    var ls = geom as MgLineString;
                    var interator = ls.GetCoordinates();
                    while (interator.MoveNext())
                    {
                        var x = interator.GetCurrent().X;
                        var y = interator.GetCurrent().Y;
 
                        ed.WriteMessage(string.Format(
                            "\n x = {0}, y={1} ", x, y));
                    }
 
                }
 
            }
        }
        trans.Commit();
    }
 
}
 
 
 
}
 
}
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2023 11:24:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229012#M7398</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2023-09-09T11:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229079#M7399</link>
      <description>&lt;P&gt;Thank you! Could you tell me which references do you import please? I have some issues when I'm trying to import them and I have some errors about non-recognized functions (Platform, MapGuide, AcMap-elements,Mg-elements)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image_2023-09-09_144635000.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1264236i84764BB4B738CC6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="image_2023-09-09_144635000.png" alt="image_2023-09-09_144635000.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Sat, 09 Sep 2023 12:46:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229079#M7399</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2023-09-09T12:46:51Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229081#M7400</link>
      <description>&lt;P&gt;Thank you! Could you tell me which references do you import please? I have some issues when I'm trying to import them and I have some errors about non-recognized functions (Platform, MapGuide, AcMap-elements,Mg-elements)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image_2023-09-09_144635000.png" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1264236i84764BB4B738CC6C/image-size/large?v=v2&amp;amp;px=999" role="button" title="image_2023-09-09_144635000.png" alt="image_2023-09-09_144635000.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2023 12:47:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229081#M7400</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2023-09-09T12:47:10Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229154#M7401</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13127191"&gt;@m.chavet7MJRB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Why you not reading&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/81963"&gt;@fieldguy&lt;/a&gt;&amp;nbsp; and &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&amp;nbsp; @@the reply&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very well&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2023 14:20:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229154#M7401</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2023-09-09T14:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229173#M7402</link>
      <description>&lt;P&gt;There is really no need to go the more complicated route of using Map layer FDO API in this simple case of importing/exporting shape files, if you are using AutoCAD MAP/C3D (you DID not mention it in your original post). Use Map's .NET API for importing/exporting, it is easy/simple. If you downloaded AutoCAD Map ObjectARX SDK (do not confuse it with AutoCAD ObjectARX SDK), it come sample code of MAP import/export API. If you search this &lt;A href="https://forums.autodesk.com/t5/autocad-map-3d-developer/bd-p/84" target="_blank" rel="noopener"&gt;AutoCAD Map Developer Discussion Forum&lt;/A&gt;, you would also find some sample code.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 09 Sep 2023 14:41:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12229173#M7402</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-09-09T14:41:18Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12236979#M7403</link>
      <description>&lt;P&gt;Thank you for your reply.&amp;nbsp; I finally used this code (&lt;A href="https://forums.autodesk.com/t5/autocad-map-3d-developer/shp-import/m-p/8051198" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/autocad-map-3d-developer/shp-import/m-p/8051198&lt;/A&gt;) and so the&amp;nbsp;&lt;SPAN&gt;ManagedMapApi.dll reference.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;What I'm trying to do is import shapefiles into civil 3D, but also then use the attributes of the layer geometries in order to then represent them in the band sets of the profile views. I have already succeded to convert all the polylines into alignments with a C# code thanks to that:&amp;nbsp;&lt;A href="http://alcbimlab.com/C3DCustom/C3D-1.html" target="_blank" rel="noopener"&gt;http://alcbimlab.com/C3DCustom/C3D-1.html&lt;/A&gt;&amp;nbsp;.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;To give concrete examples: I have a shapefile of pipes with attributes of pressure, roughness, flow,... and I would like to represent, in civil 3D, these values in z in different bandsets along my chain.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;I already saw that it was possible with the AeccXUILand assembly.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;With the "mapimport" function and the above-mentioned code, this only imports the shapefile as polylines, but not with all features.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;However I discovered that with the OsGeo FDO Provider objects (the _mapconnect function), my entire attribute table was imported into a "map feature" object.&lt;/SPAN&gt;&lt;/SPAN&gt; &lt;SPAN class=""&gt;&lt;SPAN class=""&gt;So, I'm trying to figure out how to get these features in my code and put them in profile views.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 09:04:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12236979#M7403</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2023-09-13T09:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237404#M7404</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13127191"&gt;@m.chavet7MJRB&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;
&lt;P&gt;...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;SPAN class=""&gt;&lt;SPAN class=""&gt;With the "mapimport" function and the above-mentioned code, &lt;FONT color="#FF0000"&gt;&lt;EM&gt;this only imports the shapefile as polylines, but not with all features.&lt;/EM&gt;&lt;/FONT&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&amp;nbsp;...&lt;/SPAN&gt;&lt;/P&gt;
&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;
&lt;P&gt;Are you saying that besides the geometries in the shape file being imported as Polyline, all data attributes are not imported, or only some of them (but not all of them) being imported? That sounds not right!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Not seeing your code, or the drawing after your importing code execution, I cannot say more. You might want to clarify: were all attributes not imported? or only some of them (then how did you do it in code)?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 12:30:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237404#M7404</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-09-13T12:30:24Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237715#M7405</link>
      <description>&lt;P&gt;All the features are not imported with the "map import", and I guess it's what this code does.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With this code, I don't find the function ImportShape I created when I import it in C3D with netload:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.Civil;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Civil.Settings;
using System.Diagnostics;
using System.IO;
using Autodesk.Gis.Map.ImportExport;
using Autodesk.Gis.Map;

namespace import_shapefile
{
    public class Class1
    {

        #region IExtensionApplication Members

        public void Initialize()
        {
            //    throw new System.Exception("The method or operation is not implemented")
        }

        public void Terminate()
        {
            //    throw new System.Exception("The method or operation is not implemented")
        }

        #endregion


        [CommandMethod("ImportShape")]
        private void ImportShape(FileInfo file)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            MapApplication mapApp = HostMapApplicationServices.Application;
            using (Importer importer = mapApp.Importer)
            {
                importer.Init("SHP", file.FullName);

                string fileName = Path.GetFileNameWithoutExtension(file.FullName).Replace(" ", "");

                foreach (InputLayer inputLayer in importer)
                {
                    inputLayer.SetLayerName(LayerNameType.LayerNameDirect, fileName);
                    inputLayer.SetDataMapping(ImportDataMapping.NewObjectDataOnly, fileName);

                    inputLayer.Dispose();
                }

                importer.ImportPolygonsAsClosedPolylines = true;

                ImportResults result = importer.Import(true);

                sw.Stop();
                //Quest_Common.ed.WriteMessage(string.Format("\n{0} object(s) imported in {1} sec(s)", result.EntitiesImported.ToString(), sw.Elapsed.Seconds));

                importer.Dispose();
            }

            file.Delete();
        }
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Moreover, I get a problem when I launch this code to create profile with no surface, because of the style and the label style are not recognized, it says "Name no exists", I tried "Basic" and "Standard":&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;using System;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.Civil;
using Autodesk.Civil.ApplicationServices;
using Autodesk.Civil.DatabaseServices;
using Autodesk.Civil.Settings;
using Autodesk.AutoCAD.Geometry;


namespace CreateProfileView
{

    public class MyCommands
    {

        #region IExtensionApplication Members

        public void Initialize()
        {
            //    throw new System.Exception("The method or operation is not implemented")
        }

        public void Terminate()
        {
            //    throw new System.Exception("The method or operation is not implemented")
        }

        #endregion

        [CommandMethod("CreateProfileNoSurface")]
        public void CreateProfileNoSurface()
        {
            CivilDocument doc = CivilApplication.ActiveDocument;
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            using (Transaction ts = Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
            {
                // Ask the user to select an 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;

                Alignment oAlignment = ts.GetObject(alignID, OpenMode.ForRead) as Alignment;

                // use the same layer as the alignment
                ObjectId layerId = oAlignment.LayerId;
                // get the standard style and label set 
                // these calls will fail on templates without a style named "Standard"

                ObjectId styleId = doc.Styles.ProfileStyles["Basic"];
                ObjectId labelSetId = doc.Styles.LabelSetStyles.ProfileLabelSetStyles["Basic"];

                ObjectId oProfileId = Profile.CreateByLayout("My Profile", alignID, layerId, styleId, labelSetId);

                // Now add the entities that define the profile.

                Profile oProfile = ts.GetObject(oProfileId, OpenMode.ForRead) as Profile;

                Point3d startPoint = new Point3d(oAlignment.StartingStation, -40, 0);
                Point3d endPoint = new Point3d(758.2, -70, 0);
                ProfileTangent oTangent1 = oProfile.Entities.AddFixedTangent(startPoint, endPoint);

                startPoint = new Point3d(1508.2, -60.0, 0);
                endPoint = new Point3d(oAlignment.EndingStation, -4.0, 0);
                ProfileTangent oTangent2 = oProfile.Entities.AddFixedTangent(startPoint, endPoint);

                oProfile.Entities.AddFreeSymmetricParabolaByLength(oTangent1.EntityId, oTangent2.EntityId, VerticalCurveType.Sag, 900.1, true);

                ts.Commit();
            }

        }

       
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 14:09:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237715#M7405</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2023-09-13T14:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237788#M7406</link>
      <description>&lt;P&gt;At first glance I see that the first method is defined as "private".&amp;nbsp; The second is defined as "public".&lt;/P&gt;&lt;P&gt;IIRC commandmethods need to be defined as "public".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[CommandMethod("ImportShape")]&lt;BR /&gt;private void ImportShape(FileInfo file)&lt;/P&gt;&lt;P&gt;[CommandMethod("CreateProfileNoSurface")]&lt;BR /&gt;public void CreateProfileNoSurface()&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 14:33:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237788#M7406</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2023-09-13T14:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237822#M7407</link>
      <description>&lt;P&gt;Ok, thank you for your reply&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I get this error when I launch on C3D (to import the shapefile):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Application does not support just-in-time (JIT)
debugging. See the end of this message for details.

************** Exception Text **************
System.ArgumentException: Cannot bind to the target method because its signature or security transparency is not compatible with that of the delegate type.
   at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method, Boolean throwOnBindFailure)
   at System.Delegate.CreateDelegate(Type type, Object firstArgument, MethodInfo method)
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorker(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.InvokeWorkerWithExceptionFilter(MethodInfo mi, Object commandObject, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.PerDocumentCommandClass.Invoke(MethodInfo mi, Boolean bLispFunction)
   at Autodesk.AutoCAD.Runtime.CommandClass.CommandThunk.Invoke()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 14:44:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237822#M7407</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2023-09-13T14:44:07Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237827#M7408</link>
      <description>&lt;P&gt;Try &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13127191"&gt;@m.chavet7MJRB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ObjectId styleId = doc.Styles.ProfileStyles[0];
                ObjectId labelSetId = doc.Styles.LabelSetStyles.ProfileLabelSetStyles[0];&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 14:45:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12237827#M7408</guid>
      <dc:creator>hosneyalaa</dc:creator>
      <dc:date>2023-09-13T14:45:28Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12238085#M7409</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13127191"&gt;@m.chavet7MJRB&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Instead of:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[CommandMethod("ImportShape")]
private void ImportShape(FileInfo file)&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;you have to use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;[CommandMethod("ImportShape")]
public void ImportShape()&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Command method can not have any argument and have to be &lt;STRONG&gt;public&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 16:14:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12238085#M7409</guid>
      <dc:creator>Alexander.Rivilis</dc:creator>
      <dc:date>2023-09-13T16:14:22Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12238186#M7410</link>
      <description>&lt;P&gt;&amp;lt;QUOTE&amp;gt;&lt;BR /&gt;&lt;EM&gt;All the features are not imported with the "map import", and I guess it's what this code does.&lt;/EM&gt;&lt;BR /&gt;&amp;lt;/QUOTE&amp;gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Again, it is utterly WRONG to say that. It is your code that is wrong, not the API:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;foreach (InputLayer inputLayer in importer)&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp; inputLayer.SetLayerName(LayerNameType.LayerNameDirect, fileName);&lt;BR /&gt;&amp;nbsp; &amp;nbsp; inputLayer.SetDataMapping(ImportDataMapping.NewObjectDataOnly, fileName);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt; inputLayer.Dispose();&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Why do you dispose the InputLayer? This simply prevented all data attributes being imported.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Of course, the error from the other command has nothing to do with the shape importing, for now, because you have not gotten the data attributes into the drawing (once you do, you'll need to learn how to data data from ObjectData attached to the imported polylines, this would be a whole new different topic).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 16:52:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12238186#M7410</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-09-13T16:52:28Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12238426#M7411</link>
      <description>&lt;P&gt;Thank you for your response, I will check that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I still get this error in both codes : "The application does not support Windows form debugging in just in time (JIT)".&amp;nbsp; I found this to solve the problem:&amp;nbsp;&lt;A href="https://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-A2CD7540-69C5-4085-BCE8-2A8ACE16BFDD" target="_blank"&gt;https://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-A2CD7540-69C5-4085-BCE8-2A8ACE16BFDD&lt;/A&gt;&amp;nbsp;, but I don't get how to implement it in the code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 18:31:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12238426#M7411</guid>
      <dc:creator>m.chavet7MJRB</dc:creator>
      <dc:date>2023-09-13T18:31:45Z</dc:date>
    </item>
    <item>
      <title>Re: Import shapefile to polylines in C# .NET framework</title>
      <link>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12238634#M7412</link>
      <description>&lt;P&gt;The link you quoted probably has nothing to do with the error you get. Have you read the reply from&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/481027"&gt;@Alexander.Rivilis&lt;/a&gt;&amp;nbsp;? Command method doe not allow an argument or arguments (the "ImportShape" command).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Sep 2023 20:50:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/import-shapefile-to-polylines-in-c-net-framework/m-p/12238634#M7412</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2023-09-13T20:50:27Z</dc:date>
    </item>
  </channel>
</rss>

