Author Topic: C# Com Interop Help.  (Read 4598 times)

0 Members and 1 Guest are viewing this topic.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8858
  • AKA Daniel
C# Com Interop Help.
« on: May 07, 2007, 10:52:05 PM »
A little background, I have created a mix managed/unmanaged dll that I can load into Intellicad.
Once this dll is loaded I can load other .Net assemblies via System.Reflection.Assembly.LoadFrom(fileName);
I can then run methods from the remote assembly;

I can’t figure out how to interface with Intellicad’s ActiveX API from within an assembly that’s been netloaded 

I have tried

creates a new instance of Intellicad which I don’t want.
Code: [Select]
IntelliCAD.Application app = new IntelliCAD.Application();

This one freezes the application if invoked from a loaded assembly
But works from an external exe.
Code: [Select]
IntelliCAD.Application app = (IntelliCAD.Application)Marshal.GetActiveObject("ICAD.Application");
      app.ActiveDocument.Utility.Prompt("Hi From Com");

anybody have any ideas on how I can make this work?

Thanks a ton.
Dan

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: C# Com Interop Help.
« Reply #1 on: May 07, 2007, 11:31:45 PM »
nope, sorry.
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.

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8858
  • AKA Daniel
Re: C# Com Interop Help.
« Reply #2 on: May 08, 2007, 02:07:04 AM »
Yeah, I’m dumb when it comes to COM,  :ugly:
I just need to figure out how to get the application object.


Dan
« Last Edit: May 08, 2007, 03:59:27 AM by Danielm103 »

LE

  • Guest
Re: C# Com Interop Help.
« Reply #3 on: May 08, 2007, 09:30:57 AM »
Daniel,

Haber si te sirve este link, suerte.

http://support.microsoft.com/kb/316126

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8858
  • AKA Daniel
Re: C# Com Interop Help.
« Reply #4 on: May 08, 2007, 11:18:33 AM »
Daniel,

Haber si te sirve este link, suerte.

http://support.microsoft.com/kb/316126

Hola Luis,

You know I really really miss Chicharrones. I think I can learn to make them.   ^-^

Thanks for the link. Those work when I call them from an external app. But since I am running inside Intellicad’s space, GetActiveObject fails. I am finding some good info on Arx + Com so this might help.

Dan

LE

  • Guest
Re: C# Com Interop Help.
« Reply #5 on: May 08, 2007, 02:15:56 PM »
Master Daniel;

Here is another url link, in case you have time to explore... no idea if helps

http://www.google.com.mx/search?hl=es&q=GetActiveObject+intellicad&meta=

About the "Chicharrones" I like them too, but those that you make when you prepare "Carnitas".... :)

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8858
  • AKA Daniel
Re: C# Com Interop Help.
« Reply #6 on: May 09, 2007, 01:18:14 AM »
Master Daniel;

Here is another url link, in case you have time to explore... no idea if helps

http://www.google.com.mx/search?hl=es&q=GetActiveObject+intellicad&meta=

About the "Chicharrones" I like them too, but those that you make when you prepare "Carnitas".... :)

Hi Luis,
That worked great, I was able to create the Com Object  in the main module that does the assembly loading. Each assembly can get the object by calling a method.
Code: [Select]
   ICComInterface com = new ICComInterface();
   ICad app = (ICad)com.getComappliation();
   app.ActiveDocument.Utility.Prompt("Hi");
   app.ActiveDocument.SetLispVariable("a", 1);

MMMM you know after living in New Mexico for 25 years ...… well I am a little home sick for posole, Manudo, oh and my favorite Carne adovada so hot you have to eat ice cream afterwards or you will surly regret it the next day.

Thanks Master Luis

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8858
  • AKA Daniel
Re: C# Com Interop Help.
« Reply #7 on: May 09, 2007, 02:54:23 AM »
Here is an ample of what I have so far. I will share once I have more done

Code: [Select]
using System;
using System.Collections;
using System.Runtime.InteropServices;

using DWM.Cad.DatabaseServices;
using DWM.Cad.RuntimeServices;
using DWM.Cad.Geometry;

using ICad = IntelliCAD.Application;

namespace testerclass
{
  public class Test
  {
    [CommandMethod("ln1")]//dans line class
    public static void tmp()
    {
      Line ln = new Line();
      ln.Layer = "0";
      ln.StartPoint = new Point3D(0, 0, 0);
      ln.EndPoint = new Point3D(100, 100, 0);
      ln.Update();
    }
    [CommandMethod("ln2")]//wrapped entmake
    public static void tmp77()
    {
      ResultBuffer Ln = new ResultBuffer();
      Ln.Add(new TypedValue(0, "LINE"));
      Ln.Add(new TypedValue(8, "0"));
      Ln.Add(new TypedValue(10, new Point3D(0, 0, 0)));
      Ln.Add(new TypedValue(11, new Point3D(100, 100, 0)));
      Sds.entMake(Ln);
    }
    [CommandMethod("ln3")]//Com Ugh!
    public static void tmp1()
    {
      ICComInterface com = new ICComInterface();
      ICad app = (ICad)com.getComAppliation();
      IntelliCAD.Document doc = app.ActiveDocument;
      IntelliCAD.Point pt1 = new IntelliCAD.Point();
      IntelliCAD.Point pt2 = new IntelliCAD.Point();
      pt1.x = 100; pt1.y = 100; pt1.z = 0;
      pt2.x = 0; pt2.y = 0; pt2.z = 0;
      IntelliCAD.Line myLine = doc.ModelSpace.AddLine(pt1, pt2);
      myLine.Update();
    }
  }
}

michiel

  • Guest
Re: C# Com Interop Help.
« Reply #8 on: December 16, 2011, 07:13:38 AM »
using DWM.Cad.DatabaseServices;
using DWM.Cad.RuntimeServices;
using DWM.Cad.Geometry;

where do I find these references?

thx

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8858
  • AKA Daniel
Re: C# Com Interop Help.
« Reply #9 on: December 19, 2011, 07:10:34 AM »
Way to dig up the past  :-D
has it been that long since I start doing that wrapper stuff?  :laugh: 
Anyway,  Since Bricscad has been progressing nicely on their .NET API, so I kind of let this go.  I think intellicad 7 may have some .NET stuff, this is if the're still alive... what platform are you using?
BTY welcome to the swamp!

__noop

michiel

  • Guest
Re: C# Com Interop Help.
« Reply #10 on: December 20, 2011, 08:34:01 AM »

well I wrote a .net dll on autocad, which I want to load now in IntelliCAD 7. But I have not the correct references for de databaseServices , RuntimeServices, ...

Thank you in advance..

M