Drawing2d
dimension(param)
Creates one or multiple dimensions in the product. The dimensions will be visible after creating and exporting the views to svg or dxf.
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: id|VOID|Array<id|VOID> // one or multiple ids of the created dimensions
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Default | Description |
---|---|---|---|
param | object | Array<object> | object or objects containing the parameters | |
param.id | string | real | id | id of the product to create the dimension in | |
param.viewType | "TOP" | "FRONT" | "RIGHT" | "LEFT" | "BOTTOM" | "RIGHT_90" | "LEFT_90" | "BACK" | "ISO" | type of the view where the dimension will be visible later in the dxf file | |
param.common | object | object containing the common parameters | |
param.common.type | "LINEAR" | "ANGULAR" | "RADIAL" | "DIAMETER" | type of the dimension | |
[param.common.name] | string | "Dimension" | name of the dimension |
[param.common.label] | string | label for the dimension text, this will appear in the 2d view next to the dimension e.g. "width = " | |
[param.common.value] | string | real | value for the dimension text which will be concatenated with the label, if empty the value will be calculated automatically strings: - If a string is provided, "<>" can be used as a placeholder which will be replaced by the current value. - In angular dimensions, "<>" will be replaced by an angle value in degrees and °, e.g. "60°" - In radial dimensions, "<>" will be replaced by R and the radius value, e.g. "R60" - In diameter dimensions, "<>" will be replaced by Ø and the diameter value, e.g. "Ø120" special symbols: - "%%d" will be replaced by °. - "%%c" will be replaced by Ø | |
[param.common.color] | real | 256 | color of the dimension (autocad color index) in range of [0,256], whereas 256 means the color will be taken from the defined layer in the dxf template |
[param.common.layer] | string | "1" | layer where the dimension will appear, e.g. "1", depends on layer definitions in dxf template |
param.common.textPos | point | position where the dimension text (combination of label and value) will be placed | |
[param.linear] | object | object containing the parameters for a linear dimension | |
param.linear.startPos | point | position of the start of the linear dimension | |
param.linear.endPos | point | position of the end of the linear dimension | |
[param.linear.textAngle] | real | If not set, it is calculated depending on orientation, which is OK for most cases. If angle (in radians) is set, it defines the dimension line orientation measured counter clockwise from the x-axis. | |
param.linear.orientation | "VERTICAL" | "HORIZONTAL" | "ALIGNED" | orientation of the linear dimension | |
[param.angular] | object | object containing the parameters for an angular dimension | |
param.angular.startPos | point | position of the start of the angular dimension | |
param.angular.endPos | point | position of the end of the angular dimension | |
param.angular.cornerPos | point | position of the corner of the angular dimension | |
[param.angular.isCCW] | boolean | TRUE | if true the orientation is counter clockwise (ccw) (default=TRUE) |
[param.radial] | object | object containing the parameters for a radial dimension | |
param.radial.centerPos | point | position of the center of the radial dimension | |
param.radial.radius | real | radius of the radial dimension | |
[param.diameter] | object | object containing the parameters for a diameter dimension | |
param.diameter.centerPos | point | position of the center of the diameter dimension | |
param.diameter.radius | real | radius of the diameter dimension |
Example
res = api.v1.drawing2d.dimension({ id: 796, type: 'HORIZONTAL', geomIds: [startPt, endPt] })
centerView(param)
This method centers all given views to origin, depending on each view's boundary box. This can be useful after creating the views and before placing them
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: VOID
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Description |
---|---|---|
param | object | object containing the parameters |
param.id | string | real | id | id of the product to center the views from |
param.types | Array<("TOP"|"FRONT"|"RIGHT"|"LEFT"|"BOTTOM"|"RIGHT_90"|"LEFT_90"|"BACK"|"ISO")> | type of views to center, if empty all views will be centered |
Example
res = api.v1.drawing2d.centerView({ id: 796, types: ['TOP', 'ISO'] })
view(param)
Creates the defined 2d views of the given product (solids) in xy-plane and returns the ids of the created views. Previously created dimensions will appear in the defined views (depends on type), e.g. a dimension with viewType = "TOP", will appear in the "TOP" view
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: id|Array<id> // one or multiple ids of the newly created views
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Default | Description |
---|---|---|---|
param | object | object containing the parameters | |
param.id | string | real | id | id of the product to create views of | |
param.types | Array<("TOP"|"FRONT"|"RIGHT"|"LEFT"|"BOTTOM"|"RIGHT_90"|"LEFT_90"|"BACK"|"ISO")> | type of views to create | |
[param.color] | real | 0 | color of the view (autocad color index) in range of [0,256], whereas 256 means the color will be taken from the defined layer in the dxf template |
[param.layer] | string | "0" | layer where the view will appear later in the dxf export, it depends on layer definitions in dxf template |
Example
res = api.v1.drawing2d.view({ id: 796, types: ['RIGHT', 'BOTTOM'], color: 125, layer: '5' })
exportDXF(param)
Exports all the views from given product into dxf. By default the model is written to a data string.
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: {
success: boolean,
content?: string // content is the data string of the export and is only available if neither file nor url is defined.
}
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Description |
---|---|---|
param | object | object containing the parameters |
param.id | string | real | id | id of the product to export the views from |
[param.file] | string | full path of the file. Path has to be a for the ClassCAD process reachable local or UNC path. |
[param.url] | string | url to send the model data to. |
[param.encoding] | "base64" | the encoding the data will be encoded with. If compression is also set, the decoding happens after compression! |
[param.compression] | "deflate" | the compression algorithm the data is compressed with. |
Example
res = api.v1.drawing2d.exportDXF({ id: 796, file: '/var/models/file.dxf' })
res = api.v1.drawing2d.exportDXF({
id: 796,
file: '/var/models/file.dxf',
dxfTemplateFile: '/templates/StandardTemplate.dxf',
})
res = api.v1.drawing2d.exportDXF({ id: 796, compression: 'deflate', encoding: 'base64' })
exportSVG(param)
Exports all the views from given product into svg. By default the model is written to a data string.
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: {
success: boolean,
content?: string // content is the data string of the export and is only available if neither file nor url is defined.
}
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Description |
---|---|---|
param | object | object containing the parameters |
param.id | string | real | id | id of the product to export the views from |
[param.file] | string | full path of the file. Path has to be a for the ClassCAD process reachable local or UNC path. |
[param.url] | string | url to send the model data to. |
[param.encoding] | "base64" | the encoding the data will be encoded with. If compression is also set, the decoding happens after compression! |
[param.compression] | "deflate" | the compression algorithm the data is compressed with. |
[param.modus] | "SVG_WHOLE_DRAWING" | "SVG_FIT_WHOLE_DRAWING" | modus to define how drawing will fit into svg file |
[param.renderSize] | object | object containing the render size of the drawing (default=1024x768) |
param.renderSize.x | real | horizontal size of the drawing |
param.renderSize.y | real | vertical size of the drawing |
Example
res = api.v1.drawing2d.exportSVG({ id: 796, file: '/var/models/file.svg' })
res = api.v1.drawing2d.exportSVG({ id: 796, compression: 'deflate', encoding: 'base64' })
getBoundaryBoxFromView(param)
This method returns min and max point for each given view.
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: Array<{ min: point, max: point }> | VOID // array of objects containing the min and max point
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Description |
---|---|---|
param | object | object containing the parameters |
param.id | string | real | id | id of the product to get boundary boxes of the views from |
param.types | Array<("TOP"|"FRONT"|"RIGHT"|"LEFT"|"BOTTOM"|"RIGHT_90"|"LEFT_90"|"BACK"|"ISO")> | type of views to get boundary box from, if empty, boundary boxes of all existing views will be returned |
Example
res = api.v1.drawing2d.getBoundaryBoxFromView({ id: 796, types: ['LEFT'] })
placeView(param)
Places each view relatively to its current position in xy-plane
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: VOID
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Description |
---|---|---|
param | object | object containing the parameters |
param.id | string | real | id | id of the product to place the views |
param.placements | Array<object> | objects containing the placement information |
param.placements[].type | "TOP" | "FRONT" | "RIGHT" | "LEFT" | "BOTTOM" | "RIGHT_90" | "LEFT_90" | "BACK" | "ISO" | type of view to place by offset vector |
param.placements[].offset | point | offset vector to move view relatively to its current position |
Example
res = api.v1.drawing2d.placeView({ id: 796, placements: [{ type: 'TOP', offset: [0, 150, 0] }] })
deleteDimension(param)
Deletes one or multiple dimensions
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: VOID
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Description |
---|---|---|
param | object | object containing all the parameters |
param.ids | Array<(string|real|id)> | ids of the dimensions to remove |
Example
res = api.v1.drawing2d.deleteDimension({ ids: [58, 96] })
updateDimensionPosition(param)
Updates the position of the dimension text. Attention: The view needs to be recreated to have updated positions in the view
Kind: v1.drawing2d function
Returns: object
- object containing result and optional messages
{
result: VOID
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Description |
---|---|---|
param | object | object containing all the parameters |
param.id | string | real | id | id of the dimension to change the text position |
param.pos | point | position of the dimension text to update |
Example
res = api.v1.drawing2d.updateDimensionPosition({ id: 796, pos: [50, 60, 0] })