<?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: New AutoCAD Managed C# Application Wizard in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412692#M84071</link>
    <description>csharpbird wrote:&lt;BR /&gt;
&amp;gt; The original “AutoCAD Managed C# Application Wizard” is very simple. Only the “Autodesk.AutoCAD.Runtime” namespace is imported, but the ObjectARX application often needs other namespaces such as “Autodesk.AutoCAD.DatabaseSevices” and “Autodesk.AutoCAD.ApplicationSevices”. Futhermore, the version of “System.dll” assembly and "System.Data.dll”　assemly is 1.0 ,but in Visual Studio.net 2003 we need the 1.1 versions.&lt;BR /&gt;
&amp;gt; So I decide to rewrite the wizard to solve the problems. &lt;BR /&gt;
&amp;gt; For more details,you can read this article:&lt;BR /&gt;
&amp;gt; http://www.codeproject.com/useritems/newcswizard.asp&lt;BR /&gt;
&lt;BR /&gt;
Thank you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
David Kurtz&lt;BR /&gt;
Peckham &amp;amp; Wright Architects, Inc.&lt;BR /&gt;
Columbia, Missouri</description>
    <pubDate>Fri, 26 Aug 2005 20:39:54 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2005-08-26T20:39:54Z</dc:date>
    <item>
      <title>New AutoCAD Managed C# Application Wizard</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412691#M84070</link>
      <description>The original “AutoCAD Managed C# Application Wizard” is very simple. Only the “Autodesk.AutoCAD.Runtime” namespace is imported, but the ObjectARX application often needs other namespaces such as “Autodesk.AutoCAD.DatabaseSevices” and “Autodesk.AutoCAD.ApplicationSevices”. Futhermore, the version of “System.dll” assembly and "System.Data.dll”　assemly is 1.0 ,but in Visual Studio.net 2003 we need the 1.1 versions.&lt;BR /&gt;
So I decide to rewrite the wizard to solve the problems. &lt;BR /&gt;
For more details,you can read this article:&lt;BR /&gt;
http://www.codeproject.com/useritems/newcswizard.asp</description>
      <pubDate>Tue, 23 Aug 2005 02:42:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412691#M84070</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-08-23T02:42:27Z</dc:date>
    </item>
    <item>
      <title>Re: New AutoCAD Managed C# Application Wizard</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412692#M84071</link>
      <description>csharpbird wrote:&lt;BR /&gt;
&amp;gt; The original “AutoCAD Managed C# Application Wizard” is very simple. Only the “Autodesk.AutoCAD.Runtime” namespace is imported, but the ObjectARX application often needs other namespaces such as “Autodesk.AutoCAD.DatabaseSevices” and “Autodesk.AutoCAD.ApplicationSevices”. Futhermore, the version of “System.dll” assembly and "System.Data.dll”　assemly is 1.0 ,but in Visual Studio.net 2003 we need the 1.1 versions.&lt;BR /&gt;
&amp;gt; So I decide to rewrite the wizard to solve the problems. &lt;BR /&gt;
&amp;gt; For more details,you can read this article:&lt;BR /&gt;
&amp;gt; http://www.codeproject.com/useritems/newcswizard.asp&lt;BR /&gt;
&lt;BR /&gt;
Thank you.&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
David Kurtz&lt;BR /&gt;
Peckham &amp;amp; Wright Architects, Inc.&lt;BR /&gt;
Columbia, Missouri</description>
      <pubDate>Fri, 26 Aug 2005 20:39:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412692#M84071</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-08-26T20:39:54Z</dc:date>
    </item>
    <item>
      <title>Re: New AutoCAD Managed C# Application Wizard</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412693#M84072</link>
      <description>I am trying to create a C# application that loops through every element in the model space of an AutoCAD application.&lt;BR /&gt;
I have the following code in VB that does the job, but I need it in C#  &lt;BR /&gt;
 &lt;BR /&gt;
VB code:&lt;BR /&gt;
Dim mspace As Object&lt;BR /&gt;
Dim elem As Object&lt;BR /&gt;
acadApp.Documents.Open("C:\test.dwg")&lt;BR /&gt;
mspace = acadApp.ActiveDocument.ModelSpace()&lt;BR /&gt;
For Each elem In mspace&lt;BR /&gt;
...&lt;BR /&gt;
Next&lt;BR /&gt;
But when I translate that to C# i get an error &lt;BR /&gt;
foreach ( object elem in mspace ) { &lt;BR /&gt;
...&lt;BR /&gt;
}&lt;BR /&gt;
saying: " foreach statement cannot operate on variables of type 'object' because 'object' does not contain a definition for 'GetEnumerator', or it is inaccessible"&lt;BR /&gt;
Do you have any C# example to loop through the model space successfully?&lt;BR /&gt;
Thanks in Advance!!&lt;BR /&gt;
Edgar&lt;BR /&gt;
banguero@yahoo.com</description>
      <pubDate>Wed, 31 Aug 2005 22:53:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412693#M84072</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-08-31T22:53:43Z</dc:date>
    </item>
    <item>
      <title>Re: New AutoCAD Managed C# Application Wizard</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412694#M84073</link>
      <description>The problem is you shouldn't be using that code in VB.NET either! The&lt;BR /&gt;
bigger problem, though, is the IDE let you get away with it. Assuming you&lt;BR /&gt;
are doing this through the COM approach, your code should be something&lt;BR /&gt;
like:&lt;BR /&gt;
&lt;BR /&gt;
Dim elem As AcadObject&lt;BR /&gt;
acadApp.Documents.Open("C:\test.dwg")&lt;BR /&gt;
Dim ieObjList as IEnumerator = _&lt;BR /&gt;
acadApp.ActiveDocument.ModelSpace.GetEnumerator&lt;BR /&gt;
While ieObjList.MoveNext&lt;BR /&gt;
  elem = ieObjList.Current&lt;BR /&gt;
  ......&lt;BR /&gt;
End While&lt;BR /&gt;
&lt;BR /&gt;
Now even this isn't the best approach but its more accurate than yours.&lt;BR /&gt;
Ideally, I'd go straight managed code and use a transaction that access the&lt;BR /&gt;
modelspace.GetAllObjects. This retrieves a DBObjectCollection that you can&lt;BR /&gt;
iterate through.&lt;BR /&gt;
 &lt;BR /&gt;
-- Mike&lt;BR /&gt;
___________________________&lt;BR /&gt;
Mike Tuersley&lt;BR /&gt;
___________________________&lt;BR /&gt;
the trick is to realize that there is no spoon...</description>
      <pubDate>Thu, 01 Sep 2005 03:48:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412694#M84073</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-09-01T03:48:03Z</dc:date>
    </item>
    <item>
      <title>Re: New AutoCAD Managed C# Application Wizard</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412695#M84074</link>
      <description>Hi Mike.  Can't seem to make any sense&lt;BR /&gt;
of what you say below, both the example&lt;BR /&gt;
code you show, and the reference to the &lt;BR /&gt;
managed "modelspace.GetAllObjects()" &lt;BR /&gt;
method.&lt;BR /&gt;
&lt;BR /&gt;
What modelspace.GetAllObjects() method&lt;BR /&gt;
are you talking about?&lt;BR /&gt;
&lt;BR /&gt;
Also, would you mind telling us who told&lt;BR /&gt;
you that using IEnumerator is the 'proper'&lt;BR /&gt;
way to iterate over ActiveX collections&lt;BR /&gt;
(in any .NET language) ?&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
"Mike Tuersley" &lt;MTUERSLEY_NOT_&gt; wrote in message news:4944844@discussion.autodesk.com...&lt;BR /&gt;
The problem is you shouldn't be using that code in VB.NET either! The&lt;BR /&gt;
bigger problem, though, is the IDE let you get away with it. Assuming you&lt;BR /&gt;
are doing this through the COM approach, your code should be something&lt;BR /&gt;
like:&lt;BR /&gt;
&lt;BR /&gt;
Dim elem As AcadObject&lt;BR /&gt;
acadApp.Documents.Open("C:\test.dwg")&lt;BR /&gt;
Dim ieObjList as IEnumerator = _&lt;BR /&gt;
acadApp.ActiveDocument.ModelSpace.GetEnumerator&lt;BR /&gt;
While ieObjList.MoveNext&lt;BR /&gt;
  elem = ieObjList.Current&lt;BR /&gt;
  ......&lt;BR /&gt;
End While&lt;BR /&gt;
&lt;BR /&gt;
Now even this isn't the best approach but its more accurate than yours.&lt;BR /&gt;
Ideally, I'd go straight managed code and use a transaction that access the&lt;BR /&gt;
modelspace.GetAllObjects. This retrieves a DBObjectCollection that you can&lt;BR /&gt;
iterate through.&lt;BR /&gt;
 &lt;BR /&gt;
-- Mike&lt;BR /&gt;
___________________________&lt;BR /&gt;
Mike Tuersley&lt;BR /&gt;
___________________________&lt;BR /&gt;
the trick is to realize that there is no spoon...&lt;/MTUERSLEY_NOT_&gt;</description>
      <pubDate>Fri, 02 Sep 2005 07:31:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412695#M84074</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-09-02T07:31:21Z</dc:date>
    </item>
    <item>
      <title>Re: New AutoCAD Managed C# Application Wizard</title>
      <link>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412696#M84075</link>
      <description>I'm not sure what Mike was thinking when he wrote&lt;BR /&gt;
that reply, but the basic problem your code has is&lt;BR /&gt;
that it declares variables as 'object', which you can&lt;BR /&gt;
do in VB, but not in C#.&lt;BR /&gt;
&lt;BR /&gt;
Contrary to what Mike shows, you do not use the&lt;BR /&gt;
IEnumerator to iterate ActiveX collections, since&lt;BR /&gt;
the foreach construct knows how to do that for you.&lt;BR /&gt;
&lt;BR /&gt;
Here's a simple example that iterates over each&lt;BR /&gt;
entity in the modelspace collection, in two ways.&lt;BR /&gt;
The important thing to note is that variables are&lt;BR /&gt;
not declared as 'Object' type.&lt;BR /&gt;
&lt;BR /&gt;
////////////////////////////////////////////////////////&lt;BR /&gt;
using System;&lt;BR /&gt;
using Autodesk.AutoCAD.Interop;&lt;BR /&gt;
using Autodesk.AutoCAD.Runtime;&lt;BR /&gt;
using Autodesk.AutoCAD.Interop.Common;&lt;BR /&gt;
using AcadApp = Autodesk.AutoCAD.ApplicationServices.Application;&lt;BR /&gt;
&lt;BR /&gt;
namespace ActiveXIterator&lt;BR /&gt;
{&lt;BR /&gt;
   public class Class1&lt;BR /&gt;
   {&lt;BR /&gt;
      public Class1()&lt;BR /&gt;
      {&lt;BR /&gt;
      }&lt;BR /&gt;
&lt;BR /&gt;
      [CommandMethod("SAMPLE")]&lt;BR /&gt;
      public void Sample()&lt;BR /&gt;
      {&lt;BR /&gt;
         AcadApplication app = (AcadApplication) AcadApp.AcadApplication;&lt;BR /&gt;
         AcadModelSpace mspace = app.ActiveDocument.ModelSpace;&lt;BR /&gt;
&lt;BR /&gt;
         // One way to iterate the modelspce collection:&lt;BR /&gt;
&lt;BR /&gt;
         int i = 0;&lt;BR /&gt;
         foreach( AcadEntity entity in mspace )&lt;BR /&gt;
         {&lt;BR /&gt;
            Prompt("\nElement {0} EntityName = {1}", i++, entity.EntityName);&lt;BR /&gt;
         }&lt;BR /&gt;
&lt;BR /&gt;
         // Another way to iterate the modelspace collection:&lt;BR /&gt;
&lt;BR /&gt;
         int cnt = mspace.Count;&lt;BR /&gt;
         for( int k = 0; k &amp;lt; cnt; k++ )&lt;BR /&gt;
         {&lt;BR /&gt;
            AcadEntity e = mspace.Item(k);&lt;BR /&gt;
            Prompt("\nitem[{0}].EntityName = {1}", k, e.EntityName);&lt;BR /&gt;
         }&lt;BR /&gt;
      }&lt;BR /&gt;
&lt;BR /&gt;
      public void Prompt(string fmt, params object[] args)&lt;BR /&gt;
      {&lt;BR /&gt;
         AcadApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage(fmt, args);&lt;BR /&gt;
      }&lt;BR /&gt;
&lt;BR /&gt;
   }&lt;BR /&gt;
}&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
&lt;BANGUERO&gt; wrote in message news:4944740@discussion.autodesk.com...&lt;BR /&gt;
I am trying to create a C# application that loops through every element in the model space of an AutoCAD application.&lt;BR /&gt;
I have the following code in VB that does the job, but I need it in C#  &lt;BR /&gt;
 &lt;BR /&gt;
VB code:&lt;BR /&gt;
Dim mspace As Object&lt;BR /&gt;
Dim elem As Object&lt;BR /&gt;
acadApp.Documents.Open("C:\test.dwg")&lt;BR /&gt;
mspace = acadApp.ActiveDocument.ModelSpace()&lt;BR /&gt;
For Each elem In mspace&lt;BR /&gt;
...&lt;BR /&gt;
Next&lt;BR /&gt;
But when I translate that to C# i get an error &lt;BR /&gt;
foreach ( object elem in mspace ) { &lt;BR /&gt;
...&lt;BR /&gt;
}&lt;BR /&gt;
saying: " foreach statement cannot operate on variables of type 'object' because 'object' does not contain a definition for 'GetEnumerator', or it is inaccessible"&lt;BR /&gt;
Do you have any C# example to loop through the model space successfully?&lt;BR /&gt;
Thanks in Advance!!&lt;BR /&gt;
Edgar&lt;BR /&gt;
banguero@yahoo.com&lt;/BANGUERO&gt;</description>
      <pubDate>Fri, 02 Sep 2005 17:30:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/new-autocad-managed-c-application-wizard/m-p/1412696#M84075</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2005-09-02T17:30:04Z</dc:date>
    </item>
  </channel>
</rss>

