Search code examples
ms-accessvbams-access-2013autocad

Zoom on MTEXT object AutoCAD


I got an access database, which contains records regarding objects that have a static location on our terrains so we can locate them querying the DB.
EG: CODE              DESCRIPTION              LOCATION
  "E1-050505"         "Concrete Posts"         "Street #"

Now my struggle is that to actually know where to go on our terrains (cause its big), I have to refer to an AutoCAD map, there I will check where "Street #" is located by searching text "E1-050505". I have found vba code that is able to open the autocad file, then the document. But I found no way or command to set focus on an specific control or object.

The procedure would be this: Click a button on Access form, VBA will launch my CAD file, search text "E1-050505" and then set the view to the visual location in the autocad drawing of that object.

I am able to search and find the MTEXT object, but I haven't found a way to move the "camera" or view to focus it.

I need a command or code to move the view to MTEXT object.


Solution

  • You can use the Object option of the Zoom command:

    AcadApp.ActiveDocument.SendCommand "_ZOOM" & vbCr & "_O" _
    & vbCr & "(handent """ & mtext.Handle & """)" & vbCr & vbCr