bsPolylineIterator

An iterator for polylines. The iterator allows access to polyline attributes as well as access to attributes and coordinates of individual polyline points.

Integer nPolyClosed

Option “closed” for polyline mode. E.g. an outer or inner polygon of a part layer-section. The polygon can contain an arbitrary number of points where each point is the start of an edge vector. The last point defines an edge vector with the first point so that the polygon is always closed.

Integer nPolyOpen

Option “open” for polyline mode. The polyline can contain an arbitrary number of points where each point (except the last point) is the start of an edge vector. The last point is the end point of the last edge vector. The polyline can be geometrically closed if the last point is equal to the first point. But nevertheless the polyline is ‘logically’ open.

Integer nPolyHatch

Option “hatch” for polyline mode. A list of independent edge vectors where each edge has its own start and end point. Therefore the number of points is always a multiple of 2. E.g. p1Start, p1End, p2Start, p2End

Integer nPolyModeInvalid

Option “invalid” for polyline mode.

Integer nIslandBorderPolygons

Iterate over the border polygons of an island.

Integer nLayerOpenPolylines

Iterate over open polylines of a layer.

Integer nLayerExposure

Iterate over a layer’s exposure polylines.

Integer nLayerExposureInProcessingOrder

Iterate over a layer’s exposure polylines. The iterator will follow the intended processing order of the exposure toolpaths. This order can be controlled by setting the attribute ‘_processing_order’ in a bsPolyline or bsHatch to an ascending integer sort key.

Object bsPolylineIterator.clone()

Creates a new instance which is a copy of this iterator.

Return

A new bsPolylineIterator object

Array bsPolylineIterator.getAllAttributes()

Creating an array of all attributes which are stored in the current polyline. Each attribute has the member ‘uid’ which is the unique identifier of the attribute. The second member contains the attribute value. Its name depends on the type of the attribute (int, real). The value member name is ‘intValue’ for an integer attribute and ‘fltValue’ for a real attribute.

Return

Array of Attributes

Integer bsPolylineIterator.getAttributeInt(sId)

Queries the value of an integer attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes. If the attribute is not available then the return value is 0.

Arguments

Return

Attribute value. If the attribute is not available then the return value is 0.

Integer bsPolylineIterator.getAttributeIntExt(sId)

Queries the value of an integer attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes. If the attribute is not available then the undefined value is returned.

Arguments

Return

Attribute value. If the attribute is not available then the undefined value is returned.

Number bsPolylineIterator.getAttributeReal(sId)

Queries the value of an integer attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes. If the attribute is not available then the return value is 0.0.

Arguments

Return

Attribute value. If the attribute is not available then the return value is 0.0.

Number bsPolylineIterator.getAttributeRealExt(sId)

Queries the value of an integer attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes. If the attribute is not available then the undefined value is returned.

Arguments

Return

Attribute value. If the attribute is not available then the undefined value is returned.

bsBounds2D bsPolylineIterator.getBounds()

Get bounding box of all polylines.

Return

Bounding box (bsBounds2D).

Integer bsPolylineIterator.getModelIndex()

Queries the part index of the part where the polyline belongs to.

Return

Part index (0 for the first part)

Integer bsPolylineIterator.getModelSubtype()

Queries the part sub-type of the polyline.

Return

Sub-type of the polyline. E.g. nSubtypePart, nSubtypeSupport (see bsModel).

Links: bsModel

Integer bsPolylineIterator.getPointAttributeInt(nPointIndex, sId)

Queries the value of an integer point attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes. If the attribute is not available then the return value is 0.

Arguments

Return

Attribute value. If the attribute is not available then the return value is 0.

Integer bsPolylineIterator.getPointAttributeIntExt(nPointIndex, sId)

Queries the value of an integer point attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes. If the attribute is not available then the undefined value is returned.

Arguments

Return

Attribute value. If the attribute is not available then the undefined value is returned.

Number bsPolylineIterator.getPointAttributeReal(nPointIndex, sId)

Queries the value of a floating point point attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes. If the attribute is not available then the return value is 0.0.

Arguments

Return

Attribute value. If the attribute is not available then the return value is 0.0.

Number bsPolylineIterator.getPointAttributeRealExt(nPointIndex, sId)

Queries the value of a floating point point attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes. If the attribute is not available then the undefined value is returned.

Arguments

Return

Attribute value. If the attribute is not available then the undefined value is returned.

Integer bsPolylineIterator.getPointCount()

Queries the number of points of the current polyline. Points are accessed by their point index (0..n).

Return

Number of points

Integer bsPolylineIterator.getPolylineMode()

Queries the mode of the current polyline (e.g.: bsPolylineIterator.nPolyClosed , bsPolylineIterator.nPolyOpen , bsPolylineIterator.nPolyHatch , bsPolylineIterator.nPolyModeInvalid).

Return

The polyline mode (bsPolylineIterator.nPolyClosed , bsPolylineIterator.nPolyOpen , bsPolylineIterator.nPolyHatch , bsPolylineIterator.nPolyModeInvalid).

Vec2 bsPolylineIterator.getXYCoord(nIndex)

Queries x and y-coordinate of the polyline point at the given index.

Arguments

Return

Vec2 object.

bool bsPolylineIterator.isInloop()

Checks if current polyline is an inner loop of a layer section of the part.

Return

true if it’s an inner loop. false if it is not an inner loop.

bool bsPolylineIterator.isOutloop()

Checks if current polyline is the outer loop of a layer section of the part.

Return

true if it’s an outer loop. false if it is not an outer loop.

bool bsPolylineIterator.isValid()

Checks if the iterator is valid.

Return

true if the iterator is valid. false if the iterator is invalid.

void bsPolylineIterator.invalidate()

Make the iterator invalid.

bool bsPolylineIterator.next()

Sets the iterator to the next polyline.

Return

true if successful and iterator is still valid. false if the iterator has become invalid.

bsPolylineIterator.polylineToHatch(hatch)

Converts the current polyline to exposure vectors.

Arguments

bsPolylineIterator.setAttributeInt(sId, nValue)

Sets the value of an integer attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes.

Arguments

bsPolylineIterator.setAttributeReal(sId, fValue)

Sets the value of a Real attribute with the unique identifier sId. Attributes must have been declared within declareBuildAttributes.

Arguments

bsPolylineIterator.removeAttributes(sId)

Remove attributes with given ids

Arguments

Return

True if any attributes have been removed

bsPolylineIterator.removePointAttributes(nPointIndex, sId)

Remove attributes with given ids

Arguments

Return

True if any attributes have been removed

Integer bsPolylineIterator.getSkipCount()

Returns the total number of skip vectors. These are the vectors from a segment end to the start of the next segment. If the polyline is not in hatch mode then the result is always zero (see getPolylineMode()).

Return

Total number of skip vectors.

Number bsPolylineIterator.getSkipLength()

Calculates the whole length of all skip vectors in mm. If the polyline is not in hatch mode then the result is always zero (see getPolylineMode()).

Return

Whole length of all skip vectors.

Number bsPolylineIterator.getExposureLength()

Get the length of the polyline. Or In hatch mode the sum of the lengths of all individual segments.

Return

Length

sortPolylinesForMinJumpLength(polylines, args)

Sorting polylines so that the sum of all traveling distances between the polylines are reduced.

var args = {
 "startPos" : {x: 0.0, y: 0.0},
 "bFlip" : true
};

Arguments: