Custom Grain Import
Beyond the standard grain shapes, BurnSim 4's Custom grain type lets you build a cross-section that doesn't fit any of them - sketched directly in BurnSim, or imported from a drawing. Select grain type Custom in the Grain Editor to reveal four buttons:
- Edit shape... - opens BurnSim's own shape editor, where you build the cross-section as a list of features (holes and/or slots cut into a circular or polygonal outer boundary) rather than by drawing points. See Sketching a Shape below.
- Import DXF... - reads a cross-section from an AutoCAD DXF file
- Import SVG... - reads a cross-section from an SVG (vector drawing) file
- Import Image... - traces a cross-section from a raster image (PNG/JPEG/BMP) of a drawing, scan, or photo
Whichever way a shape is built, it's simulated through the same pixel-based eroder as every other grain type - a custom cross-section erodes and reports Kn exactly as faithfully as a BATES or star grain does.
Sketching a Shape
The shape editor builds a cross-section as an outer boundary (a circle or a regular polygon) with features cut into it - any number of hole arrays or slot arrays, each an evenly-spaced ring of copies around the axis. A live preview shows the actual bitmap the simulation would rasterize, and features can be dragged directly in the preview as well as edited numerically. The editor also reports diagnostics (thin ledges, features that nearly touch, etc.) a few hundred milliseconds after each edit, and can export the shape currently on screen straight to a DXF file - useful for taking a shape built in BurnSim out to a CAD program, or for round-tripping through it as a template for hand-editing.
Importing a Drawing
All three import formats answer the same two questions the same way, so the identical drawing produces the identical grain no matter which format it's expressed in:
- Propellant vs. void is decided by nesting: the outermost loop is propellant, a loop inside it is a void (a hole or slot), a loop inside that is an island of propellant again, and so on. There's nothing to mark or label - it's exactly how a "profile with pockets" already reads in any CAD or drawing tool. A plain BATES-style grain, for example, is just two circles - one big one for the outer wall, one smaller one inside it for the core. Nothing tells BurnSim which is which; the nesting does that automatically.
- Where the axis is - every import is automatically centred on the smallest circle enclosing the whole drawing (not its bounding box, which can overstate a shape's true extent). You don't need to draw the shape centred at the origin yourself.
Loops are allowed to touch. A spoked "wagon-wheel" core - where each spoke runs all the way from an outer hub to the bore, so there's no gap between them - is drawn exactly as it looks: the bore as one loop, each spoke as another loop whose inner edge sits exactly on the bore's circle. BurnSim handles this correctly (it doesn't misread the touching edge as "the spoke is outside the bore" or vice versa), so there's no need to leave an artificial sliver of a gap to force the loops apart.
The suggested grain diameter is set to that enclosing circle's diameter, but only when the grain's current diameter is blank or too small to contain the import - a larger existing diameter is left alone, since an imported shape can legitimately sit smaller than the grain around it.
DXF
Reads an ASCII DXF (re-export as "ASCII DXF" or "R12 ASCII" if your CAD program saved a binary one). Supported entities: LINE, CIRCLE, ARC, LWPOLYLINE and POLYLINE (including bulged/arced segments) - a drawing's outline is very often many of these meeting at their endpoints, and BurnSim chains them into closed loops automatically, bridging gaps narrower than one simulation pixel. SPLINE and ELLIPSE aren't read directly; convert them to polylines or arcs in your CAD program first.
Units come from the file's own $INSUNITS header field (inches, feet, mm, cm, or m). A DXF with no declared units is read as inches, and one with an unrecognized unit is also read as inches - both cases surface a warning so a drawing that's actually in millimetres (and would otherwise come in about 25x too large) doesn't go unnoticed.
SVG
Reads standard vector shapes: <circle>, <ellipse>, <rect> (including rounded corners), <polygon>, <polyline>, and <path> (the full M/L/H/V/C/S/Q/T/A/Z path syntax, absolute and relative), including nested <g> groups and transform attributes (translate/scale/rotate/skew/matrix). <use>/<symbol> references, <text>, embedded raster <image> elements, and CSS-driven styling aren't read - convert those to plain paths in your drawing program first.
Units come from the SVG's viewBox and width attributes (inches, cm, mm, pt, pc, or px all recognized); with neither declared, the SVG/CSS default of 96 pixels per inch is assumed, with a warning.
Raster Image (PNG/JPEG/BMP)
The least precise of the three, for when there's no vector source at all - a hand sketch, a scan, a photo of a paper template. BurnSim thresholds the image to ink/background and traces the boundary (marching squares), then simplifies the result to remove the pixel-grid staircase. Unlike DXF/SVG, a bitmap carries no scale or meaning of its own, so two things have to be entered by hand in the options dialog that appears before the trace runs:
- Width (inches) - the physical width the image spans in real life. Required; there's nothing in a bitmap to infer it from.
- Threshold - how dark a pixel has to be (0-255) to count as "ink" to trace. 128 (the default) suits a clean black-line-on-white drawing; lower it for a noisy scan whose background isn't quite white, raise it for faint lines. Invert flips this for a light-line-on-dark-background image.
Examples
These are complete, minimal files - save the text as-is (matching extension) and import it directly to see how the nesting rule plays out, or use them as a starting point for your own shape.
BATES-equivalent (two circles)
The simplest possible import: one circle for the 1.2in outer wall, one smaller circle for a 0.5in core. This produces the same grain as picking grain type BATES with those dimensions - it's a good first file to test the import path itself with, before drawing anything more complex.
SVG (open text-edit this by hand, no drawing program needed):
<svg xmlns="http://www.w3.org/2000/svg" width="1.2in" height="1.2in" viewBox="-0.6 -0.6 1.2 1.2"> <circle cx="0" cy="0" r="0.6" /> <circle cx="0" cy="0" r="0.25" /> </svg>
DXF (ASCII/R12, $INSUNITS=1 declares inches):
0 SECTION 2 HEADER 9 $INSUNITS 70 1 0 ENDSEC 0 SECTION 2 ENTITIES 0 CIRCLE 8 0 10 0.0 20 0.0 40 0.6 0 CIRCLE 8 0 10 0.0 20 0.0 40 0.25 0 ENDSEC 0 EOF
Star-shaped core
A circular outer wall (propellant) with a 5-pointed star cut into it as the core (void) - the same idea as grain type Star Grain, but built by hand to show a non-circular void nested inside a circular boundary. Outer wall radius 0.4in, star points reaching to radius 0.4in with 0.18in between points:
<svg xmlns="http://www.w3.org/2000/svg" width="1in" height="1in" viewBox="-0.5 -0.5 1 1">
<circle cx="0" cy="0" r="0.4" />
<polygon points="
0,-0.4 0.1058,-0.1456 0.3804,-0.1236 0.1712,0.0556 0.2351,0.3236
0,0.18 -0.2351,0.3236 -0.1712,0.0556 -0.3804,-0.1236 -0.1058,-0.1456" />
</svg>
Note there are only two contours here (the outer circle and the star polygon) - the star's points don't need to be drawn as separate shapes, because they're all one loop.
Troubleshooting
Each importer reports failures in terms of what to fix in the source drawing rather than a generic error:
- "No usable geometry found" - the file has none of the supported element/entity types above; check for a drawing made entirely of the unsupported ones (SPLINE, `<use>`, etc.)
- "...has geometry but no closed outline" (DXF) - the outline has loose ends; some segments don't quite meet. Join them into a single polyline in your CAD program, or check for gaps at corners.
- "This is a binary DXF" - re-export as ASCII/R12 ASCII DXF.
- "This does not look like an SVG file" - the file isn't well-formed XML, or has no `<svg>` root element.
Tools for Creating Import Files
You don't need paid CAD software to build or experiment with import files:
- SVG - Inkscape (free, open source) is the easiest way to draw a cross-section by hand: draw closed shapes with the pen/shape tools and use File → Save As → "Plain SVG". SVG is also plain-text XML, so for a quick test you can skip the drawing program entirely and hand-edit a file like the examples above in any text editor.
- DXF - Inkscape can export DXF too (File → Save As → "Desktop Cutting Plotter (AutoCAD DXF R14)"). For a tool built around DXF specifically, LibreCAD (free, open source) is a real 2D CAD package and a good way to test unit handling ($INSUNITS) against a proper CAD export.
- Raster - any image editor works; Windows' built-in Paint is enough. Draw a black shape on a white background and save as PNG or BMP to test the threshold/invert options.