Author Topic: AU 2005 - Example Code Project  (Read 12777 times)

0 Members and 1 Guest are viewing this topic.

Bobby C. Jones

  • Swamp Rat
  • Posts: 516
  • Cry havoc and let loose the dogs of war.
AU 2005 - Example Code Project
« on: January 03, 2006, 02:15:47 PM »
Per request, attached are the VS2005 project files for my AU2005 code samples.  I *may* have an older VS2003 version of this project lying around if anyone is interested.  Just let me know.
Bobby C. Jones

LE

  • Guest
Re: AU 2005 - Example Code Project
« Reply #1 on: January 03, 2006, 03:48:44 PM »
Per request, attached are the VS2005 project files for my AU2005 code samples.  I *may* have an older VS2003 version of this project lying around if anyone is interested.  Just let me know.

Is possible to run this samples on SharpDevelop ? ... [I have AutoCAD 2005]

Thanks.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: AU 2005 - Example Code Project
« Reply #2 on: January 03, 2006, 04:25:08 PM »
Yes you can Luis, you may have to change the 'using' statements slightly as it seems SharpDev reads the ref'd assemblies a little differently, this may have changed in later releases though.
Also, if the sample was built for 2006 it probably won't compile for 2005 as they changed quite a few of the wrappers (mainly for the editor and UI) and made them more complete for 2006.

If you have VS2002 you should have no trouble, this is what I use at the moment with no prob's so far.
hth
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

LE

  • Guest
Re: AU 2005 - Example Code Project
« Reply #3 on: January 03, 2006, 04:30:48 PM »
Yes you can Luis, you may have to change the 'using' statements slightly as it seems SharpDev reads the ref'd assemblies a little differently, this may have changed in later releases though.
Also, if the sample was built for 2006 it probably won't compile for 2005 as they changed quite a few of the wrappers (mainly for the editor and UI) and made them more complete for 2006.

If you have VS2002 you should have no trouble, this is what I use at the moment with no prob's so far.
hth

 :-(

I see, I just want to play for now.... nope it will allow only 2003 solutions... I have VS2002 but it is the "standard" version.....  does not include C#... OK.. I will download the 2005 express.... for now [will that work?]

Thanks.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: AU 2005 - Example Code Project
« Reply #4 on: January 03, 2006, 04:47:40 PM »
Before you do, create a new project, add your references and add just the .cs files into your project (or copy and paste the code from a std text editor into new files). It's only the version of vs that's givving you the trouble ;)
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

LE

  • Guest
Re: AU 2005 - Example Code Project
« Reply #5 on: January 03, 2006, 05:10:16 PM »
Before you do, create a new project, add your references and add just the .cs files into your project (or copy

Let me explain, what I did before:

1. I started a Class Library
2. Added the references: From the .NET assembly browser and use: "ACDBMGD.DLL" and "ACMGD.DLL"
3. In the HelloWorld.cs - I added:

Code: [Select]
using System;
using System.Runtime.InteropServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.ApplicationServices;
using acadApp = Autodesk.AutoCAD.ApplicationServices.Application;

namespace HelloWorld
{
/// <summary>
/// Description of HelloWorld.
/// </summary>
public class HelloWorld
{
[Autodesk.AutoCAD.Runtime.CommandMethod("HELLO")]
public void HelloCommand()
{
acadApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Hello World FROM C#!");
acadApp.UpdateScreen();
 
}

}
}

I hit the Build option and get:
'Autodesk.AutoCAD.ApplicationServices.Document' does not contain a definition for 'Editor'


MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: AU 2005 - Example Code Project
« Reply #6 on: January 03, 2006, 05:34:12 PM »
Luis, try replacing

acadApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Hello World FROM C#!");

with -

CommandLinePrompts.Message("Hello World FROM C#!");//using the Autodesk.AutoCAD.Application namespace
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

LE

  • Guest
Re: AU 2005 - Example Code Project
« Reply #7 on: January 03, 2006, 05:42:06 PM »
Luis, try replacing

acadApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Hello World FROM C#!");

with -

CommandLinePrompts.Message("Hello World FROM C#!");//using the Autodesk.AutoCAD.Application namespace

 :-o
Aaaaaaaaaaa..... that was it.... that's good!!!, where can I read about those functions or calls? - I see that I do not have to close nothing?... all is managed code like in LISP ?.....

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: AU 2005 - Example Code Project
« Reply #8 on: January 03, 2006, 05:49:03 PM »
You'll probably have to look at the doc's that came with your arx sdk and find suitable replacements for things that won't work. Just holler if you have trouble finding suitable classes.
Quite a few things changed from 2005 to 2006 including some of the geometry classes (matrices for eg) so this will happen quite a bit!

Once you start opening objects and bt's etc. you will need to close them unless you are using transactions which will take care of this for you, I'm not sure if this is the case with arx and tranactions though(?).
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AU 2005 - Example Code Project
« Reply #9 on: January 03, 2006, 05:52:20 PM »
Luis, try replacing

acadApp.DocumentManager.MdiActiveDocument.Editor.WriteMessage("Hello World FROM C#!");

with -

CommandLinePrompts.Message("Hello World FROM C#!");//using the Autodesk.AutoCAD.Application namespace

I was trying to find some old code .. I couldn't remember that .. DUH !
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

MickD

  • King Gator
  • Posts: 3619
  • (x-in)->[process]->(y-out) ... simples!
Re: AU 2005 - Example Code Project
« Reply #10 on: January 03, 2006, 05:54:16 PM »
Here's some old code I used for a template you may find useful.
"Short cuts make long delays,' argued Pippin.”
J.R.R. Tolkien

LE

  • Guest
Re: AU 2005 - Example Code Project
« Reply #11 on: January 03, 2006, 06:02:38 PM »
Once you start opening objects and bt's etc. you will need to close them unless you are using transactions which will take care of this for you, I'm not sure if this is the case with arx and tranactions though(?).

OK, I think not sure.... it is the same as in ObjectARX

Code: [Select]
long i, length;
ads_name ename;
AcDbObjectId entId;
acedSSLength(m_sset, &length);

// Traverse selected entities
acdbTransactionManager->startTransaction();

for (i = 0; i < length; i++) {
// obtener el objectId de cada entidad
acedSSName(m_sset, i, ename);
acdbGetObjectId(entId, ename);
// abrir la entidad y borrarla
// es recomendable inicializar el pointer
// y darle el valor de 0 o NULL que es lo mismo
AcDbEntity* pEnt = NULL;
if (acdbTransactionManager->getObject((AcDbObject*&)pEnt,entId,AcDb::kForWrite) == Acad::eOk) {
pEnt->erase();
}
}

acdbTransactionManager->endTransaction();

Are Smart Pointers available on C# ?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AU 2005 - Example Code Project
« Reply #12 on: January 03, 2006, 06:07:30 PM »
Luis, Have alook at this by Glenn
http://www.theswamp.org/forum/index.php?topic=8197.msg105289#msg105289

Does almost the same thing


Well, NOT the same, but you'll get the idea :-)
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

LE

  • Guest
Re: AU 2005 - Example Code Project
« Reply #13 on: January 03, 2006, 06:18:22 PM »
Luis, Have alook at this by Glenn
http://www.theswamp.org/forum/index.php?topic=8197.msg105289#msg105289

Does almost the same thing


Well, NOT the same, but you'll get the idea :-)

Start to get confused............  :lol:

I don't see in there any place to call the endTransaction() ... It is because if Managed Code no?

Well.... at least I have an idea now [I think]

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: AU 2005 - Example Code Project
« Reply #14 on: January 03, 2006, 06:23:53 PM »
The EndTransaction is automagic BECAUSE the code operates inside this :

using (Transaction tr = ...
{


   
}

     
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.