Common
clear([param])
Deletes all objects in the current drawing //TODO: description
Kind: v1.common 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.keepIds] | Array<(string|real|id)> | Ids of the objects to keep in the database. |
Example
res = api.v1.common.clear()
evaluateExpression(param)
Evaluates an expression.
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: real|point|VOID // A real or point value of the evaluated expression, or VOID if expression is incorrect
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Default | Description |
---|---|---|---|
param | object | object containing all the parameters | |
[param.id] | string | real | id | any id which is a child of the root part/assembly like feature id, expression set, ... | |
param.expression | string | expression string to be evaluated | |
[param.silent] | boolean | FALSE | flag to define whether the expression should be evaluated without error message (default=FALSE) |
Example
res = api.v1.common.evaluateExpression({ id: 25, expression: 'sin(C:PI/2)' })
getDatabaseSettings()
Returns the current general settings from the database
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: {
isGraphicEnabled: boolean
isCCGraphicEnabled: boolean
isInvisibleGraphicEnabled: boolean
isSketchGraphicEnabled: boolean
facetingParamsMode: real
chordHeightTol: real
angleTol: real
doCurveTessellation: boolean
}
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Example
res = api.v1.common.getDatabaseSettings()
getFacetingParameters()
Returns the faceting parameters used to tessellate surfaces and curves.
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: { angleTol: real, chordHeightTol: real } // object containing faceting parameters as properties
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Example
res = api.v1.common.getFacetingParameters()
setAppearance(param)
Sets the appearance on the target, which is here defined by an id which is the feature and optional inidices to select specific solids from the feature, if more than one solid is appended.
Kind: v1.common 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 or objects containing the parameters |
param.target | string | real | id | object | target as id of the feature to set appearance on or as object containing an id and optional indices |
param.target.id | string | real | id | id of the feature, to set the appearance on |
[param.target.indices] | Array<real> | if more than one solid is appended to the feature, the indices can be used to select the solids |
[param.color] | object | object containing the rgb values |
param.color.r | real | red value (0-255) of the color |
param.color.g | real | green value (0-255) of the color |
param.color.b | real | blue value (0-255) of the color |
[param.transparency] | real | value of transparency between 0 and 1 |
[param.chordHeightTol] | real | chord height tolerance |
[param.angleTol] | real | angle tolerance |
Example
res = api.v1.common.setAppearance({ target: { id: 25 }, color: { r: 55, g: 69, b: 89 }, transparency: 0.8 })
setDatabaseSettings(param)
Sets the current and initial general settings on the database.
Kind: v1.common 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.isGraphicEnabled] | boolean | flag to define whether graphic will be visible or not |
[param.isCCGraphicEnabled] | boolean | flag to define whether classcad graphic will be visible or not |
[param.isInvisibleGraphicEnabled] | boolean | flag to define whether invisible graphic will tessellated or not. |
[param.isSketchGraphicEnabled] | boolean | to define whether sketch graphic will be visible or not. |
[param.facetingParamsMode] | real | Mode to define which faceting parameters will be used for tessellation. - mode = 0: default parameters will be used - mode = 1: specific parameters of each entity will be used |
[param.chordHeightTol] | real | distance tolerance between geometrical arc and tesselated arc |
[param.angleTol] | real | angle tolerance between two surfaces of tesselation |
[param.doCurveTessellation] | boolean | flag defines if analytic curves (e.g. arc) are tesselated on server (=true) or on client (=false) |
Example
res = api.v1.common.setDatabaseSettings({ chordHeightTol: 0.5 })
setFacetingParameters(param)
Sets the faceting parameters of current drawing.
Kind: v1.common 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.angleTol] | real | angle tolerance between two surfaces of tesselation |
[param.chordHeightTol] | real | distance tolerance between geometrical arc and tesselated arc |
Example
res = api.v1.common.setFacetingParameters({ angleTol: 20 })
transformObjectWithMatrix(param)
Transforms an object with the given matrix.
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: VOID
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Default | Description |
---|---|---|---|
param | object | object containing all the parameters | |
param.id | string | real | id | id of any object to transform | |
param.matrix | Array<Array<real>> | the 4x4 transformation matrix | |
[param.isGlobal] | boolean | TRUE | must be TRUE if the given matrix is in global coords, FALSE else (default=TRUE) |
Example
res = api.v1.common.transformObjectWithMatrix({
id: 58,
matrix: [
[1, 0, 0, 100],
[0, 1, 0, 0],
[0, 0, 1, 0],
[0, 0, 0, 1],
],
})
setObjectCoordSystem(param)
Calls "SetObjectCoordSystem" on object or sets object coord system if function does not exist
Kind: v1.common 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 object to set the new coordinate system on |
param.origin | point | origin of the new coordinate system |
param.xVec | point | x direction of the new coordinate system |
param.yVec | point | y direction of the new coordinate system |
Example
res = api.v1.common.setObjectCoordSystem({ id: 796, origin: [0, 150, 0], xVec: [0, 1, 0], yVec: [0, 0, 1] })
setObjectName(param)
Calls "SetObjectName" on object or sets object name if function does not exist
Kind: v1.common 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 object to set the name on |
param.name | string | name to set for the object |
Example
res = api.v1.common.setObjectName({ id: 796, name: 'Obj_23' })
getClassFileVersion()
Returns the class file version
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: string // class file version
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Example
res = api.v1.common.getClassFileVersion()
getAppVersion()
Returns the app version object containing result and optional messages
{
result: string // app version or empty string if not available
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Kind: v1.common function
Example
res = api.v1.common.getAppVersion()
setUserData(param)
Sets custom user data by key and value on given object. If the given object will be copied later, the user data is not copied as well.
Kind: v1.common 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 object to set user data on |
param.key | string | key as string |
param.value | string | value as string |
Example
res = api.v1.common.setUserData({ id: 796, key: 'material', value: 'aluminum-1060' })
getUserData(param)
Returns the value from the user data map at given key. If the key or map does not exist the defaultValue will be returned.
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: string // value at given key or default value
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 object to get user data from |
param.key | string | key of user data entry to get value from |
param.defaultValue | string | default value to return if key does not exist |
Example
res = api.v1.common.getUserData({ id: 89, key: 'material', defaultValue: 'none' })
removeUserData(param)
Removes the user data entry identified by given key
Kind: v1.common 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 object to remove user data from |
param.key | string | key of user data entry to remove |
Example
res = api.v1.common.removeUserData({ id: 796, key: 'material' })
clearUserData(param)
Clears all entries from user data of given object
Kind: v1.common 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 object to clear user data |
Example
res = api.v1.common.clearUserData({ id: 796 })
getUserDataKeys(param)
Returns all the keys of user data map of given object
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: Array<string> // array of keys
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 object to get all keys from |
Example
res = api.v1.common.getUserDataKeys({ id: 796 })
batch(param)
Runs the given api calls in a sequence.
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: Array<{
result: any | VOID
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}>
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Description |
---|---|---|
param | object | object containing all the parameters |
param.jobs | Array<object> | an array of objects containing api jobs to be executed in one single call |
param.jobs[].api | string | the api of the job to be called |
[param.jobs[].param] | object | the parameters to be used for the job api call |
Example
res = @api.v1.common.batch({jobs: [
{ api: "v1.common.clear" },
{ api: "v1.part.create" },
{ api: "v1.common.save", param: { format: "ofb", encoding: "base64" } }
]});
requestVisualisation(param)
Requests the visualisation of the entities/cad entities from the classcad server
Kind: v1.common 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.ids | Array<(string|real|id)> | ids of the entities/ cad entities to get visualisation from |
Example
res = api.v1.common.requestVisualisation({ ids: [25, 36] })
load(param)
Reads drawing from ClassCAD- or SolidFile, drawing must be cleared or doClear set to TRUE. Other formats than STEP or ClassCAD are imported to a CC_Part and assembly information is not considered By default an STL file is loaded as PolyBrep and can mainly be used for visualisation.
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: { id: id } | VOID // object containing the id of the loaded model
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Default | Description |
---|---|---|---|
param | object | object containing the parameters | |
[param.url] | string | url to load file from | |
[param.file] | string | full path of the file. Path has to be a for the ClassCAD process reachable local or UNC path. | |
[param.data] | string | data/content of the model to load. If you want to load binary data, you have to string encode first. See encoding for possible encodings. | |
[param.format] | "ofb" | "stp" | "iwp" | the format of the data. For load from file, the format is not needed if the extension fits the format. | |
[param.doClear] | boolean | FALSE | if true, the drawing is cleared before loading and BaseModeling is initialised if needed (default=FALSE) |
[param.ident] | string | custom string identifier for the loaded root product | |
[param.encoding] | "base64" | the encoding the data is encoded with. If compression is also set, the decoding happens first! If loading as file, encoding has no influence. | |
[param.compression] | "deflate" | the compression algorithm the data is compressed with. If saving as file, compression has no influence. | |
[param.ofb] | object | options to configure the ofb data, if the format == ofb. | |
[param.ofb.geometry] | real | 2 | (default=2). - 2: use stored geometry - 3: use stored graphics - 4: use stored geometry and graphics |
[param.stp] | object | options to configure the ofb data, if the format == stp. | |
[param.stp.asPart] | boolean | FALSE | (default=FALSE). - FALSE: stp files are loaded using assembly structure. - TRUE: stp files are loaded into part without assembly structures. |
[param.stl] | object | options to configure the stl data, if the format == stl. Assembly structure is lost. | |
[param.stl.asPolyBrep] | boolean | TRUE | (default=TRUE). - FALSE: body will be loaded as faces - TRUE: body will be loaded as poly brep |
Example
res = api.v1.common.load({ url: 'https://.../file.ofb', format: 'ofb' })
res = api.v1.common.load({ file: '/var/models/file.stp' })
res = api.v1.common.load({ file: '/var/models/file.stp', stp: { asPart: TRUE } })
res = api.v1.common.load({ data: 'xx124b', format: 'ofb' })
save(param)
Stores the current model. ofb, scg and step can keep assembly structure, for other formats only the geometry is exported and assembly information is lost. By default the model is written to a data string.
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: {
success: boolean,
content?: string // content is the data string of the model and is only available if neither file nor url is defined.
}
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Param | Type | Default | Description |
---|---|---|---|
param | object | object containing the parameters | |
[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.format] | "ofb" | "scg" | "stp" | "iwp" | "stl" | "dxf" | the format of data stored. If stored to a file, format is optional (if missing the file ending is used to define the format). | |
[param.encoding] | "base64" | the encoding the data will be encoded with. If compression is also set, the decoding happens after compression! If saving as file, encoding has no influence. | |
[param.compression] | "deflate" | the compression algorithm the data is compressed with. If saving as file, compression has no influence. | |
[param.ofb] | object | options to configure the ofb data, if the format == ofb. | |
[param.ofb.version] | real | -2 | defines the fileformat which is used to write the data. -2 is the most current released version (default=-2). |
[param.ofb.geometry] | real | 2 | (default=2). - 0: only store ClassCAD objects. - 1: store objects for class format. - 2: store objects and geometry. - 3: store objects and graphics. - 4: store objects, geometry and graphics. |
[param.stp] | object | options to configure the step data, if the format == stp. | |
[param.stp.asPart] | boolean | FALSE | (default=FALSE). This flag is only available in base modeling TODO: correct?? - FALSE: step files are written using assembly structure. - TRUE: all geometry in instances is copied to the apropriate place and written to the stepfile as new geometry. |
[param.stp.analytic] | real | 0 | defines if exported geometry should be converted into analytic geometry (e.g. circle, plane,...) when writing data (default=0). |
[param.stp.version] | real | 2 | defines the step data format. Depending on the format different content may exist in the data. (default=2). - 1: AP203. - 2: AP214. - 3: AP242. |
[param.stp.header] | object | options to configure the header of stp data | |
[param.stp.header.filename] | object | options to configure the header's filename properties | |
[param.stp.header.filename.name] | string | name of the stp data to set in the header's filename | |
[param.stp.header.filename.organization] | string | name of the organization to set in the header's filename of stp data | |
[param.stl] | object | options to configure the stl data, if the format == stl. Assembly structure is lost. | |
[param.stl.facetingTol] | real | 0.1 | max distance between real geometry and approximated segment (default=0.1). |
[param.stl.angleTol] | real | 6 | max angle between two segments, unit: degree (default=6). |
[param.stl.binary] | boolean | TRUE | defines if stl data should be binary. Else it is ASCII (default=TRUE). |
[param.iwp] | object | options to configure the iwp data, if the format == iwp. Assembly structure is lost. This is an SMLib internal format and can contain more than one geometry. | |
[param.iwp.binary] | boolean | FALSE | (default=FALSE). - FALSE: Data is written in ASCII. - TRUE: File is written binary. |
[param.dxf] | object | options to configure the dxf data, if the format == dxf. Can only be used to write 2d geometry. | |
[param.dxf.digits] | real | 16 | number of digits for numbers (default=16). |
[param.dxf.version] | real | 2000 | version for dxf data. Version 2000 is internaly vAC15. The newest supported version is 2013, internaly vAC27 (default=2000). |
Example
res = api.v1.common.save({ format: 'ofb' })
res = api.v1.common.save({ file: '/var/models/file.stp' })
res = api.v1.common.save({ url: 'https://.../file.ofb', format: 'ofb' })
res = api.v1.common.save({ file: '/var/models/file.stp', stp: { asPart: TRUE, version: 1 } })
res = api.v1.common.save({
file: '/var/models/file.stp',
stp: { asPart: TRUE, version: 1, header: { fileName: { name: '/var/name.stp' } } },
})
res = api.v1.common.save({ format: 'stl', stl: { facetingTolerance: 0.5, binary: 0 } })
recalc()
Recalculates and updates the whole drawing with all its objects
Kind: v1.common function
Returns: object
- object containing result and optional messages
{
result: VOID
messages?: { message: string, level: real, code: real, api: string }[]
maxLevel?: real
}
Example
res = api.v1.common.recalc()