<?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: Export object to SHP in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/export-object-to-shp/m-p/7050707#M31747</link>
    <description>&lt;P&gt;Excellent! &amp;nbsp;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have pretty much given up on the map forum. I found some shp export stuff in civil 3d as well so decided here was the best place to get the answer. &amp;nbsp;I am using civil 3d 2016.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the important parts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using acapp = Autodesk.AutoCAD.ApplicationServices;
using acdb = Autodesk.AutoCAD.DatabaseServices;
using acgis = Autodesk.Gis.Map;


acdb.ObjectIdCollection expcoll = new acdb.ObjectIdCollection();
acapp.Document doc = acapp.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityOptions peo = new PromptEntityOptions("\nSelect an export entity: ");
Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status == PromptStatus.OK)
	expcoll.Add(per.ObjectId);
acgis.MapApplication ma = acgis.HostMapApplicationServices.Application;
acgis.ImportExport.Exporter exp = ma.Exporter;
exp.Init("SHP", @"C:\\myacadfolder\\myshps\newfile.shp");
// exp.ExportAll = false;
exp.SetSelectionSet(expcoll);
acgis.ImportExport.ExpressionTargetCollection dm = null;
dm = exp.GetExportDataMappings();
exp.SetExportDataMappings(dm);
acgis.ImportExport.GeometryType lines = acgis.ImportExport.GeometryType.Line;
exp.SetStorageOptions(acgis.ImportExport.StorageType.FileOneEntityType, lines, string.Empty);
// exp.ClosedPolylinesAsPolygons = true;
acgis.ImportExport.ExportResults results;
try
{
	results = exp.Export(true);
}
catch (acgis.MapImportExportException mee)
{
	string badexport = "There is a problem with the export\n";
        MessageBox.Show(badexport + mee.Message);
}&lt;/PRE&gt;</description>
    <pubDate>Fri, 28 Apr 2017 22:33:44 GMT</pubDate>
    <dc:creator>fieldguy</dc:creator>
    <dc:date>2017-04-28T22:33:44Z</dc:date>
    <item>
      <title>Export object to SHP</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-object-to-shp/m-p/7050519#M31745</link>
      <description>&lt;P&gt;I am almost finished with a SHP export application. &amp;nbsp;Using the sample in the map objectarx sdk I am able to export successfully. &amp;nbsp;My test dwg file only has 1 closed pline with object data in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The part I am stuck on is selecting objects. &amp;nbsp;I have an objectidcollection that contains the objects, but how do I tell the exporter to only export those objects? &amp;nbsp;The layerfilter is not an option.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I have the objects in the collection exported I will post the code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 20:34:22 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-object-to-shp/m-p/7050519#M31745</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2017-04-28T20:34:22Z</dc:date>
    </item>
    <item>
      <title>Re: Export object to SHP</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-object-to-shp/m-p/7050638#M31746</link>
      <description>&lt;P&gt;This is a AutoCAD Map specific question.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The class&amp;nbsp;"Autodesk.Gis.Map.ImportExport.Exporter" has a method SetSelectionSet(ObjectIdCollection), which is what you need, if you pass an ObjectIdCollection to this method, you also want to set ExportAll property to "false" (maybe not necessary, but I always do when exporting selected geometries).&lt;/P&gt;</description>
      <pubDate>Fri, 28 Apr 2017 21:53:48 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-object-to-shp/m-p/7050638#M31746</guid>
      <dc:creator>norman.yuan</dc:creator>
      <dc:date>2017-04-28T21:53:48Z</dc:date>
    </item>
    <item>
      <title>Re: Export object to SHP</title>
      <link>https://forums.autodesk.com/t5/net-forum/export-object-to-shp/m-p/7050707#M31747</link>
      <description>&lt;P&gt;Excellent! &amp;nbsp;Thanks&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/543921"&gt;@norman.yuan&lt;/a&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have pretty much given up on the map forum. I found some shp export stuff in civil 3d as well so decided here was the best place to get the answer. &amp;nbsp;I am using civil 3d 2016.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's the important parts.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;using acapp = Autodesk.AutoCAD.ApplicationServices;
using acdb = Autodesk.AutoCAD.DatabaseServices;
using acgis = Autodesk.Gis.Map;


acdb.ObjectIdCollection expcoll = new acdb.ObjectIdCollection();
acapp.Document doc = acapp.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
PromptEntityOptions peo = new PromptEntityOptions("\nSelect an export entity: ");
Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();
PromptEntityResult per = ed.GetEntity(peo);
if (per.Status == PromptStatus.OK)
	expcoll.Add(per.ObjectId);
acgis.MapApplication ma = acgis.HostMapApplicationServices.Application;
acgis.ImportExport.Exporter exp = ma.Exporter;
exp.Init("SHP", @"C:\\myacadfolder\\myshps\newfile.shp");
// exp.ExportAll = false;
exp.SetSelectionSet(expcoll);
acgis.ImportExport.ExpressionTargetCollection dm = null;
dm = exp.GetExportDataMappings();
exp.SetExportDataMappings(dm);
acgis.ImportExport.GeometryType lines = acgis.ImportExport.GeometryType.Line;
exp.SetStorageOptions(acgis.ImportExport.StorageType.FileOneEntityType, lines, string.Empty);
// exp.ClosedPolylinesAsPolygons = true;
acgis.ImportExport.ExportResults results;
try
{
	results = exp.Export(true);
}
catch (acgis.MapImportExportException mee)
{
	string badexport = "There is a problem with the export\n";
        MessageBox.Show(badexport + mee.Message);
}&lt;/PRE&gt;</description>
      <pubDate>Fri, 28 Apr 2017 22:33:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/export-object-to-shp/m-p/7050707#M31747</guid>
      <dc:creator>fieldguy</dc:creator>
      <dc:date>2017-04-28T22:33:44Z</dc:date>
    </item>
  </channel>
</rss>

