Weight¶
Value¶
The Value simply describes the weight in the specified units.
Weight Unit / Length Unit¶
Weights are not always absolute. For example, profiles frequently list the weight in gram per meter. To handle this, the W24Weight object defines a weight_unit and a length_unit. For absolute weights (e.g., 4kg), the length_unit is set to null
.
Model¶
Extracted information can be accessed from the W24Weight
Model.
W24Weight¶
Weight of a Part - for example as indicated on the Title Block.
NOTE: this can also be a relative weight (e.g. kg per meter for profiles)
Attributes: blurb: Weight in a human-readable format.
value: Value of the Weight
weight_unit: Unit of the Weight (e.g., kg)
length_unit: Unit of the Length for relative
weights (e.g., METER for meter weights of profiles)s
Properties¶
-
position
: Refer to #/definitions/W24BaseFeaturePosition. -
blurb
(string) -
value
(number) -
weight_unit
: Refer to #/definitions/W24UnitWeight. -
length_unit
: Refer to #/definitions/W24UnitLength.
Definitions¶
-
W24BaseFeatureCoordinate
(object): Coordinate point
Attributes: x: x position normalized by the thumbnail's width
y: y position normalized by the thumbnail's height. -
x
(number) -
y
(number) -
W24BaseFeaturePosition
(object): Position of the Feature on the individual thumbnails normalized by the width and height of each thumbnail.
Each features position is indicated as a list of coordinates. If the list only has two elements, you are dealing with a line. If it has four or more, you are looking at a polygon
Attributes: page: Position of the Feature on the Page thumbnail
sheet: Position of the Feature on the Sheet thumbnail
sectional: Position of the Feature on the Sectional thumbnail. -
sheet
(array)- Items: Refer to #/definitions/W24BaseFeatureCoordinate.
-
canvas
(array)- Items: Refer to #/definitions/W24BaseFeatureCoordinate.
-
sectional
(array)- Items: Refer to #/definitions/W24BaseFeatureCoordinate.
-
W24UnitWeight
(string): Enum of all the supported weights
NOTE: This also includes relative weights such as kilogram per meter. Must be one of:['GRAM', 'KILOGRAM', 'POUND', 'OUNCE']
. -
W24UnitLength
(string): Enum of the supported length units . Must be one of:['METER', 'DECIMETER', 'CENTIMETER', 'MILLIMETER', 'FOOT', 'INCH', 'MICRO_INCH']
.
Requesting the Weight¶
from werk24 import Hook, W24AskTitleBlock
from werk24.models.techread import W24TechreadMessage
from werk24.utils import w24_read_sync
# define a function to read a file and return it as bytes
from . import get_drawing_bytes
def recv_title_block(message: W24TechreadMessage) -> None:
""" Print the Weight when we received it
"""
if message.is_successful:
print(message.payload_dict.get('weight'))
else:
print("Exceptions occurred: {message.exceptions}")
if __name__ == "__main__":
# get your drawing bytes from a file or buffer
drawing_bytes = get_drawing_bytes()
# define what information you want to receive from the API
# and what shall be done when the info is available.
hooks = [Hook(ask=W24AskTitleBlock(), function=recv_title_block)]
# submit the request to the Werk24 API
w24_read_sync(drawing_bytes, hooks)
Example Response¶
"weight": {
"blurb": "10 g/m",
"value": 10.0,
"weight_unit": "GRAM",
"length_unit": "METER",
}