Creating symbol catalog programmatically?

I know there is the option to create a symbol catalog via the "Symbols->Symbol Manager" "Save as catalog" button, but what would be the ideal way to do something similar programmatically?

I have a large number of PNGs organized into different categories, and given the number of catalogs I'd be creating, it seems like having a way to completely automate it would be helpful in the long term. I realize it will likely be faster to just import all the PNGs and create the catalogs by hand using the Symbol Manager dialog, but I enjoy programming, so the journey of writing something to automate it would be part of the fun.

Would this be best done as an XP, or simply an external program that creates an FSC file from scratch? I've been doing C/C++ programming for decades in my day job, so that piece isn't a problem, but the XP API is a bit of a mystery beyond what I've seen in the tutorials on this site and what I've seen in the FastCAD SDK documentation.

The main piece of information I'm missing is how to programmatically create a symbol from a PNG. Whether I do it in an XP or an external program, I'd need to automate the equivalent of IMPORTPNGSYM. Is there any documentation of how a raster symbol is structured as an entity?

It seems like once I am able to create raster symbols, then building a drawing list containing the symbol definitions would be all that would be needed to create an FSC "from scratch".

Currently, I'm working my way backwards by looking at a simple FSC that I created using CC3+ so see the structure layout. I think I finally figured out how to decompress the compressed drawing list after the 128-byte header (I can see human readable paths to my PNGs, so that's a good sign I used the right decompression routine), but I haven't tried to yet match its layout with the structures defined in all the .H files in the SDK. Before I go down that reverse-engineering rabbit hole, I figured I ask here if I'm overlooking something more obvious to figure out how to create raster symbols programmatically.

Now that I think about it, maybe creating an XP that dumps the contents of an existing symbol definition would be an easier way to see the structure...

Thanks for any advice.

Cheers,

Brian

AleD

Comments

  • MonsenMonsen Administrator 🖼️ 82 images Cartographer

    A symbol definition isn't really all that complicated. You have the symbol definition entity with the basic properties, and that entity contains a sublist with regular CC3+ entities that make up the symbol.

    A raster symbol is basically just the same as a vector symbol, the difference is that it usually only contains a single picture entity that reference the png image. I don't have all the flags in my head, but there are some flags to set to indicate that the picture refers to a proper 4-resolution image (which is preferred over using a just a single image for the symbol)

    And yea, a symbol catalog is just a regular drawing where the drawing list is filled by symbol definitions.

    Personally, I would probably have done it as an XP to take advantage of the features provided, but also as a way to gain familiarity with the toolkit.

    You are probably looking at quite a bit of work to assemble all the pieces though, and considering how easy it is to copy symbols between symbol catalogs and build your own from inside CC3+, i don't know if it is worth the effort.

    Brian StormontKertDawgGlitchAleD
  • Thanks for the advice! While I am very new to using CC3, I greatly appreciate all the posts you have written over the years. Coincidentally, I currently have about a dozen browser tabs open, each with an article of yours that I need to read. :-D

    Thanks again,

    Brian

    KertDawg
  • Just a quick follow-up: After stepping through a simple CC3-created FSC, it looks like for my use case of fairly low-resolution symbols (i.e only 1 image pe symbol), the symbol creation process via a program will be pretty straightforward.

    My symbols are only composed of a SYMDEF, which then has a sublist containing a PICTR and a SYMINFO. So, really just three data structures to fill in for each symbol.

    I'm very hopeful I can create a program to automate the process of making a catalog. I'll post another follow-up if I get it working.

    Monsen
  • After fiddling with the SDK and the Visual Studio debugger to get an easy way to look at the data structure internals, I ended up taking a slightly different tack for this utility to batch import symbols and create a symbol catalog.

    Using the SDK .H files as reference, I wrote a python script that will scan a directory containing PNGs and convert them into a symbol catalog, automatically turning the symbols into groups if their names follow the correct pattern, and creating varicolor symbols when appropriate names are detected as well.

    The script will create the necessary SYMDEF, Marker 0, PICTR, ..., SYMINFO, Marker 1 entries in a FSC file which is then readable by CC3+. Here's a screenshot of a quick test where the script created a symbol catalog from a handful of Zatta symbols from K.M. Alexander's map brush files and then I opened the file in CC3. I was pleasantly surprised when the symbols actually showed up. :-)

    It's still a work-in-progress, but once I clean up the code a bit I'll post it to github for anyone that might be interested.

    An eventual goal would be to have the script work directly with an ABR file to extract the PNGs from the brush file, and then turn that into the catalog in a single step. But right now I'm running an external utility to pull the PNGs from a brush, then this python script turns the PNGs into a catalog.

    MonsenLoopysue
  • MonsenMonsen Administrator 🖼️ 82 images Cartographer
Sign In or Register to comment.