Results 1 to 4 of 4

Thread: Map 2007 Change Coordinate System

  1. #1
    I could stop if I wanted to
    Join Date
    2003-03
    Location
    Alberta
    Posts
    260
    Login to Give a bone
    0

    Question Map 2007 Change Coordinate System

    Working with VB.Net 2005 and Map 2007 I'm having some difficulty changing the coordinate system assigned to a drawing.

    I can call the following and it returns the value that I would expect (ie: UTM83-10)
    Code:
    Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.Projection
    But if I try the following AutoCAD gives me a fatal error message and the whole thing comes crashing down around me.
    Code:
    Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject.Projection="UTM83-11"
    Any suggestions, do I need to set some other variable before changing the coordinate system?

  2. #2
    I could stop if I wanted to
    Join Date
    2003-03
    Location
    Alberta
    Posts
    260
    Login to Give a bone
    0

    Angry Re: Map 2007 Change Coordinate System

    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.

  3. #3
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Map 2007 Change Coordinate System

    I have heard other people complain about the API that is associated with C3D, so I'm not sure the issues are the same, but they say they have to go the COM route to get stuff done. I don't use either one, so I'm not sure how much help that is, but it might give you a way to do stuff. If you want to know more about the topic check out theSwamp.org.

  4. #4
    All AUGI, all the time
    Join Date
    2015-12
    Location
    Central Oregon
    Posts
    591
    Login to Give a bone
    0

    Default Re: Map 2007 Change Coordinate System

    bweir, the following code works for me. I've found that some objects in .NET must be first cast and then used instead of attempting to use them as you tried.
    Code:
        <CommandMethod("TestMe")> _
        Public Sub TestMe()
            Dim AcMap As MapApplication
            AcMap = HostMapApplicationServices.Application
            Dim activeProj As Project.ProjectModel
            activeProj = AcMap.ActiveProject
            Dim strPrjxn As String
            strPrjxn = activeProj.Projection
            MsgBox("The current projection is: " + strPrjxn)
            activeProj.Projection = "UTM83-11"
    
        End Sub
    And I'll echo what Tim said.....check out theSwamp.org for some additional help. Although Map has a full .NET managed wrapper, unlike C3D's heavy use of the ActiveX/COM API.....at least for now, hopefully we'l get some more robust .NET managed code in the next release.
    HTH,
    Jeff

Similar Threads

  1. 2015: coordinate system
    By rmk in forum AutoCAD General
    Replies: 0
    Last Post: 2015-03-27, 09:33 PM
  2. Replies: 0
    Last Post: 2011-01-25, 05:59 AM
  3. Revit Coordinate System
    By dtownsend in forum Revit Architecture - General
    Replies: 1
    Last Post: 2006-10-20, 01:04 PM
  4. Coordinate System
    By mccurdyks in forum Revit Architecture - General
    Replies: 7
    Last Post: 2006-06-21, 05:05 PM
  5. UCS - Un-accessible Coordinate System
    By gregcashen in forum Revit Architecture - Wish List
    Replies: 19
    Last Post: 2004-06-06, 10:20 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •