TIP: Determining Map Width in Macros

Determining the working map width can be a bit tricky but sometimes it's needed for scaling purposes. The software does it by finding the innermost entities on the MAP BORDER layer (right?) but there seems to be no macro command to do this. Fortunately I found a workaround that works for me. GETSHEETX vMapWidth;BACKGROUND The "BACKGROUND" sheet typically has no entities that extend beyond the map's working area. The height of the map can (if needed) be similarly determined using the GETSHEETY command. I hope someone finds this useful.

Comments

  • MonsenMonsen Administrator 🖼️ 46 images Cartographer
    edited May 2019
    The general way in the software use to check the extent of the complete set of visible entities on all visible sheets/layers, it doesn't check a particular layer.

    This is basically why the GETSHEET(X/Y) commands came about, just to allow you to check on a more specific sheet, just for this purpose (avoiding things beyond the map border.)

    You also have the GETLAYERX/GETLAYERY commands for layers.

    There are more information about these here.
  • DaltonSpenceDaltonSpence Mapmaker
    edited May 2019
    I originally tried to use the GETLAYERX command with the MAP BORDER layer but unfortunately some templates use that layer for decorative borders outside the working area and even hiding the MAP BORDER sheet didn't stop the extent commands from picking them up. Which is why I'm lobbying for GETBORDER_ commands to get the internal dimensions of the map that the program uses sometimes to scale things. (Or maybe it doesn't and nobody has noticed? ;) )
  • DaltonSpenceDaltonSpence Mapmaker
    edited May 2019

    It occurred to me that knowing where the map boundaries are may be important to many macro writers so perhaps this code could be included in the OnOpenMacro note of new templates.

    getsheetl mapxy1;BACKGROUND getx mapx1 mapxy1 gety mapy1 mapxy1 getsheeth mapxy2;BACKGROUND getx mapx2 mapxy2 gety mapy2 mapxy2 getsheetx mapWidth;BACKGROUND getsheety mapHeight;BACKGROUND

    You may note I like using the OnOpenMacro note for a lot of preprocessing issues, not just setting up symbols and menus. (See my QUESTIONS: OnXxxxMacro Map Notes discussion for details.)

Sign In or Register to comment.