Skip to main content

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
}
ParamTypeDefaultDescription
paramobject | Array<object>object or objects containing the parameters
param.idstring | real | idid 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.commonobjectobject 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]stringlabel for the dimension text, this will appear in the 2d view next to the dimension e.g. "width = "
[param.common.value]string | realvalue 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]real256color 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.textPospointposition where the dimension text (combination of label and value) will be placed
[param.linear]objectobject containing the parameters for a linear dimension
param.linear.startPospointposition of the start of the linear dimension
param.linear.endPospointposition of the end of the linear dimension
[param.linear.textAngle]realIf 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]objectobject containing the parameters for an angular dimension
param.angular.startPospointposition of the start of the angular dimension
param.angular.endPospointposition of the end of the angular dimension
param.angular.cornerPospointposition of the corner of the angular dimension
[param.angular.isCCW]booleanTRUEif true the orientation is counter clockwise (ccw) (default=TRUE)
[param.radial]objectobject containing the parameters for a radial dimension
param.radial.centerPospointposition of the center of the radial dimension
param.radial.radiusrealradius of the radial dimension
[param.diameter]objectobject containing the parameters for a diameter dimension
param.diameter.centerPospointposition of the center of the diameter dimension
param.diameter.radiusrealradius 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
}
ParamTypeDescription
paramobjectobject containing the parameters
param.idstring | real | idid of the product to center the views from
param.typesArray<("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
}
ParamTypeDefaultDescription
paramobjectobject containing the parameters
param.idstring | real | idid of the product to create views of
param.typesArray<("TOP"|"FRONT"|"RIGHT"|"LEFT"|"BOTTOM"|"RIGHT_90"|"LEFT_90"|"BACK"|"ISO")>type of views to create
[param.color]real0color 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
}
ParamTypeDescription
paramobjectobject containing the parameters
param.idstring | real | idid of the product to export the views from
[param.file]stringfull path of the file. Path has to be a for the ClassCAD process reachable local or UNC path.
[param.url]stringurl 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
}
ParamTypeDescription
paramobjectobject containing the parameters
param.idstring | real | idid of the product to export the views from
[param.file]stringfull path of the file. Path has to be a for the ClassCAD process reachable local or UNC path.
[param.url]stringurl 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]objectobject containing the render size of the drawing (default=1024x768)
param.renderSize.xrealhorizontal size of the drawing
param.renderSize.yrealvertical 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
}
ParamTypeDescription
paramobjectobject containing the parameters
param.idstring | real | idid of the product to get boundary boxes of the views from
param.typesArray<("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
}
ParamTypeDescription
paramobjectobject containing the parameters
param.idstring | real | idid of the product to place the views
param.placementsArray<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[].offsetpointoffset 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idsArray<(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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idstring | real | idid of the dimension to change the text position
param.pospointposition of the dimension text to update

Example

res = api.v1.drawing2d.updateDimensionPosition({ id: 796, pos: [50, 60, 0] })