Miscellaneous methods
iterator()
Syntax
cadlib.iterator(shape, shapeType);
Parameters
Name | Type | Description |
---|---|---|
shape | object | A shape can be one of Solid, Face, Wire or Shell |
shape | string | Type of the shape. All uppercase. SOLID, FACE, EDGE or SHELL |
Returns
iterator - An iterator
Example
let ite = cadlib.iterator(someShape, "FACE");
while( ite.more) {
ite.next();
let offsetShape = ite.current;
}
toRadian()
Converts angle in degrees to radians.
Syntax
cadlib.toRadian(angleInDegree);
Parameters
Name | Type | Description |
---|---|---|
angleInDegree | Number | Angle value |
Returns
Number - angle in radians
toDegree()
Converts angle in degrees to radians.
Syntax
cadlib.toDegree(angleInRadians);
Parameters
Name | Type | Description |
---|---|---|
angleInRadians | Number | Angle value |
Returns
Number - angle in degrees
makeShell()
Creates a shell consisting of specified faces. Minium one face is required. The shell will be considered closed only if the faces form a closed volume.
If you are trying to create a closed shell, refer to sewShapes method.
Syntax
cadlib.makeShell(faces, options);
Parameters
Name | Type | Description |
---|---|---|
faces | Array | Array of Face objects |
options | Object | {tolerance}. Default tolerance value is 1.0e-06 |
Returns
point()
Creates a Point using X, Y and Z coordinates. This is not of type Vector3.
Syntax
cadlib.point();
Parameters
Name | Type | Description |
---|---|---|
x | Number | X coordinate |
y | Number | Y coordinate |
z | Number | Z coordinate |
Returns
Object - A vanilla javascript object with three properties
extrudeText()
Extrudes a text using specified options. You can use combination of letters, numbers, special characters like ~, # etc.
Following fonts are currently supported
Syntax
cadlib.extrudeText(textToExtrude, options);
Parameters
Options
Name | Type | Description |
---|---|---|
textToExtrude | String | UTF-8 character string, no spaces |
options | Object | options object |
options = {
fontName: string // One of the font name, exactly as shown, in the list above
size: number // Size of the font. This is not font size in pixels or in rm/rem units. So please experiment with this value.
height: number // Extrusion height
}
Returns
divideShapeByArea()
Divides a solid, shell or a face by given area.
Syntax
cadlib.divideShapeByArea(options);
Parameters
Options Object:
Name | Type | Description |
---|---|---|
shape | Solid, Shell or Face | Object to divide |
maxArea | Number | Default:100, Use a +ve number |
Returns
Solid | Face | Shell | null - This method will return null value if given object can’t be divided by specified area.
divideClosedFaces()
Divides closed faces into patches. Cuts determin number of U and V segments produced.
Syntax
cadlib.divideClosedFaces(options);
Parameters
Options object -
Name | Type | Description |
---|---|---|
shape | Shape | Object to divide. Should be one of Solid, Shell or Face type object |
cuts | Number | Default:10, Use a +ve number |
Returns
Solid | shell | Face | null - If shape can’t be divided a null value is returned.
replaceShape()
Replaces a sub-shape within an initial-shape with a new one. New shape needs to have same geometrical parameterization and the old shape Can be used to replace face, wire, edge or vertex
Syntax
cadlib.replaceShape(options);
Parameters
Options object
Name | Type | Description |
---|---|---|
initialShape | Shape | Shape can be one of - Solid |
oldShape | Shape | Shape that is going to be replaced. It can be either face, edge, vertex |
newShape | Shape | Replacement shape. It can be either face, edge, vertex |
Returns
Solid | Shell | Compound | null - A null value is returned if operation fails
makeSubdShape()
Coming Soon!!