-
Notifications
You must be signed in to change notification settings - Fork 18
pydim
The pydim.* api functions create the annotations of the PYTHA model programmatically — the dimensions a user creates with the Dimensions functions, and the 2d texts and leaders of the Text functions in the PYTHA user interface.
-
pydim.create_linear_dimension— create a linear dimension between two part points (optionally with saw angle). -
pydim.create_radial_dimension— create a radius, diameter, center or arc-length dimension from three points on an arc. -
pydim.create_angular_dimension— create an angle dimension between two edges, or an edge-distance dimension for parallel edges. -
pydim.create_perpendicular_dimension— create a perpendicular dimension from a point onto an edge. -
pydim.delete_dimension— delete dimensions.
-
pydim.create_text— create a 2d annotation text, optionally with a leader. -
pydim.get_text— read content, placement and appearance of a text. -
pydim.update_text— change content, placement or appearance of a text. -
pydim.delete_text— delete texts together with their leaders.
Dimensions in PYTHA are anchored to part points or reference points, not to free coordinates: when the element is modified, its dimensions follow. pydim therefore expects coordinates that coincide with an existing point. Each dimension point is given as a table with the coordinate at index 1 and, optionally, a part or group element handle at index 2 that restricts the point search to that element:
{ {x, y, z} } -- searched everywhere
{ {x, y, z}, part } -- searched only in this part
{ {x, y, z}, group } -- searched only among this group's reference pointsThe search resolves the coordinate in this order:
- Part reference points (of the given part, or of all parts)
- Group reference points (only without a part handle)
- Plain part points
Reference points always take priority over plain part points. A group handle only matches the group's reference points — groups have no plain points. If a coordinate does not match any point, no dimension is created and the function returns nil.
pydim.create_angular_dimension and pydim.create_perpendicular_dimension reference part edges. An edge is given as two dimension-point tables for its end coordinates; the coordinates are resolved to the part edge that connects them (the order of the two ends does not matter). An edge always lies completely within one part, so if both end points carry a part handle, it must be the same part. Edges connect plain part points only — group handles and reference points cannot describe an edge.
Every dimension belongs to one view and is displayed in that view only ("xy", "xz", "yz", their flipped counterparts, or "axo").
- In the plane views,
"horizontal"measures along the horizontal axis of the view,"vertical"along the vertical axis, and"parallel"along the connection of the two dimension points. - In the axo view,
"horizontal"and"vertical"additionally need the plane the dimension lies in. A"parallel"dimension in the axo view is axis-parallel: it needs the axis the dimension line is parallel to and the plane it is projected into.
A new dimension uses the current default dimension style (Environment -> Settings -> Dimension). Both can be overridden per dimension:
-
style_file— a path handle to a dimension style file (as saved from the dimension attributes dialog) that is loaded as the base style. -
style— a table with individual style settings (pens, delimiters, text, tolerances, ...) applied on top.
2d annotation texts are drawing aids, not 3d objects — they live in one view like a dimension does and are typically used for labels such as position numbers. For 3d text see pytha.create_text_3d, for texts on a plot sheet pyplot.insert_text.
The anchor of a text has the same form as a dimension point, but is resolved more leniently: a coordinate that hits a part point binds the text to that point so it follows the part, while a coordinate that matches no point simply yields a free text instead of an error.
A leader is a property of its text: pydim.create_text creates at most one leader together with the text, pydim.update_text changes or removes it, and pydim.delete_text deletes it with the text. There is no separate leader handle. A user can still attach further leaders interactively, so pydim.get_text reports a leader_count.
pytha, pyplot, Element Handles, Path Handles, pytha.create_text_3d, pyplot.insert_text