Skip to main content

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
}
ParamTypeDescription
[param]objectobject 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
}
ParamTypeDefaultDescription
paramobjectobject containing all the parameters
[param.id]string | real | idany id which is a child of the root part/assembly like feature id, expression set, ...
param.expressionstringexpression string to be evaluated
[param.silent]booleanFALSEflag 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
}
ParamTypeDescription
paramobjectobject or objects containing the parameters
param.targetstring | real | id | objecttarget as id of the feature to set appearance on or as object containing an id and optional indices
param.target.idstring | real | idid 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]objectobject containing the rgb values
param.color.rrealred value (0-255) of the color
param.color.grealgreen value (0-255) of the color
param.color.brealblue value (0-255) of the color
[param.transparency]realvalue of transparency between 0 and 1
[param.chordHeightTol]realchord height tolerance
[param.angleTol]realangle 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
[param.isGraphicEnabled]booleanflag to define whether graphic will be visible or not
[param.isCCGraphicEnabled]booleanflag to define whether classcad graphic will be visible or not
[param.isInvisibleGraphicEnabled]booleanflag to define whether invisible graphic will tessellated or not.
[param.isSketchGraphicEnabled]booleanto define whether sketch graphic will be visible or not.
[param.facetingParamsMode]realMode 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]realdistance tolerance between geometrical arc and tesselated arc
[param.angleTol]realangle tolerance between two surfaces of tesselation
[param.doCurveTessellation]booleanflag 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
[param.angleTol]realangle tolerance between two surfaces of tesselation
[param.chordHeightTol]realdistance 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
}
ParamTypeDefaultDescription
paramobjectobject containing all the parameters
param.idstring | real | idid of any object to transform
param.matrixArray<Array<real>>the 4x4 transformation matrix
[param.isGlobal]booleanTRUEmust 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idstring | real | idid of the object to set the new coordinate system on
param.originpointorigin of the new coordinate system
param.xVecpointx direction of the new coordinate system
param.yVecpointy 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idstring | real | idid of the object to set the name on
param.namestringname 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idstring | real | idid of the object to set user data on
param.keystringkey as string
param.valuestringvalue 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idstring | real | idid of the object to get user data from
param.keystringkey of user data entry to get value from
param.defaultValuestringdefault 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idstring | real | idid of the object to remove user data from
param.keystringkey 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idstring | real | idid 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.idstring | real | idid 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
}
ParamTypeDescription
paramobjectobject containing all the parameters
param.jobsArray<object>an array of objects containing api jobs to be executed in one single call
param.jobs[].apistringthe api of the job to be called
[param.jobs[].param]objectthe 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
}
ParamTypeDescription
paramobjectobject containing the parameters
param.idsArray<(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
}
ParamTypeDefaultDescription
paramobjectobject containing the parameters
[param.url]stringurl to load file from
[param.file]stringfull path of the file. Path has to be a for the ClassCAD process reachable local or UNC path.
[param.data]stringdata/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]booleanFALSEif true, the drawing is cleared before loading and BaseModeling is initialised if needed (default=FALSE)
[param.ident]stringcustom 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]objectoptions to configure the ofb data, if the format == ofb.
[param.ofb.geometry]real2(default=2). - 2: use stored geometry - 3: use stored graphics - 4: use stored geometry and graphics
[param.stp]objectoptions to configure the ofb data, if the format == stp.
[param.stp.asPart]booleanFALSE(default=FALSE). - FALSE: stp files are loaded using assembly structure. - TRUE: stp files are loaded into part without assembly structures.
[param.stl]objectoptions to configure the stl data, if the format == stl. Assembly structure is lost.
[param.stl.asPolyBrep]booleanTRUE(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
}
ParamTypeDefaultDescription
paramobjectobject containing the parameters
[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.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]objectoptions to configure the ofb data, if the format == ofb.
[param.ofb.version]real-2defines the fileformat which is used to write the data. -2 is the most current released version (default=-2).
[param.ofb.geometry]real2(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]objectoptions to configure the step data, if the format == stp.
[param.stp.asPart]booleanFALSE(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]real0defines if exported geometry should be converted into analytic geometry (e.g. circle, plane,...) when writing data (default=0).
[param.stp.version]real2defines 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]objectoptions to configure the header of stp data
[param.stp.header.filename]objectoptions to configure the header's filename properties
[param.stp.header.filename.name]stringname of the stp data to set in the header's filename
[param.stp.header.filename.organization]stringname of the organization to set in the header's filename of stp data
[param.stl]objectoptions to configure the stl data, if the format == stl. Assembly structure is lost.
[param.stl.facetingTol]real0.1max distance between real geometry and approximated segment (default=0.1).
[param.stl.angleTol]real6max angle between two segments, unit: degree (default=6).
[param.stl.binary]booleanTRUEdefines if stl data should be binary. Else it is ASCII (default=TRUE).
[param.iwp]objectoptions 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]booleanFALSE(default=FALSE). - FALSE: Data is written in ASCII. - TRUE: File is written binary.
[param.dxf]objectoptions to configure the dxf data, if the format == dxf. Can only be used to write 2d geometry.
[param.dxf.digits]real16number of digits for numbers (default=16).
[param.dxf.version]real2000version 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()