I'm getting very angry with the AutoCAD Managed API stuff. It seems to have more wholes in it then a colander. Because I can't seem to change the projection system using the Map API I thought I would tap into the Lisp through ActiveX. Well guess what this doesn't work either.
Code:
Dim ADwg As AcadIop.AcadDocument = Dwg.AcadDocument
Dim VL As Object = ADwg.Application.GetInterfaceObject("VL.Application.16")
Dim Funcs As Object = VL.ActiveDocument.Functions
Dim Func As Object = Funcs.Item("ade_projsetwscode")
Changed = CType(Func.Funcall(Chr(34) & Projection & Chr(34)), Boolean)
' Tried with and without the Chr(34).
Func = Nothing
Funcs = Nothing
VL = Nothing
The only time Changed comes back with True is when I give the function the same projection code that the drawing is already set to. Am I making some wrong assumptions as to how things work in AutoCAD? Using the (ade_projsetwscode...) function in Lisp or the ADESETCRDSYS command change the projection as one would expect. Using anything else is causing nothing but headaches.
I have an event handler to watch the coordinate system for me and it will report when ever the code is changed; either through a command, lisp or other means. Nothing is fired when I try Lisp through ActiveX cuz the function fails through ActiveX.
I think I'm just going to have to use the SendStringToExecute method (in VB.Net) of the Dwg and send the (ade_projsetwscode...) function to the command line. Looks like this is the only method that works. Down fall is that there is nothing returned if the SendStringToExecute was successful or not.