<?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: VB to C# in Civil 3D Customization Forum</title>
    <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671568#M19330</link>
    <description>&lt;P&gt;Alfred hi,&lt;/P&gt;&lt;P&gt;First, thank you.&lt;/P&gt;&lt;P&gt;The purpose of the program is to import Surface XML into the current DWG.&lt;/P&gt;&lt;P&gt;The program was supplied by Autodesk in 2011 and was written in VB.&lt;/P&gt;&lt;P&gt;I manage to change some lines but got stacked at the main task which is the import method.&lt;/P&gt;&lt;P&gt;The program looks as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using System;&lt;BR /&gt;using System.Collections.Generic;&lt;BR /&gt;using System.Linq;&lt;BR /&gt;using System.Text;&lt;BR /&gt;using System.IO;&lt;BR /&gt;using System.ComponentModel;&lt;BR /&gt;using System.Data;&lt;BR /&gt;using System.Drawing;&lt;BR /&gt;//using System.Xml;&lt;BR /&gt;using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;using Autodesk.AutoCAD.ApplicationServices;&lt;BR /&gt;using Autodesk.AutoCAD.DatabaseServices;&lt;BR /&gt;using Autodesk.AutoCAD.EditorInput;&lt;BR /&gt;using Autodesk.AutoCAD.Geometry;&lt;BR /&gt;using Autodesk.Civil.DatabaseServices.Styles;&lt;BR /&gt;using Autodesk.Civil.ApplicationServices;&lt;BR /&gt;using CivSuface = Autodesk.Civil.DatabaseServices.Surface;&lt;BR /&gt;using OpenFileDialog = System.Windows.Forms.OpenFileDialog;&lt;BR /&gt;using DialogResult = System.Windows.Forms.DialogResult;&lt;BR /&gt;using Exception = System.Exception;&lt;BR /&gt;using oSurfaces = Autodesk.Civil.DatabaseServices.SurfaceOperationAddXmlFile;&lt;/P&gt;&lt;P&gt;namespace ClassLibrary1&lt;BR /&gt;{&lt;BR /&gt;public class Class1&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;[CommandMethod("ESD_Surface_XML")]&lt;BR /&gt;//public void ESD_Surface_XML()&lt;BR /&gt;//{&lt;BR /&gt;// String surface = gbutton1_Click();&lt;BR /&gt;// if (surface == null) return;&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;public void ESD_Surface_XML()&lt;BR /&gt;{&lt;BR /&gt;CivilDocument doc = CivilApplication.ActiveDocument;&lt;BR /&gt;Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;ObjectIdCollection SurfaceIds = doc.GetSurfaceIds();&lt;BR /&gt;Stream myStream = null;&lt;BR /&gt;OpenFileDialog openFileDialog1 = new OpenFileDialog();&lt;BR /&gt;openFileDialog1.InitialDirectory = "c:\\";&lt;BR /&gt;openFileDialog1.Filter = "XML files (*.XML)|*.XML";&lt;BR /&gt;openFileDialog1.FilterIndex = 2;&lt;BR /&gt;openFileDialog1.RestoreDirectory = true;&lt;BR /&gt;//string path = openFileDialog1.Directory;&lt;/P&gt;&lt;P&gt;if (openFileDialog1.ShowDialog() == DialogResult.OK)&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;if ((myStream = openFileDialog1.OpenFile()) != null)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;using (myStream)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;String sXmlFileName = openFileDialog1.FileName;&lt;BR /&gt;ed.WriteMessage("\nFile Selected: " + sXmlFileName);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Set Surface = oSurfaces.(sXmlFileName) ;&lt;/FONT&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 24 Oct 2012 06:40:29 GMT</pubDate>
    <dc:creator>ebarlevi</dc:creator>
    <dc:date>2012-10-24T06:40:29Z</dc:date>
    <item>
      <title>VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3670292#M19326</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I need to convert the following line from VB to C#.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Set Surface = oSurfaces.(sXmlFileName)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Idea ?&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2012 12:10:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3670292#M19326</guid>
      <dc:creator>ebarlevi</dc:creator>
      <dc:date>2012-10-23T12:10:18Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3670700#M19327</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;look to &lt;A target="_self" href="http://www.developerfusion.com/tools/convert/vb-to-csharp/"&gt;&amp;gt;&amp;gt;&amp;gt;this page&amp;lt;&amp;lt;&amp;lt;&lt;/A&gt; for translation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;HTH, - alfred -&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2012 15:45:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3670700#M19327</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-10-23T15:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3670768#M19328</link>
      <description>&lt;P&gt;Alfred hi,&lt;/P&gt;&lt;P&gt;I am familiar with that conversion web. Unfortunately it does not work --)&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2012 16:13:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3670768#M19328</guid>
      <dc:creator>ebarlevi</dc:creator>
      <dc:date>2012-10-23T16:13:14Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3670846#M19329</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; Unfortunately it does not work&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;What code do you get as a result, how do the code-lines above (especially the declaration of the var's) look like and what error-message do you get?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Tue, 23 Oct 2012 16:54:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3670846#M19329</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-10-23T16:54:09Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671568#M19330</link>
      <description>&lt;P&gt;Alfred hi,&lt;/P&gt;&lt;P&gt;First, thank you.&lt;/P&gt;&lt;P&gt;The purpose of the program is to import Surface XML into the current DWG.&lt;/P&gt;&lt;P&gt;The program was supplied by Autodesk in 2011 and was written in VB.&lt;/P&gt;&lt;P&gt;I manage to change some lines but got stacked at the main task which is the import method.&lt;/P&gt;&lt;P&gt;The program looks as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;using System;&lt;BR /&gt;using System.Collections.Generic;&lt;BR /&gt;using System.Linq;&lt;BR /&gt;using System.Text;&lt;BR /&gt;using System.IO;&lt;BR /&gt;using System.ComponentModel;&lt;BR /&gt;using System.Data;&lt;BR /&gt;using System.Drawing;&lt;BR /&gt;//using System.Xml;&lt;BR /&gt;using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;using Autodesk.AutoCAD.ApplicationServices;&lt;BR /&gt;using Autodesk.AutoCAD.DatabaseServices;&lt;BR /&gt;using Autodesk.AutoCAD.EditorInput;&lt;BR /&gt;using Autodesk.AutoCAD.Geometry;&lt;BR /&gt;using Autodesk.Civil.DatabaseServices.Styles;&lt;BR /&gt;using Autodesk.Civil.ApplicationServices;&lt;BR /&gt;using CivSuface = Autodesk.Civil.DatabaseServices.Surface;&lt;BR /&gt;using OpenFileDialog = System.Windows.Forms.OpenFileDialog;&lt;BR /&gt;using DialogResult = System.Windows.Forms.DialogResult;&lt;BR /&gt;using Exception = System.Exception;&lt;BR /&gt;using oSurfaces = Autodesk.Civil.DatabaseServices.SurfaceOperationAddXmlFile;&lt;/P&gt;&lt;P&gt;namespace ClassLibrary1&lt;BR /&gt;{&lt;BR /&gt;public class Class1&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;[CommandMethod("ESD_Surface_XML")]&lt;BR /&gt;//public void ESD_Surface_XML()&lt;BR /&gt;//{&lt;BR /&gt;// String surface = gbutton1_Click();&lt;BR /&gt;// if (surface == null) return;&lt;BR /&gt;//}&lt;/P&gt;&lt;P&gt;public void ESD_Surface_XML()&lt;BR /&gt;{&lt;BR /&gt;CivilDocument doc = CivilApplication.ActiveDocument;&lt;BR /&gt;Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;&lt;BR /&gt;ObjectIdCollection SurfaceIds = doc.GetSurfaceIds();&lt;BR /&gt;Stream myStream = null;&lt;BR /&gt;OpenFileDialog openFileDialog1 = new OpenFileDialog();&lt;BR /&gt;openFileDialog1.InitialDirectory = "c:\\";&lt;BR /&gt;openFileDialog1.Filter = "XML files (*.XML)|*.XML";&lt;BR /&gt;openFileDialog1.FilterIndex = 2;&lt;BR /&gt;openFileDialog1.RestoreDirectory = true;&lt;BR /&gt;//string path = openFileDialog1.Directory;&lt;/P&gt;&lt;P&gt;if (openFileDialog1.ShowDialog() == DialogResult.OK)&lt;BR /&gt;{&lt;BR /&gt;try&lt;BR /&gt;{&lt;BR /&gt;if ((myStream = openFileDialog1.OpenFile()) != null)&lt;BR /&gt;&lt;BR /&gt;{&lt;BR /&gt;using (myStream)&lt;BR /&gt;{&lt;/P&gt;&lt;P&gt;String sXmlFileName = openFileDialog1.FileName;&lt;BR /&gt;ed.WriteMessage("\nFile Selected: " + sXmlFileName);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Set Surface = oSurfaces.(sXmlFileName) ;&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2012 06:40:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671568#M19330</guid>
      <dc:creator>ebarlevi</dc:creator>
      <dc:date>2012-10-24T06:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671588#M19331</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;how is "Surface" declared? as Object and you are working with latebinding or as AeccSurface and you have referenced the AECC-lib's?&lt;/P&gt;&lt;P&gt;If that is the complete code-snippet then the base of your problem is that you want to import an XML, but before importing it you try to access the surface (that would exist after import, but not before). Am I right with the statement: when your red line get's executed the surface does not exist in the drawing? If so then the surface-collection has no item called &amp;lt;sXmlFileName&amp;gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;BTW: when you have the code in VBA, why not translating it to VB.NET then? &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2012 07:10:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671588#M19331</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-10-24T07:10:07Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671598#M19332</link>
      <description>&lt;P&gt;Alfred,&lt;/P&gt;&lt;P&gt;The program up to the red line was converted from VB to C#.&lt;/P&gt;&lt;P&gt;The red line is still in VB because I do not know how to convert it.&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;sXmlFileName = string and is the name of the XML file chosen for import.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;2013 does not support VBA, and I do not want to install the add on VBA,this is the reason for the whole conversion project.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Eitan&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2012 07:16:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671598#M19332</guid>
      <dc:creator>ebarlevi</dc:creator>
      <dc:date>2012-10-24T07:16:57Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671606#M19333</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; The program up to the red line was converted from VB to C#&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If it's the filename foro import, then my estimation that the surface does not exist in the drawing is correct. So you can't access the surface from a collection of surfaces if it does not exist.&lt;/P&gt;&lt;P&gt;There is some code lost during conversion I think, can you show the original VBA-code?&lt;/P&gt;&lt;P&gt;Is it possible that on top of the sub in VBA the statement&lt;/P&gt;&lt;P&gt;&lt;FONT color="#666699" face="lucida sans unicode,lucida sans"&gt;On Error Resume Next&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;is placed? If so then also VBA would have the problem/the exception, but with the above statement it ignores it. And that makes sense if the guy who wrote the code tried to verify if a surface already existis in the drawing with that name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; 2013 does not support VBA, and I do not want to install the add on VBA&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;If you are running on 64bit I understand that. But at the single machine where you do development it might be an advantage to compare the workflow at running/debugging situation.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2012 07:34:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671606#M19333</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-10-24T07:34:29Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671632#M19334</link>
      <description>&lt;P&gt;Alfred,&lt;/P&gt;&lt;P&gt;This is the original VB from Autodesk (2011) In my C# I change it so I can browse and select an XML file.&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;' Create a surface from the file EG.xml.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;' NOTE: This uses a hard coded dirercory.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;'&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;Public Function CreateSurfaceByImportXML() As Boolean&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Dim oSurfaces As AeccSurfaces&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Set oSurfaces = g_oDocument.Surfaces&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; ' Get a reference to the existing surface ("EG"). If&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; ' it does not exist, try loading surface data from a&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; ' XML file.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Dim oSurface As AeccSurface&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Dim sXmlFileName As String&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; On Error Resume Next&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Set oSurface = oSurfaces.Item("EG")&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; On Error GoTo 0&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; If (oSurface Is Nothing) Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; sXmlFileName = "d:\temp\EG.xml"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Set oSurface = oSurfaces.ImportXML(sXmlFileName)&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; If (oSurface Is Nothing) Then&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Debug.Print "Error loading XML file: " &amp;amp; Err.Description&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; CreateSurfaceByImportXML = False&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Err.Clear&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; End If&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; End If&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; ' Fill the screen with the surface, and show the triangles&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; ' that make up the surface.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; ThisDrawing.Application.ZoomExtents&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; Call DisplayBorderTrianglesOnly&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt; CreateSurfaceByImportXML = True&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;End Function&lt;/FONT&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2012 07:47:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671632#M19334</guid>
      <dc:creator>ebarlevi</dc:creator>
      <dc:date>2012-10-24T07:47:17Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671660#M19335</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; On Error Resume Next&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt; &amp;gt;&amp;gt; Set oSurface = oSurfaces.Item("EG")&lt;/FONT&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;&lt;FONT color="#666699"&gt;&amp;gt;&amp;gt; On Error GoTo 0&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Ok, it's the "On Error ..." option I mentioned to check if a surface with that name already exists in the drawing.&lt;/P&gt;&lt;P&gt;Now there are two options to continue:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;scan through all surfaces and verify if any of these have the name, if so, use the "Set ..." statement (is more clean and does not raise an exception)&lt;/LI&gt;&lt;LI&gt;use try catch in the hard way, will raise an exception if no surface with the name exists, but it's less code to write&lt;/LI&gt;&lt;/UL&gt;&lt;PRE&gt;try 
  {
     oSurface = oSurfaces.Item("EG");
  } 
catch (Exception ex) 
  {
     oSurface = null;
  }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- alfred -&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2012 08:28:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671660#M19335</guid>
      <dc:creator>Alfred.NESWADBA</dc:creator>
      <dc:date>2012-10-24T08:28:51Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671702#M19336</link>
      <description>&lt;P&gt;Alfred,&lt;/P&gt;&lt;P&gt;Thank you so much for your help.&lt;/P&gt;&lt;P&gt;ebarlevi&lt;/P&gt;</description>
      <pubDate>Wed, 24 Oct 2012 08:56:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3671702#M19336</guid>
      <dc:creator>ebarlevi</dc:creator>
      <dc:date>2012-10-24T08:56:08Z</dc:date>
    </item>
    <item>
      <title>Re: VB to C#</title>
      <link>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3673660#M19337</link>
      <description>&lt;P&gt;Just for reference, the SET is not used in vb.net as it was in vba.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try removing the SET statement before attempting conversion, hopefully it will work for you.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Oct 2012 13:08:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/civil-3d-customization-forum/vb-to-c/m-p/3673660#M19337</guid>
      <dc:creator>andrewpuller3811</dc:creator>
      <dc:date>2012-10-25T13:08:28Z</dc:date>
    </item>
  </channel>
</rss>

