TIP: Determining Map Width in Macros
DaltonSpence
Mapmaker
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
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.
GETLAYERX
command with theMAP BORDER
layer but unfortunately some templates use that layer for decorative borders outside the working area and even hiding theMAP BORDER
sheet didn't stop the extent commands from picking them up. Which is why I'm lobbying forGETBORDER_
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? )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.)