ObjectValidator#

class ObjectValidator(**kwds)#

Object passed into the validate methods.

Implements methods to make object validation easier:
  • knows what object is being validated so the caller does not have to pass it in. This should make the messages more consistent.

  • implements common methods, like ensuring all references are resolved

checkArrayType(property, type=None)#

Checks if an Array is of a specific type.

Parameters
  • property (str) – The Array passed as a string.

  • type – The type that the Array is validated against.

checkEq(property, fence, required=False)#

Checks if a property is equal to zero.

Parameters
  • property (str) – The checked property passed as a string.

  • required (bool) – If True, the method validates if the property has been specified.

Returns

  • True, if the property is equal to zero.

  • Error, if the property is NOT equal to zero.

  • Error Not Specified, if the property is required but not specified.

checkFile(property, required=False)#

Checks the validity of the specified path of a file. Optionally checks if the file is specified.

Parameters
  • property (str) – An attribute pointing to a specific file path, passed as a string.

  • required (bool) – If True, the method checks whether the property is specified.

Returns

  • True, if the checks are valid.

  • Error Not Specified, if the file is required but not specified.

  • Error Path, if the specified path is not valid.

checkFunction(function='function', routine='routine', required=False)#

Checks if the function is specified and if the routine is valid.

Parameters
  • function (str) – The checked function passed as a string.

  • routine (str) – The checked routine passed as a string.

  • required (bool) – If True, the method validates if the function has been specified.

Returns

  • True, if the checks are valid.

  • Error Not Specified, if the function is required but not specified.

  • Error DLL not found, if the dll is not found in the filesystem.

checkGe(property, fence, required=False)#

Checks if a property is greater or equal to a specific value.

Parameters
  • property (str) – The checked property passed as a string.

  • fence (float) – The low limit value of the property.

  • required (bool) – If True, the method validates if the property has been specified.

Returns

  • True, if the property is greater or equal to fence.

  • Error, if the property is not greater or equal to fence.

  • Error Not Specified, if the property is required but not specified.

checkGe0(property, required=False)#

Checks if a property is greater or equal to zero.

Parameters
  • property (str) – The checked property passed as a string.

  • required (bool) – If True, the method validates if the property has been specified.

Returns

  • True, if the property is greater or equal to zero.

  • Error, if the property is lower than zero.

  • Error Not Specified, if the property is required but not specified.

checkGt(property, fence, required=False)#

Checks if a property is greater than a specific value.

Parameters
  • property (str) – The checked property passed as a string.

  • fence (float) – The low limit value of the property.

  • required (bool) – If True, the method validates if the property has been specified.

Returns

  • True, if the property is greater than fence.

  • Error, if the property is not greater than fence.

  • Error Not Specified, if the property is required but not specified.

checkGt0(property, required=False)#

Checks if a property is greater than zero.

Parameters
  • property (str) – The checked property passed as a string.

  • required (bool) – If True, the method validates if the property has been specified.

Returns

  • True, if the property is greater than zero.

  • Error, if the property is not greater than zero.

  • Error Not Specified, if the property is required but not specified.

checkIandJ(sameBodyOk=False)#

Checks if marker attributes i and j have been specified and performs a floating marker check if applicable. Optionally, this function can check if the two markers belong to the same body.

Parameters

sameBodyOk (bool) – If False, the function checks if the markers belong to the same body.

Returns

  • True, if the mentioned checks are valid.

  • Error, if the i and j markers are the same marker.

  • Error Same Body, if sameBodyOk=False and the i and j markers belong to the same body.

  • Error Not floating, if a marker must be floating and is not.

checkJfloatMarker()#

Checks if the jfloat attribute is a floating marker.

Returns

  • True, if jfloat is a floating marker.

  • Error Not floating, if jfloat is not a floating marker.

checkLe(property, fence, required=False)#

Checks if a property is lower or equal to a specific value.

Parameters
  • property (str) – The checked property passed as a string.

  • fence (float) – The high limit value of the property.

  • required (bool) – If True, the method validates if the property has been specified.

Returns

  • True, if the property is lower or equal to fence.

  • Error, if the property is not lower or equal to fence.

  • Error Not Specified, if the property is required but not specified.

checkLt(property, fence, required=False)#

Checks if a property is lower than a specific value.

Parameters
  • property (str) – The checked property passed as a string.

  • fence (float) – The high limit value of the property.

  • required (bool) – If True, the method validates if the property has been specified.

Returns

  • True, if the property is lower than fence.

  • Error, if the property is not lower than fence.

  • Error Not Specified, if the property is required but not specified.

checkMarkerPosition(direction=None, tolerance=0.1)#

Checks the distance of the origins of the i and j markers of an object. The method can check distance in 1, 2, or 3 directions.

Parameters
  • direction (str) – The direction along which distance is checked. Valid options are ‘x’,’xy’,’xyz’.

  • tolerance=0.1 (float) – The maximum allowed distance that should not raise a Warning.

Returns

  • True, if the distance deviation is acceptable.

  • Warning, if there is unacceptable distance between the markers.

checkMarkersOnTheSameBody(property1, property2)#

Checks if two markers belong to the same body.

Parameters
  • property1 (str) – Marker 1 passed in as a string.

  • property2 (str) – Marker 2 passed in as a string.

Returns

True, if the two markers belong to a different body. Error Same Body, if the two markers belong to the same body.

checkMutualExclusive(property, required=False)#

Checks if mutually exclusive properties have been specified. Example: Marker xp,xv,reuler are mutually exclusive

Parameters
  • property (str) – One of the mutually exclusive attributes.

  • required (bool) – If True, at least one of the mutually exclusive attributes is required. For example: Contact igeom, iflex: One of them must be specified. For example: Marker zp, zv: No need to specify exactly one so required=False

Returns

  • True, if the attribute is not defined or is correctly specified.

  • Error Exclusive, if more than one attribute is specified.

  • Error Not Specified, if required=True and no attribute is specified.

checkNe0(property, required=False)#

Checks if a property is not equal to zero.

Parameters
  • property (str) – The checked property passed as a string.

  • required (bool) – If True, the method validates if the property has been specified.

Returns

  • True, if the property is NOT equal to zero.

  • Error, if the property is equal to zero.

  • Error Not Specified, if the property is required but not specified.

checkParallelAxes(direction_i, direction_j, angle_error=60, angle_warning=30)#

Checks if two axes belonging to different markers are parallel.

Parameters
  • direction_i (str) – The axis of the i marker that is checked. Valid options are ‘x’,’y’,’z’.

  • direction_j (str) – The axis of the j marker that is checked. Valid options are ‘x’,’y’,’z’.

  • angle_error (float) – The angle deviation [deg] above which the validator will raise an Error.

  • angle_warning (float) – The angle deviation [deg] above which the validator will raise a Warning.

Returns

  • True, if the angle between the axes is below the angle_warning limit.

  • Warning, if the angle between the axes is above the angle_warning limit.

  • Error, if the angle between the axes is above the angle_error limit.

checkPerpendicularAxes(direction_i, direction_j, angle_error=60, angle_warning=30)#

Checks if two axes belonging to different markers are perpendicular.

Parameters
  • direction_i (str) – The axis of the i marker that is checked. Valid options are ‘x’,’y’,’z’.

  • direction_j (str) – The axis of the j marker that is checked. Valid options are ‘x’,’y’,’z’.

  • angle_error (float) – The angle deviation from the 90 deg restriction above which the validator will raise an Error.

  • angle_warning (float) – The angle deviation from the 90 deg restriction above which the validator will raise a Warning.

Returns

  • True, if the angle deviation is below the angle_warning limit.

  • Warning, if the angle deviation is above the angle_warning limit.

  • Error, if the angle deviation is above the angle_error limit.

checkReferences(skip=None)#

Checks which attributes of an object are of type Reference and then validates whether these references have been resolved. Optionally,a skip list of such attributes can be provided to exclude them from the check.

Parameters

skip (str) – A string containing the names of the attributes to be excluded from the validation process.

Returns

  • True, if the checks are valid.

  • Error Not Specified, if the references have not been resolved.

checkSpecified(property)#

Checks if the property has been specified.

Parameters

property (str) – The name of the property that is required to be specified.

Returns

  • True, if the property has been specified.

  • Error Not Specified, if the property has not been specified.

checkString(property, required=False)#

Checks the validity of a string. Optionally checks if the property has been specifieed.

Parameters
  • property (str) – The string attribute, passed as a string.

  • required (bool) – If True, the method validates if the string has been specified.

Returns

  • True, if the checks are valid.

  • Error Invalid string, if the string contains invalid characters.

  • Error Not Specified, if the property is required but not specified.

checkTypeExclusive(property, type_='type')#

Checks if an exclusive-to-type property has been wrongly specified. Example: Joint.pd is only valid when Joint.type=’RACKPIN’.

Parameters
  • property (str) – The attribute name that’s being validated.

  • type (str) – The class attribute that determines the type of the object.

Returns

  • True, if the attribute is not defined or is correctly specified.

  • Warning Specified, if the attribute is wrongly specified.

checkUserFunction(property, required=False)#

Checks if a function is a ‘USER’ function and performs a checkFunction validation. Optionally checks if the function is specified.

Parameters
  • property (str) – The function passed as a string.

  • required (bool) – If True, the method validates if the function has been specified.

Returns

  • True, if the checks are valid.

  • Error Not ‘USER’, if the function is not a ‘USER’ function.

  • See checkFunction method for other possible output messages.

sendError(msg)#

Used in validation code to format and write out an ERROR message. It sets the valid state to False.

Parameters

msg (str) – The error message.

sendInfo(msg)#

Used in validation code to format and write out an INFO message. The valid state is not affected.

Parameters

msg (str) – The info message.

sendNotSpecified(property)#

Used in validation code when required properties are not specified. It raises an ERROR, so it sets the valid state to False.

Parameters

property (str) – The attribute that is not specified.

sendWarning(msg)#

Used in validation code to format and write out a WARNING message. The valid state is not affected.

Parameters

msg (str) – The warning message.