element_controller.slice_element_by_plane - add function with distance by point? #174
-
|
Hi, I see throughout my scripts that I end up copying the same function over and over again, and that's the function for calculating the distance requested in the slicing function. I'm sure there's a reason for the distance approach, but at least from my user perspective I'm always defining the slicing plane by some point. So to get the distance desired for the slicing one first has to project the slicing point onto a similar angled surface through global zero and calculate the distance there. Couldn't there also be a function that slices by point? The function below is an attempt to put this all together into one user-friendly function. Ideally project_point_on_plane should also be nested into this function or available somewhere else. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
|
Maybe the following will help you. You can use the import sys
import cadwork
import element_controller as ec
sys.path.append("C:\\...\\.venv\\Lib\\site-packages")
from cwmath.cwplane3d import CwPlane3d
from cwmath.cwvector3d import CwVector3d
if __name__ == '__main__':
element_ids = ec.get_user_element_ids()
# this could be some element axis (xl, yl, zl)
plane_normal = CwVector3d(0.000000, -0.500000, 0.866025)
plane_location = CwVector3d(-42.500000, 1644.450845, 3432.000000)
plane = CwPlane3d(plane_location, plane_normal)
distance = plane.distance_to_point(CwVector3d(0.0, 0.0, 0.0))
for element_id in element_ids:
print(ec.cut_element_with_plane(element_id,
cadwork.point_3d(*plane_normal),
distance)) |
Beta Was this translation helpful? Give feedback.

Maybe the following will help you. You can use the
CwPlane3dandCwVector3dfromcwmath