-
Notifications
You must be signed in to change notification settings - Fork 18
pytha.set_grain_direction
Sets the grain direction of a plate.
Similar to the Workshop -> Grain direction function in the PYTHA user interface. The grain direction tells the parts list and the CAM postprocessor how the plate has to be oriented on the panel.
pytha.set_grain_direction(edge)| Parameter | Type | Description |
|---|---|---|
edge |
{...} |
An edge specification { {x,y,z}, {x,y,z} [, part_handle] }
|
| Type | Description |
|---|---|
element_handle |
The part the grain direction was set on, or nil if neither an edge nor a plate was found |
An existing edge. If an edge of a part connects the two coordinates, that edge becomes the grain direction edge:
pytha.set_grain_direction({ {0, 0, 19}, {600, 0, 19}, part })A free line. If no edge connects the two coordinates, the line is taken as a direction line: PYTHA searches the plate the line lies on, creates the direction edge on it and merges it into the plate. This is how a grain direction at an arbitrary angle is defined:
pytha.set_grain_direction({ {50, 50, 19}, {550, 350, 19}, part })- A plate keeps one grain direction. A second call replaces the first, it does not add a second direction.
- The edge on the opposite face of the plate is marked as well, and created if it does not exist yet, so the direction is visible from both sides.
- For the free line case the line has to lie on one of the two largest faces of the plate. Without a part handle in the edge specification all parts are searched and the first matching plate wins; pass the part handle to be explicit.
- The part keeps its handle: after the merge the resulting part carries the persistent id and the parent group of the plate, so handles you already hold stay valid.
- The grain direction is stored as the pen of the edge. Changing the pen of that edge by hand removes the grain direction.
- The function requires the Workshop license, test for it with
check_license_workshop.
Grain along the long side of a plate, coordinates taken from its bounding box:
local lo, hi = table.unpack(pytha.get_element_bounding_box(part))
pytha.set_grain_direction({ {lo[1], lo[2], hi[3]}, {hi[1], lo[2], hi[3]}, part })Minimum PYTHA Version: V27
pytha, Workshop Functions, Edge Specification, remove_grain_direction, set_x_axis_direction