Author Topic: Mixed/Managed C++ dll's, passing objects.  (Read 10621 times)

0 Members and 1 Guest are viewing this topic.

MickD

  • Gator
  • Posts: 3471
  • (x-in)->[process]->(y-out)
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #45 on: January 14, 2010, 10:23:28 PM »
woot! Thanks Dan.

Just having trouble with the database now, I'm passing in a Database^, this is what I have -

#define GetDb(database) (reinterpret_cast<AcDbDatabase*>(&(database)))

but no worky

this mixed/managed stuff has sooo many subtle tricks to watch out for, I'm almost there though!
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7054
  • AKA Daniel
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #46 on: January 14, 2010, 10:32:21 PM »
The casting only works for managed value types. for ref types you need to do something like   


Code: [Select]
AcDbDatabase *pnDb =  pmDb->UnmanagedObject.ToPointer();

//and

Database ^pmDb = dynamic_cast<Database^>(DisposableWrapper::Create(Database::typeid,(IntPtr)pnDb,false));

MickD

  • Gator
  • Posts: 3471
  • (x-in)->[process]->(y-out)
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #47 on: January 14, 2010, 10:40:38 PM »
hmm, I think I'm getting the db ok but as I'm creating a new one in C# I think it's open for write and I'm trying to add abjects to it in native code, I'll dig a bit deeper and let you know, thankis again :)
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”

It's Alive!

  • BricsCAD
  • Needs a day job
  • Posts: 7054
  • AKA Daniel
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #48 on: January 14, 2010, 10:51:16 PM »
Cool! May your pointers all point to the same instance  :lol:

MickD

  • Gator
  • Posts: 3471
  • (x-in)->[process]->(y-out)
Re: Mixed/Managed C++ dll's, passing objects.
« Reply #49 on: January 14, 2010, 10:57:10 PM »
woot!

Thanks Daniel, working fine now with a small adjustment, cheers.

pDb = (AcDbDatabase*)dbout->UnmanagedObject.ToPointer();
Forth is like the Tao: it is a Way, and is realized when followed.
Its fragility is its strength; its simplicity is its direction - Michael Ham

Lao Tzu: “To attain knowledge, add things
every day; to obtain wisdom, remove things every day.”