Author Topic: Get .Net Type for string unmanaged class name  (Read 2129 times)

0 Members and 1 Guest are viewing this topic.

Andrey Bushman

  • Swamp Rat
  • Posts: 864
Get .Net Type for string unmanaged class name
« on: August 27, 2011, 12:42:45 PM »
I have are string value, which will reading from ObjectId.ObjectClass.Name.
How on the base it string I can get .net-wrapper Type?

For example:

I have string: "AcDbText"
I need get it's Type (Autodesk.AutoCAD.DatabaseServices.DBText) by my string.
How can I do it?

I tried so:
Code: [Select]
Dictionary dict = SystemObjects.ClassDictionary;
RXClass rx = (RXClass) dict["AcDbText"];
//Further I do not know... (((

Jeff H

  • Needs a day job
  • Posts: 6150
Re: Get .Net Type for string unmanaged class name
« Reply #1 on: August 27, 2011, 03:48:23 PM »
You might store the ObjectId.ObjectClass.DxfName instead.
 
I need to look this up or read back up on it but if your dll is not in the same folder as the acad.exe you might have to use the qualified name.
 
Or load the acdbmgd assembly from reflection-only context and use Assembly.GetType() .
 
 
Code: [Select]

         [CommandMethod("tt")]
        public void tt()
        {
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
            Type typeAssemblyQualifiedName = Type.GetType("Autodesk.AutoCAD.DatabaseServices.DBText, Acdbmgd, Version=18.2.0.0, Culture=neutral, PublicKeyToken=null", false, true);
            ed.WriteMessage("\nUsing Assembly Qualified Name : " + typeAssemblyQualifiedName.Name);
            Assembly ass = Assembly.ReflectionOnlyLoad("acdbmgd");
            Type typeFullName = ass.GetType("Autodesk.AutoCAD.DatabaseServices.DBText", false, true);   
            ed.WriteMessage("\nUsing Assembly : " + typeFullName.Name);   
        }