Where to find map file data in an XP
Hello,
I'm writing an XP to export walls to Foundry. Ideally I'd like to calculate the scale factor to convert from CC units (feet) to pixels. I have the formula to do it ready to go but I need to access two variables:
- Pixel Size Width (I can find this in the GUI by going to File -> Save As -> Options -> Pixel Size -> Width)
- Drawing Area Width (I can find this in the GUI by going to File -> Resize Drawing Area -> Width)
I could always prompt the user to enter these but it's more friction, and since the program has the values, I should be able to access them from an XP, right?
I also could calculate the Drawing Area Width using an Extents check (maybe on the background layer?) but that's extra processing if the info is already stored somewhere.
Also in general is there any API documentation available where I could find accessors for data about CC3's files?
Thanks again!
Best Answer
-
Monsen Administrator 🖼 81 images Cartographer
These aren't values stored in the map that can be simply accessed.
The Drawing area size is found by calculating the extents of the current drawing. CC3+ drawing doesn't actually have a fixed size (as you may have noticed, you can easily draw far outside the map border with the basic tools. So the size you see in this dialog is just the current extents of the entities in your map. Finding the extents is basically just walk the list of entities and grab all the coordinates there and just pick out the biggest and smallest ones, these will describe your extent.
As for the pixel size, CC3+ doesn't care about pixels at all. The value you refer to is just whatever value you happened to put into the export dialog the last time you used it, but it has nothing at all to do with the current map. And any CC3+ map can be exported to any pixel size, so to calculate in relation to the export size you must know what resolution the user intends to export in. Now, usually, when you export battle maps for VTT use, you would use whatever number of pixels per map square as that particular VTT system prefer. I don't know what foundry want, and it probably can use different values, but that is the value you want, not whatever is stored in the CC3+ dialog. And there is really no way for CC3+ to tell you this since it doesn't work in pixel space. But you could assume some standard pixels/square, for example if you plan on exporting the map as 100 pixels per 5' square, that relates to 20 pixels per map unit.
Answers
These aren't values stored in the map that can be simply accessed.
The Drawing area size is found by calculating the extents of the current drawing. CC3+ drawing doesn't actually have a fixed size (as you may have noticed, you can easily draw far outside the map border with the basic tools. So the size you see in this dialog is just the current extents of the entities in your map. Finding the extents is basically just walk the list of entities and grab all the coordinates there and just pick out the biggest and smallest ones, these will describe your extent.
As for the pixel size, CC3+ doesn't care about pixels at all. The value you refer to is just whatever value you happened to put into the export dialog the last time you used it, but it has nothing at all to do with the current map. And any CC3+ map can be exported to any pixel size, so to calculate in relation to the export size you must know what resolution the user intends to export in. Now, usually, when you export battle maps for VTT use, you would use whatever number of pixels per map square as that particular VTT system prefer. I don't know what foundry want, and it probably can use different values, but that is the value you want, not whatever is stored in the CC3+ dialog. And there is really no way for CC3+ to tell you this since it doesn't work in pixel space. But you could assume some standard pixels/square, for example if you plan on exporting the map as 100 pixels per 5' square, that relates to 20 pixels per map unit.
Thanks! I tinkered with using a few different entity sheets to figure out the real extent of the map but nothing really worked with all of the example maps I used in testing. I decided to go another way and just have the user select a bounding box and then use that to derive the other data I need. The side benefit of this approach is that it also works for custom crops - the user can export any section of the map they want, and as long as they keep snap to grid on, they'll maintain the proper scale between the walls and the grid.
Version 0.0.1 is ready on github - it works for basic export into Foundry, as long as there are no curved walls. It also doesn't do doors yet. A lot of work still to do!