Automating with Drawing Tools

In CC3+, drawing tools are great timesavers. The basic functionality of a drawing tool is that it works as a preset that contains all the various settings required, such as line style, fill style, line width, color, sheet and layer so that when you draw using a drawing tool you don’t have to go around setting all of these manually like we did in the good old days. Drawing tools also have some built-in nice features like being able to draw two separate entities at once, being able to stay within the map border, and the option to easily edit an existing shape.

However, there is another very important feature that exists for drawing tools, and that is to attach macros to them. A drawing tool can contain an embedded macro which follow the tool and isn’t dependent on your main CC3+ macro file and can contain macros that work in tandem with what you draw using the tool, or even functionality that isn’t connected to drawing at all. Today, we’ll look at how to create these tools and have a brief look at how they can make things easier for us.

Drawing with Macros

If you have been making overland maps, you’ll probably familiar with the forest drawing tools. If you pay attention when you use them, you’ll note that they ask you to draw a smooth shape, and then fills this shape with trees after you are done drawing it. This is a macro drawing tool at work. What happens is that the tool itself is only set up to draw that forest background, but it also contain a macro that gets called when you are done drawing that calls the Fill With Symbols command to fill the area you just drew with trees. Let us make a similar macro that uses the Symbols in Area command instead. I won’t go into detail about Symbols in Area here, since this is about making a macro tool that uses the command, rather than explain the command itself, but if you need a refresher for the command, you can look at this article.

First thing we’ll do is to create a saved setting for the Symbols in Area command, as we want to be able to load this from our macro so the drawing tool uses the same settings each time. For this example, I am using stars from cosmographer, but it could just as well have been trees or cacti or obelisks or villages or whatever you can think of. So, run Draw => Symbols in Area and set up a reasonable setup. I recommend you try out the settings, and keep tweaking them until you have a setup you like before we move on to the macro part of this (remember when testing that you need a polygon in the map to apply this command to). The screenshot shows the settings I used for my tool now, but remember these are dependent on map size and default symbol scale in the map. Since my example is using stars, I’ve elected to use a somewhat large value for random scale to get different sizes, and I’ve also enabled the random symbol selection from group (The symbol catalog I am using have all the stars grouped into a single collection so that it chooses randomly between all of them), as well as using a random layout pattern. Once I have a setting I am happy with, I save it in my CC3+ data directory, under @System\Fillers\stars.symfill

Now, with our setting in place, we can start with our drawing tool. Click the all drawing tool buttons, followed by the Advanced button to get into the editor. Now, hit new and create a tool called Starfield. Set the draw method to Path/Polygon and then click Options and select the Smooth version. Set Attach Mode to Off. Now, hit properties and set the width to a fixed value of 0 (This results in a filled entity instead of just an outline) and set the fill style to solid 20 Bitmap. This fill is solid black, but with a high degree of transparency, so that the end result is that it will just slightly darken anything it is drawn over. Set sheet and layer according to your needs.

You now have a nice drawing tool you can use to draw a smooth polygon in your map. Because of the fill we used, it will be very transparent, almost invisible on some backgrounds. I recommend you try out the new tool before we proceed, then come back. Remember to say yes to save the tool before proceeding.

Once back in the dialog after trying our new tool, check both options under Macro command, then hit Save, before hitting the Command to execute button. This will bring up a text editor window. Add the following macro into the dialog (erase anything that might be in there already, and remember to hit enter at the end of the last line, otherwise it won’t be recognized as a complete command when running the macro):

SYMFILLLOAD @System\Fillers\stars.symfill

After typing in the macro, hit Ok and then hit Save before closing the drawing tools dialog. This is very important, because CC3+ doesn’t detect the changes in the macro text, so it won’t offer to save automatically.

So, let us dissect this macro line by line

  • SYMFILLLOAD … : This line loads the Symbols in Area setting we made earlier. If we don’t load a saved setting, CC3+ will just use the current settings instead, which is probably not what we want. Remember to use whatever filename you save the fill under. Also remember that the @-sign refers to the CC3+ data directory.
  • SELSAVE : This line saves the current select method. This is important because we are going to change the select method on the next line, and we want to be able to set it back to whatever the user was using before running this tool.
  • SELBYP : This macro commands tells CC3+ that instead of using the normal select method, it will do a selection by Prior, which is either the last entity drawn, or the last selection used. This means that with this selection method active, any command that needs a selection will automatically select the prior entity instead of asking the user to select something. In this context the last entity drawn will always be the smooth poly we just drew with our drawing tool. You can refer to this article for more details about selection methods.
  • SYMFILLM : This runs the actual Fill With Symbols command. Normally, it would prompt the user to select the entity to fill, but since we changed the select method to prior above, it will simply use the polygon drawn by your tool instead. This is the macro version of the command, so it will not pop up the settings dialog, instead it will simply use the existing settings (Which are the ones we loaded a few lines earlier)
  • SELREST : This restores the active selection method from before we ran the command. The user would be very confused if we left selection by prior in place, as this would make it very difficult to select entities normally. (Feel free to try it. Just enter SELBYP on the command line and then go on with your mapping. Enter SELBYD to go back to the normal select method again.)

Try out your new tool. It should allow you to draw a smooth poly, and will fill it with stars when done, similar to this.


Pure Macro Drawing Tools

You can also make a drawing tool that doesn’t require you to draw anything at all, but simply runs a macro. This is something I use a lot when managing maps for the community atlas. As an example, let us look at the tool I use to export the map to an image.

To create such a macro-only tool, the procedure is the same as above, but leave Apply macro after drawing unchecked. This will cause CC3+ to just execute the macro, without asking you to draw anything first.

Here is the macro I am using (slightly altered, the version I am actually using contains a custom command I’ve written myself that don’t exist in standard CC3+, the below will work for everyone).

  • GETDWGNAME exportName : Gets the filename of the current drawing and puts it into the exportName variable which we use in multiple lines below
  • APND exportName;.png : This appends .png to the filename. This is important since a later command relies on this to export the correct file type.
  • EXPORTSETAA 25 : Set the antialias export option to 25%
  • EXPORTSETBORDER 0 : Sets the restrict to border option to off since not all atlas maps use the border correctly
  • EXPORTSETVIEWER 1 : Enables the launch image viewer export option
  • EXPORTSETCROP 1 : Enables the crop to aspect ratio export option.
  • EXPORTSETWIDTH 8192 : Sets the width of the export to 8192 pixels
  • EXPORTSETHEIGHT 8192 : Sets the height of the export to 8192 pixels
  • WBSM exportName;^DFirst Corner:;^DSecond Corner: : Runs the actual export. Because I usually need to manually define the export area for atlas maps, I have the command prompt me for the corners here. When using ^D in a macro, it means prompt the user for the parameter. Instead of prompting for the corners here, I could for example have hardcoded coordinates in here, or I could have other commands figure out the coordinates, put them into variables, and use those variables here. The WBSM command itself is equivalent to selecting rectangular section in the save as dialog, and the file name is automatically determined by the extension (which we appended earlier).
  • OPENDOC exportName : Opens the exported image in the default image viewer on the system.

This macro sets up a lot of export options. The idea here is to always export all atlas maps using the same export settings, without having to manually remember to check/set them each time I export a map. Using this tool, it is just a single click operation to correctly export the map to an image file, instead of a lot of manual clicking through dialogs and browsing for the correct location.


Symbol Catalogs

Remember that drawing tools can be added to a symbol catalog. This makes it more easily accessible. For example, I have a special symbol catalog containing all my atlas management tools, thus having them just a click away when I process community atlas maps. There is an Import Draw Tools button in the Symbol Manager, or you can just define a blank new symbol, and go to the symbol options, and check the ‘Drawtool’ option, and fill in the name of the drawtool in the format StyleName\ToolName.


Preview Images

CC3+ can’t generate preview images of macro tools, so they appear blank in the drawing tools dialog. However, you can get a preview image by dropping a .fcw file with the same name as the drawing tool into the same folder as the tool itself. Try to keep this drawing simple however, CC3+ don’t like very complicated drawings being used for the previews.


Leave a Reply