<?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: Add .dwg file to Map using Code in ArcObjects SDK Questions</title>
    <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422637#M11391</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;The CAD files do not have any projection files, it is come from other agency who only use the AutoCAD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 13 Apr 2016 13:22:51 GMT</pubDate>
    <dc:creator>VeroniqueXie</dc:creator>
    <dc:date>2016-04-13T13:22:51Z</dc:date>
    <item>
      <title>Add .dwg file to Map using Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422633#M11387</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; One of our customers have thousands of CAD .dwg files. The need an function on the Web that they can provide a .dwg file name, and get an .PDF file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Export to PDF&amp;nbsp; from .mxd or .lyr file is quite easy.&amp;nbsp; The problem is how to make an .mxd or .lyr file from a .dwg file.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Of cause I can using ArcMap, add .dwg file using the Add Data Dialog. As I learn from the Desktop Help:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; "When you add CAD data to a map document, features are drawn to match the CAD drawing's original symbology as closely as possible. The default CAD renderer draws CAD features by unique values combining line type, color, and line weight properties."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; And I got a map like this, it's pretty good:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;IMG alt="1.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/194708_1.png" style="width: 620px; height: 373px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; The problem is&amp;nbsp; we need to automate the process. so we using the flowing code to add the Cad Drawing to the Map:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &lt;/P&gt;&lt;P&gt;&amp;nbsp; Set pCadDrawingDataset = GetCadDataset("d:\data\cad", "e-51878.dwg")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If pCadDrawingDataset Is Nothing Then Exit Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pCadLayer = New CadLayer&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Set pCadLayer.CadDrawingDataset = pCadDrawingDataset&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pCadLayer.Name = "e-51878.dwg"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; pMxDoc.FocusMap.AddLayer pCadLayer&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; It works, but the map looked like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; &lt;IMG alt="2.png" class="image-2 jive-image" src="https://community.esri.com/legacyfs/online/194709_2.png" style="width: 620px; height: 371px;" /&gt;&lt;/P&gt;&lt;P&gt;The line color is OK, but the&amp;nbsp; Annotation is too big compares the the first image, and the whole dwg file becomes one layer.&amp;nbsp; Since it is become one layer, we can not modify the display of the annotation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Of cause we can add the .dwg layer by layer using&amp;nbsp; .dwg:polyline, .dwg:polygon.&amp;nbsp; But this method can not do the automatic symbolization.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #2873ee;"&gt;&lt;STRONG&gt;So my question is : Is it possible to do the "Add Data to Map"&amp;nbsp; by the ArcObjects Code? So that I can get the first map.&lt;/STRONG&gt; &lt;/SPAN&gt;I know there is a IAddDataDialog, but it will popup an dialog.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ArcMap using a special renderer for CAD .dwg file, it is very difficult to do it in Code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG alt="3.png" class="image-3 jive-image" src="https://community.esri.com/legacyfs/online/194710_3.png" style="width: 620px; height: 479px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 02:36:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422633#M11387</guid>
      <dc:creator>VeroniqueXie</dc:creator>
      <dc:date>2016-04-13T02:36:03Z</dc:date>
    </item>
    <item>
      <title>Re: Add .dwg file to Map using Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422634#M11388</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; I guest the best way is to add may be 10-20 .dwg files one time in ArcMap using the Add Data,&amp;nbsp; then save each .dwg group layer&amp;nbsp; to .lyr file using python code; keep doing it until we create a .lyr file for each .dwg file. Thus the .lyr files will have the renderer information of the .dwg files. Finally we can use AO or Python to export PDF using the exist .lyr file, get the right symbol and annotation.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 05:26:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422634#M11388</guid>
      <dc:creator>VeroniqueXie</dc:creator>
      <dc:date>2016-04-13T05:26:54Z</dc:date>
    </item>
    <item>
      <title>Re: Add .dwg file to Map using Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422635#M11389</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; I searched the document and find that we can drop the .dwg file from a Catlog window instead of using the "Add Data" button:&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="194717" alt="4.png" class="image-1 jive-image" src="https://community.esri.com/legacyfs/online/194717_4.png" style="width: 620px; height: 111px;" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; This method also creates a group layer, &lt;SPAN style="color: #2873ee;"&gt;can we automate this process by ArcObjects code? &lt;/SPAN&gt;Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 06:14:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422635#M11389</guid>
      <dc:creator>VeroniqueXie</dc:creator>
      <dc:date>2016-04-13T06:14:33Z</dc:date>
    </item>
    <item>
      <title>Re: Add .dwg file to Map using Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422636#M11390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;On the subject of the annotation changing size.&lt;/P&gt;&lt;P&gt;Does the input CAD file have a known projection? normally this would mean you have a prj file next to the CAD with the same basename.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 06:32:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422636#M11390</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-04-13T06:32:54Z</dc:date>
    </item>
    <item>
      <title>Re: Add .dwg file to Map using Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422637#M11391</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply.&lt;/P&gt;&lt;P&gt;The CAD files do not have any projection files, it is come from other agency who only use the AutoCAD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 13:22:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422637#M11391</guid>
      <dc:creator>VeroniqueXie</dc:creator>
      <dc:date>2016-04-13T13:22:51Z</dc:date>
    </item>
    <item>
      <title>Re: Add .dwg file to Map using Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422638#M11392</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Well that probably explains why the annotation changes size.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 13 Apr 2016 14:39:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422638#M11392</guid>
      <dc:creator>NeilAyres</dc:creator>
      <dc:date>2016-04-13T14:39:39Z</dc:date>
    </item>
    <item>
      <title>Re: Add .dwg file to Map using Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422639#M11393</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Yes, That could be the reason for the annotation. But the annotation works well when adding the .dwg using the "Add Data" button in ArcMap. Seems the "Add Data" using better mechanism to show the CAD data.&amp;nbsp; That is why we want simulate that process in Code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Apr 2016 00:42:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422639#M11393</guid>
      <dc:creator>VeroniqueXie</dc:creator>
      <dc:date>2016-04-14T00:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: Add .dwg file to Map using Code</title>
      <link>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422640#M11394</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was looking for a solution for&amp;nbsp; exactly the same requirement as described in this thread.&amp;nbsp; Though it is an old thread, it may help someone.&amp;nbsp; The solution is given below.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Public Sub AddCADLayer2GroupLayer(pGrpLayer As IGroupLayer, cadFolderPath As String, cadfilename As String)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Dim pFeatureLayer As ESRI.ArcGIS.Carto.IFeatureLayer = Nothing&lt;BR /&gt; Dim factory As IWorkspaceFactory = New CadWorkspaceFactory&lt;BR /&gt; Dim pFeatureWorkspace As IFeatureWorkspace = CType(factory.OpenFromFile(cadFolderPath, 0), IFeatureWorkspace)&lt;BR /&gt; Dim pFeatureDataset As IFeatureDataset = CType(pFeatureWorkspace.OpenFeatureDataset(cadfilename), IFeatureDataset)&lt;BR /&gt; Dim pFeatureClassContainer As IFeatureClassContainer = CType(pFeatureDataset, IFeatureClassContainer)&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;For i As Integer = 0 To pFeatureClassContainer.ClassCount - 1&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;&lt;BR /&gt; Dim pFeatureClass As IFeatureClass = pFeatureClassContainer.Class(i)&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;If pFeatureClass.FeatureType = esriFeatureType.esriFTAnnotation Or pFeatureClass.FeatureType = esriFeatureType.esriFTCoverageAnnotation Then&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;pFeatureLayer = New CadAnnotationLayerClass&lt;BR /&gt; pFeatureLayer.Name = pFeatureClass.AliasName&lt;BR /&gt; pFeatureLayer.FeatureClass = pFeatureClass&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;Else&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;BR /&gt; pFeatureLayer = New CadFeatureLayer&lt;BR /&gt; pFeatureLayer.Name = pFeatureClass.AliasName&lt;BR /&gt; pFeatureLayer.FeatureClass = pFeatureClass&lt;BR /&gt; Dim iglayer As ESRI.ArcGIS.Carto.IGeoFeatureLayer = CType(pFeatureLayer, ESRI.ArcGIS.Carto.IGeoFeatureLayer)&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;'Here the Renderer is set&lt;BR /&gt; Dim pUID As New UID ' create a new UID objects&lt;BR /&gt; 'progID is "esriCartoUI.CadUniqueValuePropertyPage"&lt;BR /&gt; pUID.Value = "esriCartoUI.CadUniqueValuePropertyPage"&lt;BR /&gt; iglayer.RendererPropertyPageClassID = pUID&lt;/P&gt;&lt;P style="padding-left: 60px;"&gt;End If&lt;/P&gt;&lt;P style="padding-left: 90px;"&gt;If pFeatureLayer IsNot Nothing Then&lt;BR /&gt; pGrpLayer.Add(pFeatureLayer)&lt;BR /&gt; End If&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;Next&lt;/P&gt;&lt;P&gt;End Sub&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 29 Aug 2019 05:56:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcobjects-sdk-questions/add-dwg-file-to-map-using-code/m-p/422640#M11394</guid>
      <dc:creator>rajeshc</dc:creator>
      <dc:date>2019-08-29T05:56:32Z</dc:date>
    </item>
  </channel>
</rss>

