AcMapMap.GetCurrentMap() failing in AutoCAD 2012

AcMapMap.GetCurrentMap() failing in AutoCAD 2012

Anonymous
Not applicable
805 Views
2 Replies
Message 1 of 3

AcMapMap.GetCurrentMap() failing in AutoCAD 2012

Anonymous
Not applicable

I have a plugin I've written that works fine in AutoCAD Civil 3D 2011. But when I try to run the same plugin in AutOCAD Civil 3D 2012, I get an exception when using the AcMapMap.GetCurrentMap() function. 

 

Here is the unhelpful stack trace:

OSGeo.MapGuide.MgUnclassifiedException: Failed to retrieve message for "MgUnclassifiedException".
   at OSGeo.MapGuide.MapApiPINVOKE.SWIGExceptionHelper.ThrowCustomException(String className, IntPtr cptr)
   at OSGeo.MapGuide.MapApiPINVOKE.AcMapMap_GetCurrentMapInternal()
   at Autodesk.Gis.Map.Platform.AcMapMap.GetCurrentMap()

 

Does anyone know why this function will not work? I have tried building a separate project which references the 2012 OSGeo DLLs, and I still get the same exception.

 

Thanks,

-andy

0 Likes
Accepted solutions (1)
806 Views
2 Replies
Replies (2)
Message 2 of 3

augusto.goncalves
Alumni
Alumni

Hi Andy,

 

I would suggest you repost this question on Civil 3D forum with a small code sample. As you can see, this is a 'unclassified' exception, which usually can have some different reasons...such as not closed resources.

 

Regards,

Augusto Goncalves

Autodesk Developer Network

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

I figured out that some kind of initialization needs to take place before calling GetCurrentMap(). The initialization happens when showing the Task Pane with "mapwspace on ", or with "__MAPSTARTWSPACE". I've added code to run that command when AutoCAD starts and everything is working now.

 

 

0 Likes