How to transform global axis into local using python in cadwork? #129
-
|
Hi, |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 18 replies
-
|
you could do something like this from typing import List
import cadwork
import element_controller as ec
import geometry_controller as gc
def get_element_orientation_and_position(element_id: int):
point1 = gc.get_p1(element_id)
x_direction = gc.get_xl(element_id)
y_direction = gc.get_yl(element_id)
return point1, x_direction, y_direction
def transform_element(element_id: int, point1_new: cadwork.point_3d, x_direction_new: cadwork.point_3d,
y_direction_new: cadwork.point_3d):
point1_old, x_direction_old, y_direction_old = get_element_orientation_and_position(element_id)
ec.apply_transformation_coordinate([element_id],
point1_old,
x_direction_old,
y_direction_old,
point1_new,
x_direction_new,
y_direction_new)
if __name__ == '__main__':
element_ids: List[int] = ec.get_user_element_ids()
x_direction_new = cadwork.point_3d(1., 0., 0.)
y_direction_new = cadwork.point_3d(0., 1., 0.)
for element_id in element_ids:
point1_new = gc.get_p1(element_id) # or set your preferred position
transform_element(element_id, point1_new, x_direction_new, y_direction_new) |
Beta Was this translation helpful? Give feedback.
-
|
I have a question. Let's imagine the following scenario: we have a dictionary called element_collision_and_contact, where each key represents a timber element in Cadwork (timber_element), and the values are the elements that collide or contact with this timber element (conFilter). I already understand how to transform timber_element from global to local coordinates, but I'm having difficulty maintaining the relative position of connFilter with respect to this element. How can I perform this transformation properly? |
Beta Was this translation helpful? Give feedback.
you could do something like this