diff --git a/maker.js/makerjs-tests.ts b/maker.js/makerjs-tests.ts index 4b6b5f80e..e314f0966 100644 --- a/maker.js/makerjs-tests.ts +++ b/maker.js/makerjs-tests.ts @@ -42,7 +42,19 @@ function test() { makerjs.exporter.toDXF(model); makerjs.exporter.toOpenJsCad(model); makerjs.exporter.toSTL(model); - makerjs.exporter.toSVG(model); + makerjs.exporter.toSVG(model, + { + annotate: true, + fontSize: '', + origin: [], + scale: 9.9, + stroke: '', + strokeWidth: '', + svgAttrs: {}, + units: '', + useSvgPathOnly: false, + viewBox: false + }); makerjs.exporter.tryGetModelUnits(model); } @@ -51,6 +63,7 @@ function test() { makerjs.kit.getParameterValues(null); ({}).max; ({}).metaParameters; + ({}).notes; } function testMeasure() { @@ -83,6 +96,7 @@ function test() { makerjs.model.rotate(makerjs.model.scale(model, 6), 45, [0,0]); makerjs.model.scale(model, 7); makerjs.model.walkPaths(model, (modelContext: MakerJs.IModel, pathId: string, pathContext: MakerJs.IPath) => {}); + model.exporterOptions = { foo: 'bar' }; } function testModels(): MakerJs.IModel[] { diff --git a/maker.js/makerjs.d.ts b/maker.js/makerjs.d.ts index cb217adb4..b45a1ceff 100644 --- a/maker.js/makerjs.d.ts +++ b/maker.js/makerjs.d.ts @@ -345,6 +345,12 @@ declare module MakerJs { * Optional layer of this model. */ layer?: string; + /** + * Optional exporter options for this model. + */ + exporterOptions?: { + [exporterName: string]: any; + }; } /** * Callback signature for model.walkPaths(). @@ -412,6 +418,10 @@ declare module MakerJs { * Each element of the array corresponds to a parameter of the constructor, in order. */ metaParameters?: IMetaParameter[]; + /** + * Information about this kit, in plain text or markdown format. + */ + notes?: string; } } declare module MakerJs.angle { @@ -1225,12 +1235,36 @@ declare module MakerJs.exporter { * Optional size of curve facets. */ facetSize?: number; + /** + * Optional override of function name, default is "main". + */ + functionName?: string; + /** + * Optional options applied to specific first-child models by model id. + */ + modelMap?: IOpenJsCadOptionsMap; + } + interface IOpenJsCadOptionsMap { + [modelId: string]: IOpenJsCadOptions; } } declare module MakerJs.exporter { function toSVG(modelToExport: IModel, options?: ISVGRenderOptions): string; function toSVG(pathsToExport: IPath[], options?: ISVGRenderOptions): string; function toSVG(pathToExport: IPath, options?: ISVGRenderOptions): string; + /** + * Map of MakerJs unit system to SVG unit system + */ + interface svgUnitConversion { + [unitType: string]: { + svgUnitType: string; + scaleConversion: number; + }; + } + /** + * Map of MakerJs unit system to SVG unit system + */ + var svgUnit: svgUnitConversion; /** * SVG rendering options. */ @@ -1239,6 +1273,10 @@ declare module MakerJs.exporter { * Optional attributes to add to the root svg tag. */ svgAttrs?: IXmlTagAttrs; + /** + * SVG font size and font size units. + */ + fontSize?: string; /** * SVG stroke width of paths. This may have a unit type suffix, if not, the value will be in the same unit system as the units property. */ @@ -1246,27 +1284,27 @@ declare module MakerJs.exporter { /** * SVG color of the rendered paths. */ - stroke: string; + stroke?: string; /** * Scale of the SVG rendering. */ - scale: number; + scale?: number; /** * Indicate that the id's of paths should be rendered as SVG text elements. */ - annotate: boolean; + annotate?: boolean; /** * Rendered reference origin. */ - origin: IPoint; + origin?: IPoint; /** * Use SVG < path > elements instead of < line >, < circle > etc. */ - useSvgPathOnly: boolean; + useSvgPathOnly?: boolean; /** * Flag to use SVG viewbox. */ - viewBox: boolean; + viewBox?: boolean; } } declare module MakerJs.models {