AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Select Coordinate System using VBA (version 2016)

2 REPLIES 2
Reply
Message 1 of 3
Anonymous
659 Views, 2 Replies

Select Coordinate System using VBA (version 2016)

I would like to use VBA to set the coordinate system - specifically "LA83-SF-MOD" (NAD 83 Louisiana State Plane, Southern Zone, US Survey Foot).

 

Does anyone know how to do this?

 

Thanks very much,

Kevin

2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: Anonymous

It can be done quite eazily in VBA, where you need to set reference to "AutoCAD Map 3D 2005" (AcMapVbApi.tlb), by going to menu "Tools->Refernces...". Do not be confused by "....2005", though, because the AutoCAD Map COM API has been "frozen" since AutoCAD Map 2005, thus the name of Map COM API refering "...2005".

 

After setting the reference to Map's COM API library, following simple code will do what you need:

 

Public Sub SetProjection()

    Dim acMap As AutocadMAP.AcadMap
    
    Set acMap = _
        Application.GetInterfaceObject("AutoCADMap.Application")
    
    Dim proj As AutocadMAP.Project
    Set proj = acMap.Projects(ThisDrawing)
    
    MsgBox "Current projection: " & _
        IIf(proj.CurrentProjection = "", _
        "not set", proj.CurrentProjection)
    
    proj.CurrentProjection = "LA83-SF-MOD"
    
    MsgBox "Current projection has been set to: " & _
        proj.CurrentProjection

End Sub

By the way, I run this code OK with AutoCAD Map 2015/Civil 2015.

 

HTH

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3
Anonymous
in reply to: norman.yuan

Thanks!  I will give that a shot.  I am really using Civil 3D (as I see you are), but did not see a Developer's forum under that product.  This will be a BIG help because I WAS passing along the GEOREMOVE command from VBA, which worked, but because of a glitch in 2016, I have discovered in the forums that you cannot issue more than one COMMAND from VBA without getting a VBA error.  Si I had to put message boxes in the code for the user to do that first before proceeding.

 

Now that I can use VBA to get out of State Plane and back in, I can totally automate my procedure.  (BTW, for some reason the GEOTIFFs that our local government provides will not come in correctly unless we ermove the coordinate system first.)

 

Thanks for helping out!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report