Api - model Namespace
Index
Functions
- add
Caption - add
Model - add
Path - add
To - break
Paths AtIntersections - center
- clone
- combine
- combine
Intersection - combine
Subtraction - combine
Union - convert
Units - count
Child Models - distort
- expand
Paths - find
Chains - find
Single Chain - get
All Captions Offset - get
Similar Model Id - get
Similar Path Id - is
Path Inside Model - layer
- mirror
- move
- move
Relative - originate
- outline
- prefix
Path Ids - remove
Dead Ends - rotate
- scale
- simplify
- walk
- walk
Paths - zero
Functions
addCaption
addModel
-
Add a model as a child. This is basically equivalent to:
parentModel.models[childModelId] = childModel;
with additional checks to make it safe for cascading.
Parameters
-
parentModel: IModel
The model to add to.
-
childModel: IModel
The model to add.
-
childModelId: string
The id of the child model.
-
Default value overWrite: boolean = false
Optional flag to overwrite any model referenced by childModelId. Default is false, which will create an id similar to childModelId.
Returns IModel
The original model (for cascading).
-
addPath
-
Add a path as a child. This is basically equivalent to:
parentModel.paths[childPathId] = childPath;
with additional checks to make it safe for cascading.
Parameters
-
modelContext: IModel
The model to add to.
-
pathContext: IPath
The path to add.
-
pathId: string
The id of the path.
-
Default value overWrite: boolean = false
Optional flag to overwrite any path referenced by pathId. Default is false, which will create an id similar to pathId.
Returns IModel
The original model (for cascading).
-
addTo
-
Add a model as a child of another model. This is basically equivalent to:
parentModel.models[childModelId] = childModel;
with additional checks to make it safe for cascading.
Parameters
-
childModel: IModel
The model to add.
-
parentModel: IModel
The model to add to.
-
childModelId: string
The id of the child model.
-
Default value overWrite: boolean = false
Optional flag to overwrite any model referenced by childModelId. Default is false, which will create an id similar to childModelId.
Returns IModel
The original model (for cascading).
-
breakPathsAtIntersections
-
DEPRECATED Break a model's paths everywhere they intersect with another path.
Parameters
-
modelToBreak: IModel
The model containing paths to be broken.
-
Optional modelToIntersect: IModel
Optional model containing paths to look for intersection, or else the modelToBreak will be used.
Returns IModel
The original model (for cascading).
-
center
-
Center a model at [0, 0].
Parameters
-
modelToCenter: IModel
The model to center.
-
Default value centerX: boolean = true
Boolean to center on the x axis. Default is true.
-
Default value centerY: boolean = true
Boolean to center on the y axis. Default is true.
Returns IModel
The original model (for cascading).
-
clone
combine
-
Combine 2 models. Each model will be modified accordingly.
Parameters
-
modelA: IModel
First model to combine.
-
modelB: IModel
Second model to combine.
-
Default value includeAInsideB: boolean = false
Flag to include paths from modelA which are inside of modelB.
-
Default value includeAOutsideB: boolean = true
Flag to include paths from modelA which are outside of modelB.
-
Default value includeBInsideA: boolean = false
Flag to include paths from modelB which are inside of modelA.
-
Default value includeBOutsideA: boolean = true
Flag to include paths from modelB which are outside of modelA.
-
Optional options: ICombineOptions
Optional ICombineOptions object.
Returns IModel
A new model containing both of the input models as "a" and "b".
-
combineIntersection
combineSubtraction
combineUnion
convertUnits
countChildModels
-
Count the number of child models within a given model.
Parameters
-
modelContext: IModel
The model containing other models.
Returns number
Number of child models.
-
distort
-
Create a distorted copy of a model - scale x and y individually.
Parameters
-
modelToDistort: IModel
The model to distort.
-
scaleX: number
The amount of x scaling.
-
scaleY: number
The amount of y scaling.
-
Default value scaleOrigin: boolean = false
Optional boolean to scale the origin point. Typically false for the root model.
-
Optional bezierAccuracy: number
Optional accuracy of Bezier curves.
Returns IModel
New model (for cascading).
-
expandPaths
-
Expand all paths in a model, then combine the resulting expansions.
Parameters
-
modelToExpand: IModel
Model to expand.
-
distance: number
Distance to expand.
-
Default value joints: number = 0
Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.
-
Default value combineOptions: ICombineOptions = {}
Optional object containing combine options.
Returns IModel
Model which surrounds the paths of the original model.
-
findChains
-
Find paths that have common endpoints and form chains.
Parameters
-
modelContext: IModel
The model to search for chains.
-
Optional options: IFindChainsOptions
Optional options object.
Returns IChain[] | IChainsMap
An array of chains, or a map (keyed by layer id) of arrays of chains - if options.byLayers is true.
-
-
Find paths that have common endpoints and form chains.
Parameters
-
modelContext: IModel
The model to search for chains.
-
callback: IChainCallback
Callback function when chains are found.
-
Optional options: IFindChainsOptions
Optional options object.
Returns IChain[] | IChainsMap
An array of chains, or a map (keyed by layer id) of arrays of chains - if options.byLayers is true.
-
findSingleChain
getAllCaptionsOffset
-
Gets all Caption objects, in absolute position, in this model and its children.
Parameters
-
modelContext: IModel
The model to search for Caption objects.
Returns (ICaption & object)[]
Array of Caption objects.
-
getSimilarModelId
-
Get an unused id in the models map with the same prefix.
Parameters
-
modelContext: IModel
The model containing the models map.
-
modelId: string
The id to use directly (if unused), or as a prefix.
Returns string
-
getSimilarPathId
-
Get an unused id in the paths map with the same prefix.
Parameters
-
modelContext: IModel
The model containing the paths map.
-
pathId: string
The id to use directly (if unused), or as a prefix.
Returns string
-
isPathInsideModel
-
DEPRECATED - use measure.isPointInsideModel instead. Check to see if a path is inside of a model.
Parameters
-
pathContext: IPath
The path to check.
-
modelContext: IModel
The model to check against.
-
Optional pathOffset: IPoint
-
Optional farPoint: IPoint
Optional point of reference which is outside the bounds of the modelContext.
-
Optional measureAtlas: Atlas
Returns boolean
Boolean true if the path is inside of the modelContext.
-
layer
mirror
move
moveRelative
originate
-
Moves all of a model's children (models and paths, recursively) in reference to a single common origin. Useful when points between children need to connect to each other.
Parameters
-
modelToOriginate: IModel
The model to originate.
-
Optional origin: IPoint
Optional offset reference point.
Returns IModel
The original model (for cascading).
-
outline
-
Outline a model by a specified distance. Useful for accommodating for kerf.
Parameters
-
modelToOutline: IModel
Model to outline.
-
distance: number
Distance to outline.
-
Default value joints: number = 0
Number of points at a joint between paths. Use 0 for round joints, 1 for pointed joints, 2 for beveled joints.
-
Default value inside: boolean = false
Optional boolean to draw lines inside the model instead of outside.
-
Default value options: ICombineOptions = {}
Options to send to combine() function.
Returns IModel
Model which surrounds the paths outside of the original model.
-
prefixPathIds
removeDeadEnds
-
Remove paths from a model which have endpoints that do not connect to other paths.
Parameters
-
modelContext: IModel
The model to search for dead ends.
-
Optional pointMatchingDistance: number
Optional max distance to consider two points as the same.
-
Optional keep: IWalkPathBooleanCallback
Optional callback function (which should return a boolean) to decide if a dead end path should be kept instead.
-
Optional trackDeleted: function
Optional callback function which will log discarded paths and the reason they were discarded.
-
-
Parameters
-
wp: IWalkPath
-
reason: string
Returns void
-
-
-
Returns IModel
The input model (for cascading).
-
rotate
scale
simplify
-
Simplify a model's paths by reducing redundancy: combine multiple overlapping paths into a single path. The model must be originated.
Parameters
-
modelToSimplify: IModel
-
Optional options: ISimplifyOptions
Optional options object.
Returns IModel
The simplified model (for cascading).
-
walk
-
Recursively walk through all child models and paths for a given model.
Parameters
-
modelContext: IModel
The model to walk.
-
options: IWalkOptions
Object containing callbacks.
Returns IModel
The original model (for cascading).
-
walkPaths
-
DEPRECATED - use model.walk instead. Recursively walk through all paths for a given model.
Parameters
-
modelContext: IModel
The model to walk.
-
callback: IModelPathCallback
Callback for each path.
Returns void
-
zero
-
Move a model so its bounding box begins at [0, 0].
Parameters
-
modelToZero: IModel
The model to zero.
-
Default value zeroX: boolean = true
Boolean to zero on the x axis. Default is true.
-
Default value zeroY: boolean = true
Boolean to zero on the y axis. Default is true.
Returns IModel
The original model (for cascading).
-
Generated using TypeDoc
Add a Caption object to a model.