diff --git a/rust/kcl-lib/src/simulation_tests.rs b/rust/kcl-lib/src/simulation_tests.rs index 279d98d7c..a21c659b1 100644 --- a/rust/kcl-lib/src/simulation_tests.rs +++ b/rust/kcl-lib/src/simulation_tests.rs @@ -2289,3 +2289,66 @@ mod bad_units_in_annotation { super::execute(TEST_NAME, true).await } } +mod translate_after_fillet { + const TEST_NAME: &str = "translate_after_fillet"; + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[tokio::test(flavor = "multi_thread")] + async fn unparse() { + super::unparse(TEST_NAME).await + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, true).await + } +} +mod scale_after_fillet { + const TEST_NAME: &str = "scale_after_fillet"; + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[tokio::test(flavor = "multi_thread")] + async fn unparse() { + super::unparse(TEST_NAME).await + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, true).await + } +} +mod rotate_after_fillet { + const TEST_NAME: &str = "rotate_after_fillet"; + + /// Test parsing KCL. + #[test] + fn parse() { + super::parse(TEST_NAME) + } + + /// Test that parsing and unparsing KCL produces the original KCL input. + #[tokio::test(flavor = "multi_thread")] + async fn unparse() { + super::unparse(TEST_NAME).await + } + + /// Test that KCL is executed correctly. + #[tokio::test(flavor = "multi_thread")] + async fn kcl_test_execute() { + super::execute(TEST_NAME, true).await + } +} diff --git a/rust/kcl-lib/src/std/args.rs b/rust/kcl-lib/src/std/args.rs index 5891b7cf8..d8b021bce 100644 --- a/rust/kcl-lib/src/std/args.rs +++ b/rust/kcl-lib/src/std/args.rs @@ -376,7 +376,7 @@ impl Args { pub(crate) async fn flush_batch_for_solids( &self, exec_state: &mut ExecState, - solids: Vec, + solids: &[Solid], ) -> Result<(), KclError> { // Make sure we don't traverse sketches more than once. let mut traversed_sketches = Vec::new(); diff --git a/rust/kcl-lib/src/std/patterns.rs b/rust/kcl-lib/src/std/patterns.rs index d591b4aad..835ebba79 100644 --- a/rust/kcl-lib/src/std/patterns.rs +++ b/rust/kcl-lib/src/std/patterns.rs @@ -363,7 +363,7 @@ async fn execute_pattern_transform( // Flush the batch for our fillets/chamfers if there are any. // If we do not flush these, then you won't be able to pattern something with fillets. // Flush just the fillets/chamfers that apply to these solids. - T::flush_batch(args, exec_state, geo_set.clone()).await?; + T::flush_batch(args, exec_state, &geo_set).await?; let starting: Vec = geo_set.into(); if args.ctx.context_type == crate::execution::ContextType::Mock { @@ -614,7 +614,7 @@ trait GeometryTrait: Clone { fn original_id(&self) -> Uuid; fn set_id(&mut self, id: Uuid); fn array_to_point3d(val: &KclValue, source_ranges: Vec) -> Result; - async fn flush_batch(args: &Args, exec_state: &mut ExecState, set: Self::Set) -> Result<(), KclError>; + async fn flush_batch(args: &Args, exec_state: &mut ExecState, set: &Self::Set) -> Result<(), KclError>; } impl GeometryTrait for Sketch { @@ -633,7 +633,7 @@ impl GeometryTrait for Sketch { Ok(Point3d { x, y, z: 0.0 }) } - async fn flush_batch(_: &Args, _: &mut ExecState, _: Self::Set) -> Result<(), KclError> { + async fn flush_batch(_: &Args, _: &mut ExecState, _: &Self::Set) -> Result<(), KclError> { Ok(()) } } @@ -656,7 +656,7 @@ impl GeometryTrait for Solid { array_to_point3d(val, source_ranges) } - async fn flush_batch(args: &Args, exec_state: &mut ExecState, solid_set: Self::Set) -> Result<(), KclError> { + async fn flush_batch(args: &Args, exec_state: &mut ExecState, solid_set: &Self::Set) -> Result<(), KclError> { args.flush_batch_for_solids(exec_state, solid_set).await } } @@ -1221,7 +1221,7 @@ async fn inner_pattern_circular_3d( // Flush the batch for our fillets/chamfers if there are any. // If we do not flush these, then you won't be able to pattern something with fillets. // Flush just the fillets/chamfers that apply to these solids. - args.flush_batch_for_solids(exec_state, solids.clone()).await?; + args.flush_batch_for_solids(exec_state, &solids).await?; let starting_solids = solids; diff --git a/rust/kcl-lib/src/std/shell.rs b/rust/kcl-lib/src/std/shell.rs index e5211ad14..2be881131 100644 --- a/rust/kcl-lib/src/std/shell.rs +++ b/rust/kcl-lib/src/std/shell.rs @@ -210,7 +210,7 @@ async fn inner_shell( for solid in &solids { // Flush the batch for our fillets/chamfers if there are any. // If we do not do these for sketch on face, things will fail with face does not exist. - args.flush_batch_for_solids(exec_state, vec![solid.clone()]).await?; + args.flush_batch_for_solids(exec_state, &[solid.clone()]).await?; for tag in &faces { let extrude_plane_id = tag.get_face_id(solid, exec_state, &args, false).await?; @@ -320,7 +320,7 @@ async fn inner_hollow( ) -> Result, KclError> { // Flush the batch for our fillets/chamfers if there are any. // If we do not do these for sketch on face, things will fail with face does not exist. - args.flush_batch_for_solids(exec_state, vec![(*solid).clone()]).await?; + args.flush_batch_for_solids(exec_state, &[(*solid).clone()]).await?; args.batch_modeling_cmd( exec_state.next_uuid(), diff --git a/rust/kcl-lib/src/std/sketch.rs b/rust/kcl-lib/src/std/sketch.rs index bf72aa86b..0f85ee70b 100644 --- a/rust/kcl-lib/src/std/sketch.rs +++ b/rust/kcl-lib/src/std/sketch.rs @@ -1269,7 +1269,7 @@ pub(crate) async fn inner_start_profile_at( SketchSurface::Face(face) => { // Flush the batch for our fillets/chamfers if there are any. // If we do not do these for sketch on face, things will fail with face does not exist. - args.flush_batch_for_solids(exec_state, vec![(*face.solid).clone()]) + args.flush_batch_for_solids(exec_state, &[(*face.solid).clone()]) .await?; } SketchSurface::Plane(plane) if !plane.is_standard() => { diff --git a/rust/kcl-lib/src/std/transform.rs b/rust/kcl-lib/src/std/transform.rs index c5e41f46a..674ad229d 100644 --- a/rust/kcl-lib/src/std/transform.rs +++ b/rust/kcl-lib/src/std/transform.rs @@ -147,6 +147,12 @@ async fn inner_scale( exec_state: &mut ExecState, args: Args, ) -> Result { + // If we have a solid, flush the fillets and chamfers. + // Only transforms needs this, it is very odd, see: https://github.com/KittyCAD/modeling-app/issues/5880 + if let SolidOrSketchOrImportedGeometry::SolidSet(solids) = &objects { + args.flush_batch_for_solids(exec_state, solids).await?; + } + for object_id in objects.ids() { let id = exec_state.next_uuid(); @@ -344,6 +350,12 @@ async fn inner_translate( exec_state: &mut ExecState, args: Args, ) -> Result { + // If we have a solid, flush the fillets and chamfers. + // Only transforms needs this, it is very odd, see: https://github.com/KittyCAD/modeling-app/issues/5880 + if let SolidOrSketchOrImportedGeometry::SolidSet(solids) = &objects { + args.flush_batch_for_solids(exec_state, solids).await?; + } + for object_id in objects.ids() { let id = exec_state.next_uuid(); @@ -690,6 +702,12 @@ async fn inner_rotate( exec_state: &mut ExecState, args: Args, ) -> Result { + // If we have a solid, flush the fillets and chamfers. + // Only transforms needs this, it is very odd, see: https://github.com/KittyCAD/modeling-app/issues/5880 + if let SolidOrSketchOrImportedGeometry::SolidSet(solids) = &objects { + args.flush_batch_for_solids(exec_state, solids).await?; + } + for object_id in objects.ids() { let id = exec_state.next_uuid(); diff --git a/rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap b/rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap new file mode 100644 index 000000000..07fbb0e78 --- /dev/null +++ b/rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap @@ -0,0 +1,1004 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Artifact commands rotate_after_fillet.kcl +--- +[ + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "edge_lines_visible", + "hidden": false + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "set_scene_units", + "unit": "mm" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 320, + 339, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "size": 60.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.469, + "y": 0.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "arc", + "center": { + "x": 0.0, + "y": 0.0 + }, + "radius": 0.469, + "start": { + "unit": "degrees", + "value": 0.0 + }, + "end": { + "unit": "degrees", + "value": 360.0 + }, + "relative": false + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": -0.625, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 506, + 530, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 466, + 532, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 466, + 532, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.25, + "y": 0.14433756729740643, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 750, + 833, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.0, + "y": -0.2887, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 841, + 924, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.25, + "y": -0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 932, + 1015, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.25, + "y": 0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1023, + 1105, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.0, + "y": 0.2887, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1113, + 1195, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.25, + "y": 0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1203, + 1210, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": -0.46875, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.3125, + "y": 0.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "arc", + "center": { + "x": 0.0, + "y": 0.0 + }, + "radius": 0.3125, + "start": { + "unit": "degrees", + "value": 0.0 + }, + "end": { + "unit": "degrees", + "value": 360.0 + }, + "relative": false + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": 2.5, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1454, + 1481, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1491, + 1552, + 0 + ], + "command": { + "type": "object_set_material_params_pbr", + "object_id": "[uuid]", + "color": { + "r": 0.3019608, + "g": 0.8156863, + "b": 0.2627451, + "a": 100.0 + }, + "metalness": 0.9, + "roughness": 0.9, + "ambient_occlusion": 0.0 + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1424, + 1483, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1587, + 1632, + 0 + ], + "command": { + "type": "set_object_transform", + "object_id": "[uuid]", + "transforms": [ + { + "translate": null, + "rotate_rpy": { + "property": { + "x": 3.14, + "y": 3.14, + "z": 3.14 + }, + "set": false, + "is_local": true + }, + "rotate_angle_axis": null, + "scale": null + } + ] + } + } +] diff --git a/rust/kcl-lib/tests/rotate_after_fillet/artifact_graph_flowchart.snap b/rust/kcl-lib/tests/rotate_after_fillet/artifact_graph_flowchart.snap new file mode 100644 index 000000000..83ed16952 --- /dev/null +++ b/rust/kcl-lib/tests/rotate_after_fillet/artifact_graph_flowchart.snap @@ -0,0 +1,6 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Artifact graph flowchart rotate_after_fillet.kcl +extension: md +snapshot_kind: binary +--- diff --git a/rust/kcl-lib/tests/rotate_after_fillet/artifact_graph_flowchart.snap.md b/rust/kcl-lib/tests/rotate_after_fillet/artifact_graph_flowchart.snap.md new file mode 100644 index 000000000..264c6b7a7 --- /dev/null +++ b/rust/kcl-lib/tests/rotate_after_fillet/artifact_graph_flowchart.snap.md @@ -0,0 +1,134 @@ +```mermaid +flowchart LR + subgraph path2 [Path] + 2["Path
[347, 417, 0]"] + 3["Segment
[347, 417, 0]"] + 4[Solid2d] + end + subgraph path13 [Path] + 13["Path
[655, 742, 0]"] + 14["Segment
[750, 833, 0]"] + 15["Segment
[841, 924, 0]"] + 16["Segment
[932, 1015, 0]"] + 17["Segment
[1023, 1105, 0]"] + 18["Segment
[1113, 1195, 0]"] + 19["Segment
[1203, 1210, 0]"] + 20[Solid2d] + end + subgraph path41 [Path] + 41["Path
[1311, 1380, 0]"] + 42["Segment
[1311, 1380, 0]"] + 43[Solid2d] + end + 1["Plane
[320, 339, 0]"] + 5["Sweep Extrusion
[425, 458, 0]"] + 6[Wall] + 7["Cap Start"] + 8["Cap End"] + 9["SweepEdge Opposite"] + 10["SweepEdge Adjacent"] + 11["EdgeCut Fillet
[466, 532, 0]"] + 12["EdgeCut Fillet
[466, 532, 0]"] + 21["Sweep Extrusion
[1218, 1258, 0]"] + 22[Wall] + 23[Wall] + 24[Wall] + 25[Wall] + 26[Wall] + 27[Wall] + 28["Cap Start"] + 29["SweepEdge Opposite"] + 30["SweepEdge Adjacent"] + 31["SweepEdge Opposite"] + 32["SweepEdge Adjacent"] + 33["SweepEdge Opposite"] + 34["SweepEdge Adjacent"] + 35["SweepEdge Opposite"] + 36["SweepEdge Adjacent"] + 37["SweepEdge Opposite"] + 38["SweepEdge Adjacent"] + 39["SweepEdge Opposite"] + 40["SweepEdge Adjacent"] + 44["Sweep Extrusion
[1388, 1416, 0]"] + 45[Wall] + 46["Cap End"] + 47["SweepEdge Opposite"] + 48["SweepEdge Adjacent"] + 49["EdgeCut Fillet
[1424, 1483, 0]"] + 50["StartSketchOnFace
[615, 647, 0]"] + 51["StartSketchOnFace
[1273, 1303, 0]"] + 1 --- 2 + 2 --- 3 + 2 ---- 5 + 2 --- 4 + 3 --- 6 + 3 --- 9 + 3 --- 10 + 3 --- 11 + 5 --- 6 + 5 --- 7 + 5 --- 8 + 5 --- 9 + 5 --- 10 + 7 --- 13 + 8 --- 41 + 9 <--x 12 + 13 --- 14 + 13 --- 15 + 13 --- 16 + 13 --- 17 + 13 --- 18 + 13 --- 19 + 13 ---- 21 + 13 --- 20 + 14 --- 27 + 14 --- 39 + 14 --- 40 + 15 --- 26 + 15 --- 37 + 15 --- 38 + 16 --- 25 + 16 --- 35 + 16 --- 36 + 17 --- 24 + 17 --- 33 + 17 --- 34 + 18 --- 23 + 18 --- 31 + 18 --- 32 + 19 --- 22 + 19 --- 29 + 19 --- 30 + 21 --- 22 + 21 --- 23 + 21 --- 24 + 21 --- 25 + 21 --- 26 + 21 --- 27 + 21 --- 28 + 21 --- 29 + 21 --- 30 + 21 --- 31 + 21 --- 32 + 21 --- 33 + 21 --- 34 + 21 --- 35 + 21 --- 36 + 21 --- 37 + 21 --- 38 + 21 --- 39 + 21 --- 40 + 41 --- 42 + 41 ---- 44 + 41 --- 43 + 42 --- 45 + 42 --- 47 + 42 --- 48 + 44 --- 45 + 44 --- 46 + 44 --- 47 + 44 --- 48 + 47 <--x 49 + 7 <--x 50 + 8 <--x 51 +``` diff --git a/rust/kcl-lib/tests/rotate_after_fillet/ast.snap b/rust/kcl-lib/tests/rotate_after_fillet/ast.snap new file mode 100644 index 000000000..5c5d6dfd6 --- /dev/null +++ b/rust/kcl-lib/tests/rotate_after_fillet/ast.snap @@ -0,0 +1,1685 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Result of parsing rotate_after_fillet.kcl +--- +{ + "Ok": { + "body": [ + { + "declaration": { + "end": 27, + "id": { + "end": 19, + "name": "boltDiameter", + "start": 7, + "type": "Identifier" + }, + "init": { + "end": 27, + "raw": "0.625", + "start": 22, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.625, + "suffix": "None" + } + }, + "start": 7, + "type": "VariableDeclarator" + }, + "end": 27, + "kind": "const", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 53, + "id": { + "end": 45, + "name": "boltLength", + "start": 35, + "type": "Identifier" + }, + "init": { + "end": 53, + "raw": "2.500", + "start": 48, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.5, + "suffix": "None" + } + }, + "start": 35, + "type": "VariableDeclarator" + }, + "end": 53, + "kind": "const", + "start": 28, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 90, + "id": { + "end": 75, + "name": "boltHeadLength", + "start": 61, + "type": "Identifier" + }, + "init": { + "end": 90, + "name": "boltDiameter", + "start": 78, + "type": "Identifier", + "type": "Identifier" + }, + "start": 61, + "type": "VariableDeclarator" + }, + "end": 90, + "kind": "const", + "start": 54, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 122, + "id": { + "end": 114, + "name": "boltHeadDiameter", + "start": 98, + "type": "Identifier" + }, + "init": { + "end": 122, + "raw": "0.938", + "start": 117, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.938, + "suffix": "None" + } + }, + "start": 98, + "type": "VariableDeclarator" + }, + "end": 122, + "kind": "const", + "start": 91, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 150, + "id": { + "end": 142, + "name": "boltHexDrive", + "start": 130, + "type": "Identifier" + }, + "init": { + "end": 150, + "left": { + "end": 146, + "raw": "1", + "start": 145, + "type": "Literal", + "type": "Literal", + "value": { + "value": 1.0, + "suffix": "None" + } + }, + "operator": "/", + "right": { + "end": 150, + "raw": "2", + "start": 149, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 145, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 130, + "type": "VariableDeclarator" + }, + "end": 150, + "kind": "const", + "start": 123, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 216, + "id": { + "end": 175, + "name": "boltHexFlatLength", + "start": 158, + "type": "Identifier" + }, + "init": { + "end": 216, + "left": { + "end": 190, + "name": "boltHexDrive", + "start": 178, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 216, + "left": { + "end": 195, + "raw": "2", + "start": 194, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "operator": "*", + "right": { + "arguments": [ + { + "arguments": [ + { + "end": 214, + "raw": "30", + "start": 212, + "type": "Literal", + "type": "Literal", + "value": { + "value": 30.0, + "suffix": "None" + } + } + ], + "callee": { + "end": 211, + "name": "toRadians", + "start": 202, + "type": "Identifier" + }, + "end": 215, + "start": 202, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "callee": { + "end": 201, + "name": "cos", + "start": 198, + "type": "Identifier" + }, + "end": 216, + "start": 198, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 194, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 178, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 158, + "type": "VariableDeclarator" + }, + "end": 216, + "kind": "const", + "start": 151, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 248, + "id": { + "end": 241, + "name": "boltThreadLength", + "start": 225, + "type": "Identifier" + }, + "init": { + "end": 248, + "raw": "1.75", + "start": 244, + "type": "Literal", + "type": "Literal", + "value": { + "value": 1.75, + "suffix": "None" + } + }, + "start": 225, + "type": "VariableDeclarator" + }, + "end": 248, + "kind": "const", + "start": 218, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 1573, + "id": { + "end": 264, + "name": "bolt", + "start": 260, + "type": "Identifier" + }, + "init": { + "body": { + "body": [ + { + "declaration": { + "end": 593, + "id": { + "end": 317, + "name": "boltHead", + "start": 309, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 338, + "raw": "'XZ'", + "start": 334, + "type": "Literal", + "type": "Literal", + "value": "XZ" + } + ], + "callee": { + "end": 333, + "name": "startSketchOn", + "start": 320, + "type": "Identifier" + }, + "end": 339, + "start": 320, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 360, + "name": "center", + "start": 354, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 365, + "raw": "0", + "start": 364, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 368, + "raw": "0", + "start": 367, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 369, + "start": 363, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 377, + "name": "radius", + "start": 371, + "type": "Identifier" + }, + "arg": { + "end": 400, + "left": { + "end": 396, + "name": "boltHeadDiameter", + "start": 380, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 400, + "raw": "2", + "start": 399, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 380, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 405, + "name": "tag", + "start": 402, + "type": "Identifier" + }, + "arg": { + "end": 416, + "start": 408, + "type": "TagDeclarator", + "type": "TagDeclarator", + "value": "topEdge" + } + } + ], + "callee": { + "end": 353, + "name": "circle", + "start": 347, + "type": "Identifier" + }, + "end": 417, + "start": 347, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 439, + "name": "length", + "start": 433, + "type": "Identifier" + }, + "arg": { + "argument": { + "end": 457, + "name": "boltHeadLength", + "start": 443, + "type": "Identifier", + "type": "Identifier" + }, + "end": 457, + "operator": "-", + "start": 442, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + } + ], + "callee": { + "end": 432, + "name": "extrude", + "start": 425, + "type": "Identifier" + }, + "end": 458, + "start": 425, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 479, + "name": "radius", + "start": 473, + "type": "Identifier" + }, + "arg": { + "end": 487, + "raw": "0.020", + "start": 482, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.02, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 493, + "name": "tags", + "start": 489, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 504, + "name": "topEdge", + "start": 497, + "type": "Identifier", + "type": "Identifier" + }, + { + "arguments": [ + { + "end": 529, + "name": "topEdge", + "start": 522, + "type": "Identifier", + "type": "Identifier" + } + ], + "callee": { + "end": 521, + "name": "getOppositeEdge", + "start": 506, + "type": "Identifier" + }, + "end": 530, + "start": 506, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 531, + "start": 496, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "end": 472, + "name": "fillet", + "start": 466, + "type": "Identifier" + }, + "end": 532, + "start": 466, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 593, + "nonCodeMeta": { + "nonCodeNodes": { + "3": [ + { + "end": 593, + "start": 534, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Define the sketch of the hex pattern on the screw head", + "style": "line" + } + } + ] + }, + "startNodes": [] + }, + "start": 320, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 309, + "type": "VariableDeclarator" + }, + "end": 593, + "kind": "const", + "start": 309, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declaration": { + "end": 1258, + "id": { + "end": 612, + "name": "hexPatternSketch", + "start": 596, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 637, + "name": "boltHead", + "start": 629, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 646, + "raw": "'start'", + "start": 639, + "type": "Literal", + "type": "Literal", + "value": "start" + } + ], + "callee": { + "end": 628, + "name": "startSketchOn", + "start": 615, + "type": "Identifier" + }, + "end": 647, + "start": 615, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 697, + "left": { + "end": 693, + "name": "boltHexDrive", + "start": 681, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 697, + "raw": "2", + "start": 696, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 681, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 729, + "left": { + "end": 725, + "name": "boltHexFlatLength", + "start": 708, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 729, + "raw": "2", + "start": 728, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 708, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + ], + "end": 738, + "start": 670, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 741, + "start": 740, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 669, + "name": "startProfileAt", + "start": 655, + "type": "Identifier" + }, + "end": 742, + "start": 655, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 829, + "properties": [ + { + "end": 783, + "key": { + "end": 777, + "name": "angle", + "start": 772, + "type": "Identifier" + }, + "start": 772, + "type": "ObjectProperty", + "value": { + "end": 783, + "raw": "270", + "start": 780, + "type": "Literal", + "type": "Literal", + "value": { + "value": 270.0, + "suffix": "None" + } + } + }, + { + "end": 820, + "key": { + "end": 800, + "name": "length", + "start": 794, + "type": "Identifier" + }, + "start": 794, + "type": "ObjectProperty", + "value": { + "end": 820, + "name": "boltHexFlatLength", + "start": 803, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 761, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 832, + "start": 831, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 760, + "name": "angledLine", + "start": 750, + "type": "Identifier" + }, + "end": 833, + "start": 750, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 920, + "properties": [ + { + "end": 874, + "key": { + "end": 868, + "name": "angle", + "start": 863, + "type": "Identifier" + }, + "start": 863, + "type": "ObjectProperty", + "value": { + "end": 874, + "raw": "210", + "start": 871, + "type": "Literal", + "type": "Literal", + "value": { + "value": 210.0, + "suffix": "None" + } + } + }, + { + "end": 911, + "key": { + "end": 891, + "name": "length", + "start": 885, + "type": "Identifier" + }, + "start": 885, + "type": "ObjectProperty", + "value": { + "end": 911, + "name": "boltHexFlatLength", + "start": 894, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 852, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 923, + "start": 922, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 851, + "name": "angledLine", + "start": 841, + "type": "Identifier" + }, + "end": 924, + "start": 841, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1011, + "properties": [ + { + "end": 965, + "key": { + "end": 959, + "name": "angle", + "start": 954, + "type": "Identifier" + }, + "start": 954, + "type": "ObjectProperty", + "value": { + "end": 965, + "raw": "150", + "start": 962, + "type": "Literal", + "type": "Literal", + "value": { + "value": 150.0, + "suffix": "None" + } + } + }, + { + "end": 1002, + "key": { + "end": 982, + "name": "length", + "start": 976, + "type": "Identifier" + }, + "start": 976, + "type": "ObjectProperty", + "value": { + "end": 1002, + "name": "boltHexFlatLength", + "start": 985, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 943, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1014, + "start": 1013, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 942, + "name": "angledLine", + "start": 932, + "type": "Identifier" + }, + "end": 1015, + "start": 932, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1101, + "properties": [ + { + "end": 1055, + "key": { + "end": 1050, + "name": "angle", + "start": 1045, + "type": "Identifier" + }, + "start": 1045, + "type": "ObjectProperty", + "value": { + "end": 1055, + "raw": "90", + "start": 1053, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + }, + { + "end": 1092, + "key": { + "end": 1072, + "name": "length", + "start": 1066, + "type": "Identifier" + }, + "start": 1066, + "type": "ObjectProperty", + "value": { + "end": 1092, + "name": "boltHexFlatLength", + "start": 1075, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 1034, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1104, + "start": 1103, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 1033, + "name": "angledLine", + "start": 1023, + "type": "Identifier" + }, + "end": 1105, + "start": 1023, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1191, + "properties": [ + { + "end": 1145, + "key": { + "end": 1140, + "name": "angle", + "start": 1135, + "type": "Identifier" + }, + "start": 1135, + "type": "ObjectProperty", + "value": { + "end": 1145, + "raw": "30", + "start": 1143, + "type": "Literal", + "type": "Literal", + "value": { + "value": 30.0, + "suffix": "None" + } + } + }, + { + "end": 1182, + "key": { + "end": 1162, + "name": "length", + "start": 1156, + "type": "Identifier" + }, + "start": 1156, + "type": "ObjectProperty", + "value": { + "end": 1182, + "name": "boltHexFlatLength", + "start": 1165, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 1124, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1194, + "start": 1193, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 1123, + "name": "angledLine", + "start": 1113, + "type": "Identifier" + }, + "end": 1195, + "start": 1113, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [], + "callee": { + "end": 1208, + "name": "close", + "start": 1203, + "type": "Identifier" + }, + "end": 1210, + "start": 1203, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1232, + "name": "length", + "start": 1226, + "type": "Identifier" + }, + "arg": { + "end": 1257, + "left": { + "argument": { + "end": 1250, + "name": "boltHeadLength", + "start": 1236, + "type": "Identifier", + "type": "Identifier" + }, + "end": 1250, + "operator": "-", + "start": 1235, + "type": "UnaryExpression", + "type": "UnaryExpression" + }, + "operator": "*", + "right": { + "end": 1257, + "raw": "0.75", + "start": 1253, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.75, + "suffix": "None" + } + }, + "start": 1235, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + } + ], + "callee": { + "end": 1225, + "name": "extrude", + "start": 1218, + "type": "Identifier" + }, + "end": 1258, + "start": 1218, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1258, + "start": 615, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 596, + "type": "VariableDeclarator" + }, + "end": 1258, + "kind": "const", + "start": 596, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declaration": { + "end": 1552, + "id": { + "end": 1270, + "name": "boltBody", + "start": 1262, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 1295, + "name": "boltHead", + "start": 1287, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 1302, + "raw": "'end'", + "start": 1297, + "type": "Literal", + "type": "Literal", + "value": "end" + } + ], + "callee": { + "end": 1286, + "name": "startSketchOn", + "start": 1273, + "type": "Identifier" + }, + "end": 1303, + "start": 1273, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1324, + "name": "center", + "start": 1318, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 1329, + "raw": "0", + "start": 1328, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 1332, + "raw": "0", + "start": 1331, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 1333, + "start": 1327, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1341, + "name": "radius", + "start": 1335, + "type": "Identifier" + }, + "arg": { + "end": 1360, + "left": { + "end": 1356, + "name": "boltDiameter", + "start": 1344, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 1360, + "raw": "2", + "start": 1359, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 1344, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1365, + "name": "tag", + "start": 1362, + "type": "Identifier" + }, + "arg": { + "end": 1379, + "start": 1368, + "type": "TagDeclarator", + "type": "TagDeclarator", + "value": "filletEdge" + } + } + ], + "callee": { + "end": 1317, + "name": "circle", + "start": 1311, + "type": "Identifier" + }, + "end": 1380, + "start": 1311, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1402, + "name": "length", + "start": 1396, + "type": "Identifier" + }, + "arg": { + "end": 1415, + "name": "boltLength", + "start": 1405, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "callee": { + "end": 1395, + "name": "extrude", + "start": 1388, + "type": "Identifier" + }, + "end": 1416, + "start": 1388, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1437, + "name": "radius", + "start": 1431, + "type": "Identifier" + }, + "arg": { + "end": 1444, + "raw": ".020", + "start": 1440, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.02, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1450, + "name": "tags", + "start": 1446, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "arguments": [ + { + "end": 1480, + "name": "filletEdge", + "start": 1470, + "type": "Identifier", + "type": "Identifier" + } + ], + "callee": { + "end": 1469, + "name": "getOppositeEdge", + "start": 1454, + "type": "Identifier" + }, + "end": 1481, + "start": 1454, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 1482, + "start": 1453, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "end": 1430, + "name": "fillet", + "start": 1424, + "type": "Identifier" + }, + "end": 1483, + "start": 1424, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1507, + "name": "color", + "start": 1502, + "type": "Identifier" + }, + "arg": { + "end": 1519, + "raw": "\"#4dd043\"", + "start": 1510, + "type": "Literal", + "type": "Literal", + "value": "#4dd043" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1530, + "name": "metalness", + "start": 1521, + "type": "Identifier" + }, + "arg": { + "end": 1535, + "raw": "90", + "start": 1533, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1546, + "name": "roughness", + "start": 1537, + "type": "Identifier" + }, + "arg": { + "end": 1551, + "raw": "90", + "start": 1549, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + } + ], + "callee": { + "end": 1501, + "name": "appearance", + "start": 1491, + "type": "Identifier" + }, + "end": 1552, + "start": 1491, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1552, + "start": 1273, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 1262, + "type": "VariableDeclarator" + }, + "end": 1552, + "kind": "const", + "start": 1262, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "argument": { + "end": 1571, + "name": "boltBody", + "start": 1563, + "type": "Identifier", + "type": "Identifier" + }, + "end": 1571, + "start": 1556, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 1573, + "nonCodeMeta": { + "nonCodeNodes": { + "1": [ + { + "end": 1262, + "start": 1258, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "2": [ + { + "end": 1556, + "start": 1552, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [ + { + "end": 307, + "start": 268, + "type": "NonCodeNode", + "value": { + "type": "blockComment", + "value": "Create the head of the cap screw", + "style": "line" + } + } + ] + }, + "start": 268 + }, + "end": 1573, + "params": [], + "start": 264, + "type": "FunctionExpression", + "type": "FunctionExpression" + }, + "start": 260, + "type": "VariableDeclarator" + }, + "end": 1573, + "kind": "fn", + "start": 250, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "end": 1672, + "expression": { + "body": [ + { + "arguments": [], + "callee": { + "end": 1579, + "name": "bolt", + "start": 1575, + "type": "Identifier" + }, + "end": 1581, + "start": 1575, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1598, + "name": "roll", + "start": 1594, + "type": "Identifier" + }, + "arg": { + "end": 1605, + "raw": "3.14", + "start": 1601, + "type": "Literal", + "type": "Literal", + "value": { + "value": 3.14, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1612, + "name": "pitch", + "start": 1607, + "type": "Identifier" + }, + "arg": { + "end": 1619, + "raw": "3.14", + "start": 1615, + "type": "Literal", + "type": "Literal", + "value": { + "value": 3.14, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1624, + "name": "yaw", + "start": 1621, + "type": "Identifier" + }, + "arg": { + "end": 1631, + "raw": "3.14", + "start": 1627, + "type": "Literal", + "type": "Literal", + "value": { + "value": 3.14, + "suffix": "None" + } + } + } + ], + "callee": { + "end": 1593, + "name": "rotate", + "start": 1587, + "type": "Identifier" + }, + "end": 1632, + "start": 1587, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1672, + "nonCodeMeta": { + "nonCodeNodes": { + "1": [ + { + "end": 1672, + "start": 1632, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "https://www.mcmaster.com/91251a404/", + "style": "line" + } + } + ] + }, + "startNodes": [] + }, + "start": 1575, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 1575, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 1673, + "nonCodeMeta": { + "nonCodeNodes": { + "6": [ + { + "end": 250, + "start": 248, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "7": [ + { + "end": 1575, + "start": 1573, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [] + }, + "start": 0 + } +} diff --git a/rust/kcl-lib/tests/rotate_after_fillet/input.kcl b/rust/kcl-lib/tests/rotate_after_fillet/input.kcl new file mode 100644 index 000000000..873f155cb --- /dev/null +++ b/rust/kcl-lib/tests/rotate_after_fillet/input.kcl @@ -0,0 +1,57 @@ +export boltDiameter = 0.625 +export boltLength = 2.500 +export boltHeadLength = boltDiameter +export boltHeadDiameter = 0.938 +export boltHexDrive = 1 / 2 +export boltHexFlatLength = boltHexDrive / (2 * cos(toRadians(30))) +export boltThreadLength = 1.75 + +export fn bolt() { + // Create the head of the cap screw + boltHead = startSketchOn('XZ') + |> circle(center = [0, 0], radius = boltHeadDiameter / 2, tag = $topEdge) + |> extrude(length = -boltHeadLength) + |> fillet(radius = 0.020, tags = [topEdge, getOppositeEdge(topEdge)]) + + // Define the sketch of the hex pattern on the screw head + hexPatternSketch = startSketchOn(boltHead, 'start') + |> startProfileAt([ + boltHexDrive / 2, + boltHexFlatLength / 2 + ], %) + |> angledLine({ + angle = 270, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 210, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 150, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 90, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 30, + length = boltHexFlatLength + }, %) + |> close() + |> extrude(length = -boltHeadLength * 0.75) + + boltBody = startSketchOn(boltHead, 'end') + |> circle(center = [0, 0], radius = boltDiameter / 2, tag = $filletEdge) + |> extrude(length = boltLength) + |> fillet(radius = .020, tags = [getOppositeEdge(filletEdge)]) + |> appearance(color = "#4dd043", metalness = 90, roughness = 90) + + return boltBody +} + +bolt() + |> rotate(roll = 3.14, pitch = 3.14, yaw = 3.14) + +// https://www.mcmaster.com/91251a404/ diff --git a/rust/kcl-lib/tests/rotate_after_fillet/ops.snap b/rust/kcl-lib/tests/rotate_after_fillet/ops.snap new file mode 100644 index 000000000..2aa95c43d --- /dev/null +++ b/rust/kcl-lib/tests/rotate_after_fillet/ops.snap @@ -0,0 +1,390 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Operations executed rotate_after_fillet.kcl +--- +[ + { + "type": "UserDefinedFunctionCall", + "name": "cos", + "functionSourceRange": [ + 0, + 0, + 0 + ], + "unlabeledArg": null, + "labeledArgs": {}, + "sourceRange": [ + 198, + 216, + 0 + ] + }, + { + "type": "UserDefinedFunctionReturn" + }, + { + "type": "UserDefinedFunctionCall", + "name": "bolt", + "functionSourceRange": [ + 264, + 1573, + 0 + ], + "unlabeledArg": null, + "labeledArgs": {}, + "sourceRange": [ + 1575, + 1581, + 0 + ] + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "String", + "value": "XZ" + }, + "sourceRange": [ + 334, + 338, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 320, + 339, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": -0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 442, + 457, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 425, + 458, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 425, + 458, + 0 + ] + } + }, + { + "labeledArgs": { + "radius": { + "value": { + "type": "Number", + "value": 0.02, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 482, + 487, + 0 + ] + }, + "tags": { + "value": { + "type": "Array", + "value": [ + { + "type": "TagIdentifier", + "value": "topEdge", + "artifact_id": "[uuid]" + }, + { + "type": "Uuid", + "value": "[uuid]" + } + ] + }, + "sourceRange": [ + 496, + 531, + 0 + ] + } + }, + "name": "fillet", + "sourceRange": [ + 466, + 532, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 466, + 532, + 0 + ] + } + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 629, + 637, + 0 + ] + }, + "tag": { + "value": { + "type": "String", + "value": "start" + }, + "sourceRange": [ + 639, + 646, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 615, + 647, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": -0.46875, + "ty": { + "type": "Unknown" + } + }, + "sourceRange": [ + 1235, + 1257, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 1218, + 1258, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1218, + 1258, + 0 + ] + } + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1287, + 1295, + 0 + ] + }, + "tag": { + "value": { + "type": "String", + "value": "end" + }, + "sourceRange": [ + 1297, + 1302, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 1273, + 1303, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": 2.5, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 1405, + 1415, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 1388, + 1416, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1388, + 1416, + 0 + ] + } + }, + { + "labeledArgs": { + "radius": { + "value": { + "type": "Number", + "value": 0.02, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 1440, + 1444, + 0 + ] + }, + "tags": { + "value": { + "type": "Array", + "value": [ + { + "type": "Uuid", + "value": "[uuid]" + } + ] + }, + "sourceRange": [ + 1453, + 1482, + 0 + ] + } + }, + "name": "fillet", + "sourceRange": [ + 1424, + 1483, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1424, + 1483, + 0 + ] + } + }, + { + "type": "UserDefinedFunctionReturn" + } +] diff --git a/rust/kcl-lib/tests/rotate_after_fillet/program_memory.snap b/rust/kcl-lib/tests/rotate_after_fillet/program_memory.snap new file mode 100644 index 000000000..0f5a92bef --- /dev/null +++ b/rust/kcl-lib/tests/rotate_after_fillet/program_memory.snap @@ -0,0 +1,93 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Variables in memory after executing rotate_after_fillet.kcl +--- +{ + "bolt": { + "type": "Function" + }, + "boltDiameter": { + "type": "Number", + "value": 0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHeadDiameter": { + "type": "Number", + "value": 0.938, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHeadLength": { + "type": "Number", + "value": 0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHexDrive": { + "type": "Number", + "value": 0.5, + "ty": { + "type": "Unknown" + } + }, + "boltHexFlatLength": { + "type": "Number", + "value": 0.2887, + "ty": { + "type": "Unknown" + } + }, + "boltLength": { + "type": "Number", + "value": 2.5, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltThreadLength": { + "type": "Number", + "value": 1.75, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "filletEdge": { + "type": "TagIdentifier", + "type": "TagIdentifier", + "value": "filletEdge" + } +} diff --git a/rust/kcl-lib/tests/rotate_after_fillet/rendered_model.png b/rust/kcl-lib/tests/rotate_after_fillet/rendered_model.png new file mode 100644 index 000000000..9ce91d896 Binary files /dev/null and b/rust/kcl-lib/tests/rotate_after_fillet/rendered_model.png differ diff --git a/rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap b/rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap new file mode 100644 index 000000000..e76a760e8 --- /dev/null +++ b/rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap @@ -0,0 +1,1004 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Artifact commands scale_after_fillet.kcl +--- +[ + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "edge_lines_visible", + "hidden": false + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "set_scene_units", + "unit": "mm" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 320, + 339, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "size": 60.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.469, + "y": 0.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "arc", + "center": { + "x": 0.0, + "y": 0.0 + }, + "radius": 0.469, + "start": { + "unit": "degrees", + "value": 0.0 + }, + "end": { + "unit": "degrees", + "value": 360.0 + }, + "relative": false + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": -0.625, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 506, + 530, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 466, + 532, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 466, + 532, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.25, + "y": 0.14433756729740643, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 750, + 833, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.0, + "y": -0.2887, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 841, + 924, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.25, + "y": -0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 932, + 1015, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.25, + "y": 0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1023, + 1105, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.0, + "y": 0.2887, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1113, + 1195, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.25, + "y": 0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1203, + 1210, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": -0.46875, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.3125, + "y": 0.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "arc", + "center": { + "x": 0.0, + "y": 0.0 + }, + "radius": 0.3125, + "start": { + "unit": "degrees", + "value": 0.0 + }, + "end": { + "unit": "degrees", + "value": 360.0 + }, + "relative": false + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": 2.5, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1454, + 1481, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1491, + 1552, + 0 + ], + "command": { + "type": "object_set_material_params_pbr", + "object_id": "[uuid]", + "color": { + "r": 0.3019608, + "g": 0.8156863, + "b": 0.2627451, + "a": 100.0 + }, + "metalness": 0.9, + "roughness": 0.9, + "ambient_occlusion": 0.0 + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1424, + 1483, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1587, + 1620, + 0 + ], + "command": { + "type": "set_object_transform", + "object_id": "[uuid]", + "transforms": [ + { + "translate": null, + "rotate_rpy": null, + "rotate_angle_axis": null, + "scale": { + "property": { + "x": 3.14, + "y": 3.14, + "z": 3.14 + }, + "set": false, + "is_local": true + } + } + ] + } + } +] diff --git a/rust/kcl-lib/tests/scale_after_fillet/artifact_graph_flowchart.snap b/rust/kcl-lib/tests/scale_after_fillet/artifact_graph_flowchart.snap new file mode 100644 index 000000000..f28b56a93 --- /dev/null +++ b/rust/kcl-lib/tests/scale_after_fillet/artifact_graph_flowchart.snap @@ -0,0 +1,6 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Artifact graph flowchart scale_after_fillet.kcl +extension: md +snapshot_kind: binary +--- diff --git a/rust/kcl-lib/tests/scale_after_fillet/artifact_graph_flowchart.snap.md b/rust/kcl-lib/tests/scale_after_fillet/artifact_graph_flowchart.snap.md new file mode 100644 index 000000000..264c6b7a7 --- /dev/null +++ b/rust/kcl-lib/tests/scale_after_fillet/artifact_graph_flowchart.snap.md @@ -0,0 +1,134 @@ +```mermaid +flowchart LR + subgraph path2 [Path] + 2["Path
[347, 417, 0]"] + 3["Segment
[347, 417, 0]"] + 4[Solid2d] + end + subgraph path13 [Path] + 13["Path
[655, 742, 0]"] + 14["Segment
[750, 833, 0]"] + 15["Segment
[841, 924, 0]"] + 16["Segment
[932, 1015, 0]"] + 17["Segment
[1023, 1105, 0]"] + 18["Segment
[1113, 1195, 0]"] + 19["Segment
[1203, 1210, 0]"] + 20[Solid2d] + end + subgraph path41 [Path] + 41["Path
[1311, 1380, 0]"] + 42["Segment
[1311, 1380, 0]"] + 43[Solid2d] + end + 1["Plane
[320, 339, 0]"] + 5["Sweep Extrusion
[425, 458, 0]"] + 6[Wall] + 7["Cap Start"] + 8["Cap End"] + 9["SweepEdge Opposite"] + 10["SweepEdge Adjacent"] + 11["EdgeCut Fillet
[466, 532, 0]"] + 12["EdgeCut Fillet
[466, 532, 0]"] + 21["Sweep Extrusion
[1218, 1258, 0]"] + 22[Wall] + 23[Wall] + 24[Wall] + 25[Wall] + 26[Wall] + 27[Wall] + 28["Cap Start"] + 29["SweepEdge Opposite"] + 30["SweepEdge Adjacent"] + 31["SweepEdge Opposite"] + 32["SweepEdge Adjacent"] + 33["SweepEdge Opposite"] + 34["SweepEdge Adjacent"] + 35["SweepEdge Opposite"] + 36["SweepEdge Adjacent"] + 37["SweepEdge Opposite"] + 38["SweepEdge Adjacent"] + 39["SweepEdge Opposite"] + 40["SweepEdge Adjacent"] + 44["Sweep Extrusion
[1388, 1416, 0]"] + 45[Wall] + 46["Cap End"] + 47["SweepEdge Opposite"] + 48["SweepEdge Adjacent"] + 49["EdgeCut Fillet
[1424, 1483, 0]"] + 50["StartSketchOnFace
[615, 647, 0]"] + 51["StartSketchOnFace
[1273, 1303, 0]"] + 1 --- 2 + 2 --- 3 + 2 ---- 5 + 2 --- 4 + 3 --- 6 + 3 --- 9 + 3 --- 10 + 3 --- 11 + 5 --- 6 + 5 --- 7 + 5 --- 8 + 5 --- 9 + 5 --- 10 + 7 --- 13 + 8 --- 41 + 9 <--x 12 + 13 --- 14 + 13 --- 15 + 13 --- 16 + 13 --- 17 + 13 --- 18 + 13 --- 19 + 13 ---- 21 + 13 --- 20 + 14 --- 27 + 14 --- 39 + 14 --- 40 + 15 --- 26 + 15 --- 37 + 15 --- 38 + 16 --- 25 + 16 --- 35 + 16 --- 36 + 17 --- 24 + 17 --- 33 + 17 --- 34 + 18 --- 23 + 18 --- 31 + 18 --- 32 + 19 --- 22 + 19 --- 29 + 19 --- 30 + 21 --- 22 + 21 --- 23 + 21 --- 24 + 21 --- 25 + 21 --- 26 + 21 --- 27 + 21 --- 28 + 21 --- 29 + 21 --- 30 + 21 --- 31 + 21 --- 32 + 21 --- 33 + 21 --- 34 + 21 --- 35 + 21 --- 36 + 21 --- 37 + 21 --- 38 + 21 --- 39 + 21 --- 40 + 41 --- 42 + 41 ---- 44 + 41 --- 43 + 42 --- 45 + 42 --- 47 + 42 --- 48 + 44 --- 45 + 44 --- 46 + 44 --- 47 + 44 --- 48 + 47 <--x 49 + 7 <--x 50 + 8 <--x 51 +``` diff --git a/rust/kcl-lib/tests/scale_after_fillet/ast.snap b/rust/kcl-lib/tests/scale_after_fillet/ast.snap new file mode 100644 index 000000000..83a3c4fc7 --- /dev/null +++ b/rust/kcl-lib/tests/scale_after_fillet/ast.snap @@ -0,0 +1,1675 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Result of parsing scale_after_fillet.kcl +--- +{ + "Ok": { + "body": [ + { + "declaration": { + "end": 27, + "id": { + "end": 19, + "name": "boltDiameter", + "start": 7, + "type": "Identifier" + }, + "init": { + "end": 27, + "raw": "0.625", + "start": 22, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.625, + "suffix": "None" + } + }, + "start": 7, + "type": "VariableDeclarator" + }, + "end": 27, + "kind": "const", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 53, + "id": { + "end": 45, + "name": "boltLength", + "start": 35, + "type": "Identifier" + }, + "init": { + "end": 53, + "raw": "2.500", + "start": 48, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.5, + "suffix": "None" + } + }, + "start": 35, + "type": "VariableDeclarator" + }, + "end": 53, + "kind": "const", + "start": 28, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 90, + "id": { + "end": 75, + "name": "boltHeadLength", + "start": 61, + "type": "Identifier" + }, + "init": { + "end": 90, + "name": "boltDiameter", + "start": 78, + "type": "Identifier", + "type": "Identifier" + }, + "start": 61, + "type": "VariableDeclarator" + }, + "end": 90, + "kind": "const", + "start": 54, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 122, + "id": { + "end": 114, + "name": "boltHeadDiameter", + "start": 98, + "type": "Identifier" + }, + "init": { + "end": 122, + "raw": "0.938", + "start": 117, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.938, + "suffix": "None" + } + }, + "start": 98, + "type": "VariableDeclarator" + }, + "end": 122, + "kind": "const", + "start": 91, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 150, + "id": { + "end": 142, + "name": "boltHexDrive", + "start": 130, + "type": "Identifier" + }, + "init": { + "end": 150, + "left": { + "end": 146, + "raw": "1", + "start": 145, + "type": "Literal", + "type": "Literal", + "value": { + "value": 1.0, + "suffix": "None" + } + }, + "operator": "/", + "right": { + "end": 150, + "raw": "2", + "start": 149, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 145, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 130, + "type": "VariableDeclarator" + }, + "end": 150, + "kind": "const", + "start": 123, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 216, + "id": { + "end": 175, + "name": "boltHexFlatLength", + "start": 158, + "type": "Identifier" + }, + "init": { + "end": 216, + "left": { + "end": 190, + "name": "boltHexDrive", + "start": 178, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 216, + "left": { + "end": 195, + "raw": "2", + "start": 194, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "operator": "*", + "right": { + "arguments": [ + { + "arguments": [ + { + "end": 214, + "raw": "30", + "start": 212, + "type": "Literal", + "type": "Literal", + "value": { + "value": 30.0, + "suffix": "None" + } + } + ], + "callee": { + "end": 211, + "name": "toRadians", + "start": 202, + "type": "Identifier" + }, + "end": 215, + "start": 202, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "callee": { + "end": 201, + "name": "cos", + "start": 198, + "type": "Identifier" + }, + "end": 216, + "start": 198, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 194, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 178, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 158, + "type": "VariableDeclarator" + }, + "end": 216, + "kind": "const", + "start": 151, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 248, + "id": { + "end": 241, + "name": "boltThreadLength", + "start": 225, + "type": "Identifier" + }, + "init": { + "end": 248, + "raw": "1.75", + "start": 244, + "type": "Literal", + "type": "Literal", + "value": { + "value": 1.75, + "suffix": "None" + } + }, + "start": 225, + "type": "VariableDeclarator" + }, + "end": 248, + "kind": "const", + "start": 218, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 1573, + "id": { + "end": 264, + "name": "bolt", + "start": 260, + "type": "Identifier" + }, + "init": { + "body": { + "body": [ + { + "declaration": { + "end": 593, + "id": { + "end": 317, + "name": "boltHead", + "start": 309, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 338, + "raw": "'XZ'", + "start": 334, + "type": "Literal", + "type": "Literal", + "value": "XZ" + } + ], + "callee": { + "end": 333, + "name": "startSketchOn", + "start": 320, + "type": "Identifier" + }, + "end": 339, + "start": 320, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 360, + "name": "center", + "start": 354, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 365, + "raw": "0", + "start": 364, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 368, + "raw": "0", + "start": 367, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 369, + "start": 363, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 377, + "name": "radius", + "start": 371, + "type": "Identifier" + }, + "arg": { + "end": 400, + "left": { + "end": 396, + "name": "boltHeadDiameter", + "start": 380, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 400, + "raw": "2", + "start": 399, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 380, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 405, + "name": "tag", + "start": 402, + "type": "Identifier" + }, + "arg": { + "end": 416, + "start": 408, + "type": "TagDeclarator", + "type": "TagDeclarator", + "value": "topEdge" + } + } + ], + "callee": { + "end": 353, + "name": "circle", + "start": 347, + "type": "Identifier" + }, + "end": 417, + "start": 347, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 439, + "name": "length", + "start": 433, + "type": "Identifier" + }, + "arg": { + "argument": { + "end": 457, + "name": "boltHeadLength", + "start": 443, + "type": "Identifier", + "type": "Identifier" + }, + "end": 457, + "operator": "-", + "start": 442, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + } + ], + "callee": { + "end": 432, + "name": "extrude", + "start": 425, + "type": "Identifier" + }, + "end": 458, + "start": 425, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 479, + "name": "radius", + "start": 473, + "type": "Identifier" + }, + "arg": { + "end": 487, + "raw": "0.020", + "start": 482, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.02, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 493, + "name": "tags", + "start": 489, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 504, + "name": "topEdge", + "start": 497, + "type": "Identifier", + "type": "Identifier" + }, + { + "arguments": [ + { + "end": 529, + "name": "topEdge", + "start": 522, + "type": "Identifier", + "type": "Identifier" + } + ], + "callee": { + "end": 521, + "name": "getOppositeEdge", + "start": 506, + "type": "Identifier" + }, + "end": 530, + "start": 506, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 531, + "start": 496, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "end": 472, + "name": "fillet", + "start": 466, + "type": "Identifier" + }, + "end": 532, + "start": 466, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 593, + "nonCodeMeta": { + "nonCodeNodes": { + "3": [ + { + "end": 593, + "start": 534, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Define the sketch of the hex pattern on the screw head", + "style": "line" + } + } + ] + }, + "startNodes": [] + }, + "start": 320, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 309, + "type": "VariableDeclarator" + }, + "end": 593, + "kind": "const", + "start": 309, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declaration": { + "end": 1258, + "id": { + "end": 612, + "name": "hexPatternSketch", + "start": 596, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 637, + "name": "boltHead", + "start": 629, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 646, + "raw": "'start'", + "start": 639, + "type": "Literal", + "type": "Literal", + "value": "start" + } + ], + "callee": { + "end": 628, + "name": "startSketchOn", + "start": 615, + "type": "Identifier" + }, + "end": 647, + "start": 615, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 697, + "left": { + "end": 693, + "name": "boltHexDrive", + "start": 681, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 697, + "raw": "2", + "start": 696, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 681, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 729, + "left": { + "end": 725, + "name": "boltHexFlatLength", + "start": 708, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 729, + "raw": "2", + "start": 728, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 708, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + ], + "end": 738, + "start": 670, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 741, + "start": 740, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 669, + "name": "startProfileAt", + "start": 655, + "type": "Identifier" + }, + "end": 742, + "start": 655, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 829, + "properties": [ + { + "end": 783, + "key": { + "end": 777, + "name": "angle", + "start": 772, + "type": "Identifier" + }, + "start": 772, + "type": "ObjectProperty", + "value": { + "end": 783, + "raw": "270", + "start": 780, + "type": "Literal", + "type": "Literal", + "value": { + "value": 270.0, + "suffix": "None" + } + } + }, + { + "end": 820, + "key": { + "end": 800, + "name": "length", + "start": 794, + "type": "Identifier" + }, + "start": 794, + "type": "ObjectProperty", + "value": { + "end": 820, + "name": "boltHexFlatLength", + "start": 803, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 761, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 832, + "start": 831, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 760, + "name": "angledLine", + "start": 750, + "type": "Identifier" + }, + "end": 833, + "start": 750, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 920, + "properties": [ + { + "end": 874, + "key": { + "end": 868, + "name": "angle", + "start": 863, + "type": "Identifier" + }, + "start": 863, + "type": "ObjectProperty", + "value": { + "end": 874, + "raw": "210", + "start": 871, + "type": "Literal", + "type": "Literal", + "value": { + "value": 210.0, + "suffix": "None" + } + } + }, + { + "end": 911, + "key": { + "end": 891, + "name": "length", + "start": 885, + "type": "Identifier" + }, + "start": 885, + "type": "ObjectProperty", + "value": { + "end": 911, + "name": "boltHexFlatLength", + "start": 894, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 852, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 923, + "start": 922, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 851, + "name": "angledLine", + "start": 841, + "type": "Identifier" + }, + "end": 924, + "start": 841, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1011, + "properties": [ + { + "end": 965, + "key": { + "end": 959, + "name": "angle", + "start": 954, + "type": "Identifier" + }, + "start": 954, + "type": "ObjectProperty", + "value": { + "end": 965, + "raw": "150", + "start": 962, + "type": "Literal", + "type": "Literal", + "value": { + "value": 150.0, + "suffix": "None" + } + } + }, + { + "end": 1002, + "key": { + "end": 982, + "name": "length", + "start": 976, + "type": "Identifier" + }, + "start": 976, + "type": "ObjectProperty", + "value": { + "end": 1002, + "name": "boltHexFlatLength", + "start": 985, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 943, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1014, + "start": 1013, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 942, + "name": "angledLine", + "start": 932, + "type": "Identifier" + }, + "end": 1015, + "start": 932, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1101, + "properties": [ + { + "end": 1055, + "key": { + "end": 1050, + "name": "angle", + "start": 1045, + "type": "Identifier" + }, + "start": 1045, + "type": "ObjectProperty", + "value": { + "end": 1055, + "raw": "90", + "start": 1053, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + }, + { + "end": 1092, + "key": { + "end": 1072, + "name": "length", + "start": 1066, + "type": "Identifier" + }, + "start": 1066, + "type": "ObjectProperty", + "value": { + "end": 1092, + "name": "boltHexFlatLength", + "start": 1075, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 1034, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1104, + "start": 1103, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 1033, + "name": "angledLine", + "start": 1023, + "type": "Identifier" + }, + "end": 1105, + "start": 1023, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1191, + "properties": [ + { + "end": 1145, + "key": { + "end": 1140, + "name": "angle", + "start": 1135, + "type": "Identifier" + }, + "start": 1135, + "type": "ObjectProperty", + "value": { + "end": 1145, + "raw": "30", + "start": 1143, + "type": "Literal", + "type": "Literal", + "value": { + "value": 30.0, + "suffix": "None" + } + } + }, + { + "end": 1182, + "key": { + "end": 1162, + "name": "length", + "start": 1156, + "type": "Identifier" + }, + "start": 1156, + "type": "ObjectProperty", + "value": { + "end": 1182, + "name": "boltHexFlatLength", + "start": 1165, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 1124, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1194, + "start": 1193, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 1123, + "name": "angledLine", + "start": 1113, + "type": "Identifier" + }, + "end": 1195, + "start": 1113, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [], + "callee": { + "end": 1208, + "name": "close", + "start": 1203, + "type": "Identifier" + }, + "end": 1210, + "start": 1203, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1232, + "name": "length", + "start": 1226, + "type": "Identifier" + }, + "arg": { + "end": 1257, + "left": { + "argument": { + "end": 1250, + "name": "boltHeadLength", + "start": 1236, + "type": "Identifier", + "type": "Identifier" + }, + "end": 1250, + "operator": "-", + "start": 1235, + "type": "UnaryExpression", + "type": "UnaryExpression" + }, + "operator": "*", + "right": { + "end": 1257, + "raw": "0.75", + "start": 1253, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.75, + "suffix": "None" + } + }, + "start": 1235, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + } + ], + "callee": { + "end": 1225, + "name": "extrude", + "start": 1218, + "type": "Identifier" + }, + "end": 1258, + "start": 1218, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1258, + "start": 615, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 596, + "type": "VariableDeclarator" + }, + "end": 1258, + "kind": "const", + "start": 596, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declaration": { + "end": 1552, + "id": { + "end": 1270, + "name": "boltBody", + "start": 1262, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 1295, + "name": "boltHead", + "start": 1287, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 1302, + "raw": "'end'", + "start": 1297, + "type": "Literal", + "type": "Literal", + "value": "end" + } + ], + "callee": { + "end": 1286, + "name": "startSketchOn", + "start": 1273, + "type": "Identifier" + }, + "end": 1303, + "start": 1273, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1324, + "name": "center", + "start": 1318, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 1329, + "raw": "0", + "start": 1328, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 1332, + "raw": "0", + "start": 1331, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 1333, + "start": 1327, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1341, + "name": "radius", + "start": 1335, + "type": "Identifier" + }, + "arg": { + "end": 1360, + "left": { + "end": 1356, + "name": "boltDiameter", + "start": 1344, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 1360, + "raw": "2", + "start": 1359, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 1344, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1365, + "name": "tag", + "start": 1362, + "type": "Identifier" + }, + "arg": { + "end": 1379, + "start": 1368, + "type": "TagDeclarator", + "type": "TagDeclarator", + "value": "filletEdge" + } + } + ], + "callee": { + "end": 1317, + "name": "circle", + "start": 1311, + "type": "Identifier" + }, + "end": 1380, + "start": 1311, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1402, + "name": "length", + "start": 1396, + "type": "Identifier" + }, + "arg": { + "end": 1415, + "name": "boltLength", + "start": 1405, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "callee": { + "end": 1395, + "name": "extrude", + "start": 1388, + "type": "Identifier" + }, + "end": 1416, + "start": 1388, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1437, + "name": "radius", + "start": 1431, + "type": "Identifier" + }, + "arg": { + "end": 1444, + "raw": ".020", + "start": 1440, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.02, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1450, + "name": "tags", + "start": 1446, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "arguments": [ + { + "end": 1480, + "name": "filletEdge", + "start": 1470, + "type": "Identifier", + "type": "Identifier" + } + ], + "callee": { + "end": 1469, + "name": "getOppositeEdge", + "start": 1454, + "type": "Identifier" + }, + "end": 1481, + "start": 1454, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 1482, + "start": 1453, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "end": 1430, + "name": "fillet", + "start": 1424, + "type": "Identifier" + }, + "end": 1483, + "start": 1424, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1507, + "name": "color", + "start": 1502, + "type": "Identifier" + }, + "arg": { + "end": 1519, + "raw": "\"#4dd043\"", + "start": 1510, + "type": "Literal", + "type": "Literal", + "value": "#4dd043" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1530, + "name": "metalness", + "start": 1521, + "type": "Identifier" + }, + "arg": { + "end": 1535, + "raw": "90", + "start": 1533, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1546, + "name": "roughness", + "start": 1537, + "type": "Identifier" + }, + "arg": { + "end": 1551, + "raw": "90", + "start": 1549, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + } + ], + "callee": { + "end": 1501, + "name": "appearance", + "start": 1491, + "type": "Identifier" + }, + "end": 1552, + "start": 1491, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1552, + "start": 1273, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 1262, + "type": "VariableDeclarator" + }, + "end": 1552, + "kind": "const", + "start": 1262, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "argument": { + "end": 1571, + "name": "boltBody", + "start": 1563, + "type": "Identifier", + "type": "Identifier" + }, + "end": 1571, + "start": 1556, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 1573, + "nonCodeMeta": { + "nonCodeNodes": { + "1": [ + { + "end": 1262, + "start": 1258, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "2": [ + { + "end": 1556, + "start": 1552, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [ + { + "end": 307, + "start": 268, + "type": "NonCodeNode", + "value": { + "type": "blockComment", + "value": "Create the head of the cap screw", + "style": "line" + } + } + ] + }, + "start": 268 + }, + "end": 1573, + "params": [], + "start": 264, + "type": "FunctionExpression", + "type": "FunctionExpression" + }, + "start": 260, + "type": "VariableDeclarator" + }, + "end": 1573, + "kind": "fn", + "start": 250, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "end": 1660, + "expression": { + "body": [ + { + "arguments": [], + "callee": { + "end": 1579, + "name": "bolt", + "start": 1575, + "type": "Identifier" + }, + "end": 1581, + "start": 1575, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1598, + "name": "scale", + "start": 1593, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 1606, + "raw": "3.14", + "start": 1602, + "type": "Literal", + "type": "Literal", + "value": { + "value": 3.14, + "suffix": "None" + } + }, + { + "end": 1612, + "raw": "3.14", + "start": 1608, + "type": "Literal", + "type": "Literal", + "value": { + "value": 3.14, + "suffix": "None" + } + }, + { + "end": 1618, + "raw": "3.14", + "start": 1614, + "type": "Literal", + "type": "Literal", + "value": { + "value": 3.14, + "suffix": "None" + } + } + ], + "end": 1619, + "start": 1601, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "end": 1592, + "name": "scale", + "start": 1587, + "type": "Identifier" + }, + "end": 1620, + "start": 1587, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1660, + "nonCodeMeta": { + "nonCodeNodes": { + "1": [ + { + "end": 1660, + "start": 1620, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "https://www.mcmaster.com/91251a404/", + "style": "line" + } + } + ] + }, + "startNodes": [] + }, + "start": 1575, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 1575, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 1661, + "nonCodeMeta": { + "nonCodeNodes": { + "6": [ + { + "end": 250, + "start": 248, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "7": [ + { + "end": 1575, + "start": 1573, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [] + }, + "start": 0 + } +} diff --git a/rust/kcl-lib/tests/scale_after_fillet/input.kcl b/rust/kcl-lib/tests/scale_after_fillet/input.kcl new file mode 100644 index 000000000..975256834 --- /dev/null +++ b/rust/kcl-lib/tests/scale_after_fillet/input.kcl @@ -0,0 +1,57 @@ +export boltDiameter = 0.625 +export boltLength = 2.500 +export boltHeadLength = boltDiameter +export boltHeadDiameter = 0.938 +export boltHexDrive = 1 / 2 +export boltHexFlatLength = boltHexDrive / (2 * cos(toRadians(30))) +export boltThreadLength = 1.75 + +export fn bolt() { + // Create the head of the cap screw + boltHead = startSketchOn('XZ') + |> circle(center = [0, 0], radius = boltHeadDiameter / 2, tag = $topEdge) + |> extrude(length = -boltHeadLength) + |> fillet(radius = 0.020, tags = [topEdge, getOppositeEdge(topEdge)]) + + // Define the sketch of the hex pattern on the screw head + hexPatternSketch = startSketchOn(boltHead, 'start') + |> startProfileAt([ + boltHexDrive / 2, + boltHexFlatLength / 2 + ], %) + |> angledLine({ + angle = 270, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 210, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 150, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 90, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 30, + length = boltHexFlatLength + }, %) + |> close() + |> extrude(length = -boltHeadLength * 0.75) + + boltBody = startSketchOn(boltHead, 'end') + |> circle(center = [0, 0], radius = boltDiameter / 2, tag = $filletEdge) + |> extrude(length = boltLength) + |> fillet(radius = .020, tags = [getOppositeEdge(filletEdge)]) + |> appearance(color = "#4dd043", metalness = 90, roughness = 90) + + return boltBody +} + +bolt() + |> scale(scale = [3.14, 3.14, 3.14]) + +// https://www.mcmaster.com/91251a404/ diff --git a/rust/kcl-lib/tests/scale_after_fillet/ops.snap b/rust/kcl-lib/tests/scale_after_fillet/ops.snap new file mode 100644 index 000000000..3dc4c0a51 --- /dev/null +++ b/rust/kcl-lib/tests/scale_after_fillet/ops.snap @@ -0,0 +1,390 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Operations executed scale_after_fillet.kcl +--- +[ + { + "type": "UserDefinedFunctionCall", + "name": "cos", + "functionSourceRange": [ + 0, + 0, + 0 + ], + "unlabeledArg": null, + "labeledArgs": {}, + "sourceRange": [ + 198, + 216, + 0 + ] + }, + { + "type": "UserDefinedFunctionReturn" + }, + { + "type": "UserDefinedFunctionCall", + "name": "bolt", + "functionSourceRange": [ + 264, + 1573, + 0 + ], + "unlabeledArg": null, + "labeledArgs": {}, + "sourceRange": [ + 1575, + 1581, + 0 + ] + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "String", + "value": "XZ" + }, + "sourceRange": [ + 334, + 338, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 320, + 339, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": -0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 442, + 457, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 425, + 458, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 425, + 458, + 0 + ] + } + }, + { + "labeledArgs": { + "radius": { + "value": { + "type": "Number", + "value": 0.02, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 482, + 487, + 0 + ] + }, + "tags": { + "value": { + "type": "Array", + "value": [ + { + "type": "TagIdentifier", + "value": "topEdge", + "artifact_id": "[uuid]" + }, + { + "type": "Uuid", + "value": "[uuid]" + } + ] + }, + "sourceRange": [ + 496, + 531, + 0 + ] + } + }, + "name": "fillet", + "sourceRange": [ + 466, + 532, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 466, + 532, + 0 + ] + } + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 629, + 637, + 0 + ] + }, + "tag": { + "value": { + "type": "String", + "value": "start" + }, + "sourceRange": [ + 639, + 646, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 615, + 647, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": -0.46875, + "ty": { + "type": "Unknown" + } + }, + "sourceRange": [ + 1235, + 1257, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 1218, + 1258, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1218, + 1258, + 0 + ] + } + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1287, + 1295, + 0 + ] + }, + "tag": { + "value": { + "type": "String", + "value": "end" + }, + "sourceRange": [ + 1297, + 1302, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 1273, + 1303, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": 2.5, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 1405, + 1415, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 1388, + 1416, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1388, + 1416, + 0 + ] + } + }, + { + "labeledArgs": { + "radius": { + "value": { + "type": "Number", + "value": 0.02, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 1440, + 1444, + 0 + ] + }, + "tags": { + "value": { + "type": "Array", + "value": [ + { + "type": "Uuid", + "value": "[uuid]" + } + ] + }, + "sourceRange": [ + 1453, + 1482, + 0 + ] + } + }, + "name": "fillet", + "sourceRange": [ + 1424, + 1483, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1424, + 1483, + 0 + ] + } + }, + { + "type": "UserDefinedFunctionReturn" + } +] diff --git a/rust/kcl-lib/tests/scale_after_fillet/program_memory.snap b/rust/kcl-lib/tests/scale_after_fillet/program_memory.snap new file mode 100644 index 000000000..6eb34d222 --- /dev/null +++ b/rust/kcl-lib/tests/scale_after_fillet/program_memory.snap @@ -0,0 +1,93 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Variables in memory after executing scale_after_fillet.kcl +--- +{ + "bolt": { + "type": "Function" + }, + "boltDiameter": { + "type": "Number", + "value": 0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHeadDiameter": { + "type": "Number", + "value": 0.938, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHeadLength": { + "type": "Number", + "value": 0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHexDrive": { + "type": "Number", + "value": 0.5, + "ty": { + "type": "Unknown" + } + }, + "boltHexFlatLength": { + "type": "Number", + "value": 0.2887, + "ty": { + "type": "Unknown" + } + }, + "boltLength": { + "type": "Number", + "value": 2.5, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltThreadLength": { + "type": "Number", + "value": 1.75, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "filletEdge": { + "type": "TagIdentifier", + "type": "TagIdentifier", + "value": "filletEdge" + } +} diff --git a/rust/kcl-lib/tests/scale_after_fillet/rendered_model.png b/rust/kcl-lib/tests/scale_after_fillet/rendered_model.png new file mode 100644 index 000000000..5b1faf3c3 Binary files /dev/null and b/rust/kcl-lib/tests/scale_after_fillet/rendered_model.png differ diff --git a/rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap b/rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap new file mode 100644 index 000000000..4429d8fcb --- /dev/null +++ b/rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap @@ -0,0 +1,1004 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Artifact commands translate_after_fillet.kcl +--- +[ + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "edge_lines_visible", + "hidden": false + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "set_scene_units", + "unit": "mm" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 0, + 0, + 0 + ], + "command": { + "type": "object_visible", + "object_id": "[uuid]", + "hidden": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 320, + 339, + 0 + ], + "command": { + "type": "make_plane", + "origin": { + "x": 0.0, + "y": 0.0, + "z": 0.0 + }, + "x_axis": { + "x": 1.0, + "y": 0.0, + "z": 0.0 + }, + "y_axis": { + "x": 0.0, + "y": 0.0, + "z": 1.0 + }, + "size": 60.0, + "clobber": false, + "hide": true + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.469, + "y": 0.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "arc", + "center": { + "x": 0.0, + "y": 0.0 + }, + "radius": 0.469, + "start": { + "unit": "degrees", + "value": 0.0 + }, + "end": { + "unit": "degrees", + "value": 360.0 + }, + "relative": false + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 347, + 417, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": { + "x": 0.0, + "y": -1.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": -0.625, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 425, + 458, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 506, + 530, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 466, + 532, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 466, + 532, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.25, + "y": 0.14433756729740643, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 655, + 742, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 750, + 833, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.0, + "y": -0.2887, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 841, + 924, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.25, + "y": -0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 932, + 1015, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": -0.25, + "y": 0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1023, + 1105, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.0, + "y": 0.2887, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1113, + 1195, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "line", + "end": { + "x": 0.25, + "y": 0.1443, + "z": 0.0 + }, + "relative": true + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1203, + 1210, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": -0.46875, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1218, + 1258, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "start_path" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "move_path_pen", + "path": "[uuid]", + "to": { + "x": 0.3125, + "y": 0.0, + "z": 0.0 + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "extend_path", + "path": "[uuid]", + "segment": { + "type": "arc", + "center": { + "x": 0.0, + "y": 0.0 + }, + "radius": 0.3125, + "start": { + "unit": "degrees", + "value": 0.0 + }, + "end": { + "unit": "degrees", + "value": 360.0 + }, + "relative": false + } + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1311, + 1380, + 0 + ], + "command": { + "type": "close_path", + "path_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "enable_sketch_mode", + "entity_id": "[uuid]", + "ortho": false, + "animated": false, + "adjust_camera": false, + "planar_normal": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "extrude", + "target": "[uuid]", + "distance": 2.5, + "faces": null + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "sketch_mode_disable" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "object_bring_to_front", + "object_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_extrusion_face_info", + "object_id": "[uuid]", + "edge_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1388, + 1416, + 0 + ], + "command": { + "type": "solid3d_get_next_adjacent_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1454, + 1481, + 0 + ], + "command": { + "type": "solid3d_get_opposite_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "face_id": "[uuid]" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1491, + 1552, + 0 + ], + "command": { + "type": "object_set_material_params_pbr", + "object_id": "[uuid]", + "color": { + "r": 0.3019608, + "g": 0.8156863, + "b": 0.2627451, + "a": 100.0 + }, + "metalness": 0.9, + "roughness": 0.9, + "ambient_occlusion": 0.0 + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1424, + 1483, + 0 + ], + "command": { + "type": "solid3d_fillet_edge", + "object_id": "[uuid]", + "edge_id": "[uuid]", + "radius": 0.02, + "tolerance": 0.0000001, + "cut_type": "fillet" + } + }, + { + "cmdId": "[uuid]", + "range": [ + 1587, + 1620, + 0 + ], + "command": { + "type": "set_object_transform", + "object_id": "[uuid]", + "transforms": [ + { + "translate": { + "property": { + "x": 10.0, + "y": 0.0, + "z": 0.0 + }, + "set": false, + "is_local": true + }, + "rotate_rpy": null, + "rotate_angle_axis": null, + "scale": null + } + ] + } + } +] diff --git a/rust/kcl-lib/tests/translate_after_fillet/artifact_graph_flowchart.snap b/rust/kcl-lib/tests/translate_after_fillet/artifact_graph_flowchart.snap new file mode 100644 index 000000000..7e1f53ca7 --- /dev/null +++ b/rust/kcl-lib/tests/translate_after_fillet/artifact_graph_flowchart.snap @@ -0,0 +1,6 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Artifact graph flowchart translate_after_fillet.kcl +extension: md +snapshot_kind: binary +--- diff --git a/rust/kcl-lib/tests/translate_after_fillet/artifact_graph_flowchart.snap.md b/rust/kcl-lib/tests/translate_after_fillet/artifact_graph_flowchart.snap.md new file mode 100644 index 000000000..264c6b7a7 --- /dev/null +++ b/rust/kcl-lib/tests/translate_after_fillet/artifact_graph_flowchart.snap.md @@ -0,0 +1,134 @@ +```mermaid +flowchart LR + subgraph path2 [Path] + 2["Path
[347, 417, 0]"] + 3["Segment
[347, 417, 0]"] + 4[Solid2d] + end + subgraph path13 [Path] + 13["Path
[655, 742, 0]"] + 14["Segment
[750, 833, 0]"] + 15["Segment
[841, 924, 0]"] + 16["Segment
[932, 1015, 0]"] + 17["Segment
[1023, 1105, 0]"] + 18["Segment
[1113, 1195, 0]"] + 19["Segment
[1203, 1210, 0]"] + 20[Solid2d] + end + subgraph path41 [Path] + 41["Path
[1311, 1380, 0]"] + 42["Segment
[1311, 1380, 0]"] + 43[Solid2d] + end + 1["Plane
[320, 339, 0]"] + 5["Sweep Extrusion
[425, 458, 0]"] + 6[Wall] + 7["Cap Start"] + 8["Cap End"] + 9["SweepEdge Opposite"] + 10["SweepEdge Adjacent"] + 11["EdgeCut Fillet
[466, 532, 0]"] + 12["EdgeCut Fillet
[466, 532, 0]"] + 21["Sweep Extrusion
[1218, 1258, 0]"] + 22[Wall] + 23[Wall] + 24[Wall] + 25[Wall] + 26[Wall] + 27[Wall] + 28["Cap Start"] + 29["SweepEdge Opposite"] + 30["SweepEdge Adjacent"] + 31["SweepEdge Opposite"] + 32["SweepEdge Adjacent"] + 33["SweepEdge Opposite"] + 34["SweepEdge Adjacent"] + 35["SweepEdge Opposite"] + 36["SweepEdge Adjacent"] + 37["SweepEdge Opposite"] + 38["SweepEdge Adjacent"] + 39["SweepEdge Opposite"] + 40["SweepEdge Adjacent"] + 44["Sweep Extrusion
[1388, 1416, 0]"] + 45[Wall] + 46["Cap End"] + 47["SweepEdge Opposite"] + 48["SweepEdge Adjacent"] + 49["EdgeCut Fillet
[1424, 1483, 0]"] + 50["StartSketchOnFace
[615, 647, 0]"] + 51["StartSketchOnFace
[1273, 1303, 0]"] + 1 --- 2 + 2 --- 3 + 2 ---- 5 + 2 --- 4 + 3 --- 6 + 3 --- 9 + 3 --- 10 + 3 --- 11 + 5 --- 6 + 5 --- 7 + 5 --- 8 + 5 --- 9 + 5 --- 10 + 7 --- 13 + 8 --- 41 + 9 <--x 12 + 13 --- 14 + 13 --- 15 + 13 --- 16 + 13 --- 17 + 13 --- 18 + 13 --- 19 + 13 ---- 21 + 13 --- 20 + 14 --- 27 + 14 --- 39 + 14 --- 40 + 15 --- 26 + 15 --- 37 + 15 --- 38 + 16 --- 25 + 16 --- 35 + 16 --- 36 + 17 --- 24 + 17 --- 33 + 17 --- 34 + 18 --- 23 + 18 --- 31 + 18 --- 32 + 19 --- 22 + 19 --- 29 + 19 --- 30 + 21 --- 22 + 21 --- 23 + 21 --- 24 + 21 --- 25 + 21 --- 26 + 21 --- 27 + 21 --- 28 + 21 --- 29 + 21 --- 30 + 21 --- 31 + 21 --- 32 + 21 --- 33 + 21 --- 34 + 21 --- 35 + 21 --- 36 + 21 --- 37 + 21 --- 38 + 21 --- 39 + 21 --- 40 + 41 --- 42 + 41 ---- 44 + 41 --- 43 + 42 --- 45 + 42 --- 47 + 42 --- 48 + 44 --- 45 + 44 --- 46 + 44 --- 47 + 44 --- 48 + 47 <--x 49 + 7 <--x 50 + 8 <--x 51 +``` diff --git a/rust/kcl-lib/tests/translate_after_fillet/ast.snap b/rust/kcl-lib/tests/translate_after_fillet/ast.snap new file mode 100644 index 000000000..ce7864a45 --- /dev/null +++ b/rust/kcl-lib/tests/translate_after_fillet/ast.snap @@ -0,0 +1,1675 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Result of parsing translate_after_fillet.kcl +--- +{ + "Ok": { + "body": [ + { + "declaration": { + "end": 27, + "id": { + "end": 19, + "name": "boltDiameter", + "start": 7, + "type": "Identifier" + }, + "init": { + "end": 27, + "raw": "0.625", + "start": 22, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.625, + "suffix": "None" + } + }, + "start": 7, + "type": "VariableDeclarator" + }, + "end": 27, + "kind": "const", + "start": 0, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 53, + "id": { + "end": 45, + "name": "boltLength", + "start": 35, + "type": "Identifier" + }, + "init": { + "end": 53, + "raw": "2.500", + "start": 48, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.5, + "suffix": "None" + } + }, + "start": 35, + "type": "VariableDeclarator" + }, + "end": 53, + "kind": "const", + "start": 28, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 90, + "id": { + "end": 75, + "name": "boltHeadLength", + "start": 61, + "type": "Identifier" + }, + "init": { + "end": 90, + "name": "boltDiameter", + "start": 78, + "type": "Identifier", + "type": "Identifier" + }, + "start": 61, + "type": "VariableDeclarator" + }, + "end": 90, + "kind": "const", + "start": 54, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 122, + "id": { + "end": 114, + "name": "boltHeadDiameter", + "start": 98, + "type": "Identifier" + }, + "init": { + "end": 122, + "raw": "0.938", + "start": 117, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.938, + "suffix": "None" + } + }, + "start": 98, + "type": "VariableDeclarator" + }, + "end": 122, + "kind": "const", + "start": 91, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 150, + "id": { + "end": 142, + "name": "boltHexDrive", + "start": 130, + "type": "Identifier" + }, + "init": { + "end": 150, + "left": { + "end": 146, + "raw": "1", + "start": 145, + "type": "Literal", + "type": "Literal", + "value": { + "value": 1.0, + "suffix": "None" + } + }, + "operator": "/", + "right": { + "end": 150, + "raw": "2", + "start": 149, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 145, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 130, + "type": "VariableDeclarator" + }, + "end": 150, + "kind": "const", + "start": 123, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 216, + "id": { + "end": 175, + "name": "boltHexFlatLength", + "start": 158, + "type": "Identifier" + }, + "init": { + "end": 216, + "left": { + "end": 190, + "name": "boltHexDrive", + "start": 178, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 216, + "left": { + "end": 195, + "raw": "2", + "start": 194, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "operator": "*", + "right": { + "arguments": [ + { + "arguments": [ + { + "end": 214, + "raw": "30", + "start": 212, + "type": "Literal", + "type": "Literal", + "value": { + "value": 30.0, + "suffix": "None" + } + } + ], + "callee": { + "end": 211, + "name": "toRadians", + "start": 202, + "type": "Identifier" + }, + "end": 215, + "start": 202, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "callee": { + "end": 201, + "name": "cos", + "start": 198, + "type": "Identifier" + }, + "end": 216, + "start": 198, + "type": "CallExpression", + "type": "CallExpression" + }, + "start": 194, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 178, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + "start": 158, + "type": "VariableDeclarator" + }, + "end": 216, + "kind": "const", + "start": 151, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 248, + "id": { + "end": 241, + "name": "boltThreadLength", + "start": 225, + "type": "Identifier" + }, + "init": { + "end": 248, + "raw": "1.75", + "start": 244, + "type": "Literal", + "type": "Literal", + "value": { + "value": 1.75, + "suffix": "None" + } + }, + "start": 225, + "type": "VariableDeclarator" + }, + "end": 248, + "kind": "const", + "start": 218, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "declaration": { + "end": 1573, + "id": { + "end": 264, + "name": "bolt", + "start": 260, + "type": "Identifier" + }, + "init": { + "body": { + "body": [ + { + "declaration": { + "end": 593, + "id": { + "end": 317, + "name": "boltHead", + "start": 309, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 338, + "raw": "'XZ'", + "start": 334, + "type": "Literal", + "type": "Literal", + "value": "XZ" + } + ], + "callee": { + "end": 333, + "name": "startSketchOn", + "start": 320, + "type": "Identifier" + }, + "end": 339, + "start": 320, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 360, + "name": "center", + "start": 354, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 365, + "raw": "0", + "start": 364, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 368, + "raw": "0", + "start": 367, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 369, + "start": 363, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 377, + "name": "radius", + "start": 371, + "type": "Identifier" + }, + "arg": { + "end": 400, + "left": { + "end": 396, + "name": "boltHeadDiameter", + "start": 380, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 400, + "raw": "2", + "start": 399, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 380, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 405, + "name": "tag", + "start": 402, + "type": "Identifier" + }, + "arg": { + "end": 416, + "start": 408, + "type": "TagDeclarator", + "type": "TagDeclarator", + "value": "topEdge" + } + } + ], + "callee": { + "end": 353, + "name": "circle", + "start": 347, + "type": "Identifier" + }, + "end": 417, + "start": 347, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 439, + "name": "length", + "start": 433, + "type": "Identifier" + }, + "arg": { + "argument": { + "end": 457, + "name": "boltHeadLength", + "start": 443, + "type": "Identifier", + "type": "Identifier" + }, + "end": 457, + "operator": "-", + "start": 442, + "type": "UnaryExpression", + "type": "UnaryExpression" + } + } + ], + "callee": { + "end": 432, + "name": "extrude", + "start": 425, + "type": "Identifier" + }, + "end": 458, + "start": 425, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 479, + "name": "radius", + "start": 473, + "type": "Identifier" + }, + "arg": { + "end": 487, + "raw": "0.020", + "start": 482, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.02, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 493, + "name": "tags", + "start": 489, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 504, + "name": "topEdge", + "start": 497, + "type": "Identifier", + "type": "Identifier" + }, + { + "arguments": [ + { + "end": 529, + "name": "topEdge", + "start": 522, + "type": "Identifier", + "type": "Identifier" + } + ], + "callee": { + "end": 521, + "name": "getOppositeEdge", + "start": 506, + "type": "Identifier" + }, + "end": 530, + "start": 506, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 531, + "start": 496, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "end": 472, + "name": "fillet", + "start": 466, + "type": "Identifier" + }, + "end": 532, + "start": 466, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 593, + "nonCodeMeta": { + "nonCodeNodes": { + "3": [ + { + "end": 593, + "start": 534, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "Define the sketch of the hex pattern on the screw head", + "style": "line" + } + } + ] + }, + "startNodes": [] + }, + "start": 320, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 309, + "type": "VariableDeclarator" + }, + "end": 593, + "kind": "const", + "start": 309, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declaration": { + "end": 1258, + "id": { + "end": 612, + "name": "hexPatternSketch", + "start": 596, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 637, + "name": "boltHead", + "start": 629, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 646, + "raw": "'start'", + "start": 639, + "type": "Literal", + "type": "Literal", + "value": "start" + } + ], + "callee": { + "end": 628, + "name": "startSketchOn", + "start": 615, + "type": "Identifier" + }, + "end": 647, + "start": 615, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "elements": [ + { + "end": 697, + "left": { + "end": 693, + "name": "boltHexDrive", + "start": 681, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 697, + "raw": "2", + "start": 696, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 681, + "type": "BinaryExpression", + "type": "BinaryExpression" + }, + { + "end": 729, + "left": { + "end": 725, + "name": "boltHexFlatLength", + "start": 708, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 729, + "raw": "2", + "start": 728, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 708, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + ], + "end": 738, + "start": 670, + "type": "ArrayExpression", + "type": "ArrayExpression" + }, + { + "end": 741, + "start": 740, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 669, + "name": "startProfileAt", + "start": 655, + "type": "Identifier" + }, + "end": 742, + "start": 655, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 829, + "properties": [ + { + "end": 783, + "key": { + "end": 777, + "name": "angle", + "start": 772, + "type": "Identifier" + }, + "start": 772, + "type": "ObjectProperty", + "value": { + "end": 783, + "raw": "270", + "start": 780, + "type": "Literal", + "type": "Literal", + "value": { + "value": 270.0, + "suffix": "None" + } + } + }, + { + "end": 820, + "key": { + "end": 800, + "name": "length", + "start": 794, + "type": "Identifier" + }, + "start": 794, + "type": "ObjectProperty", + "value": { + "end": 820, + "name": "boltHexFlatLength", + "start": 803, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 761, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 832, + "start": 831, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 760, + "name": "angledLine", + "start": 750, + "type": "Identifier" + }, + "end": 833, + "start": 750, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 920, + "properties": [ + { + "end": 874, + "key": { + "end": 868, + "name": "angle", + "start": 863, + "type": "Identifier" + }, + "start": 863, + "type": "ObjectProperty", + "value": { + "end": 874, + "raw": "210", + "start": 871, + "type": "Literal", + "type": "Literal", + "value": { + "value": 210.0, + "suffix": "None" + } + } + }, + { + "end": 911, + "key": { + "end": 891, + "name": "length", + "start": 885, + "type": "Identifier" + }, + "start": 885, + "type": "ObjectProperty", + "value": { + "end": 911, + "name": "boltHexFlatLength", + "start": 894, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 852, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 923, + "start": 922, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 851, + "name": "angledLine", + "start": 841, + "type": "Identifier" + }, + "end": 924, + "start": 841, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1011, + "properties": [ + { + "end": 965, + "key": { + "end": 959, + "name": "angle", + "start": 954, + "type": "Identifier" + }, + "start": 954, + "type": "ObjectProperty", + "value": { + "end": 965, + "raw": "150", + "start": 962, + "type": "Literal", + "type": "Literal", + "value": { + "value": 150.0, + "suffix": "None" + } + } + }, + { + "end": 1002, + "key": { + "end": 982, + "name": "length", + "start": 976, + "type": "Identifier" + }, + "start": 976, + "type": "ObjectProperty", + "value": { + "end": 1002, + "name": "boltHexFlatLength", + "start": 985, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 943, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1014, + "start": 1013, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 942, + "name": "angledLine", + "start": 932, + "type": "Identifier" + }, + "end": 1015, + "start": 932, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1101, + "properties": [ + { + "end": 1055, + "key": { + "end": 1050, + "name": "angle", + "start": 1045, + "type": "Identifier" + }, + "start": 1045, + "type": "ObjectProperty", + "value": { + "end": 1055, + "raw": "90", + "start": 1053, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + }, + { + "end": 1092, + "key": { + "end": 1072, + "name": "length", + "start": 1066, + "type": "Identifier" + }, + "start": 1066, + "type": "ObjectProperty", + "value": { + "end": 1092, + "name": "boltHexFlatLength", + "start": 1075, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 1034, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1104, + "start": 1103, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 1033, + "name": "angledLine", + "start": 1023, + "type": "Identifier" + }, + "end": 1105, + "start": 1023, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "end": 1191, + "properties": [ + { + "end": 1145, + "key": { + "end": 1140, + "name": "angle", + "start": 1135, + "type": "Identifier" + }, + "start": 1135, + "type": "ObjectProperty", + "value": { + "end": 1145, + "raw": "30", + "start": 1143, + "type": "Literal", + "type": "Literal", + "value": { + "value": 30.0, + "suffix": "None" + } + } + }, + { + "end": 1182, + "key": { + "end": 1162, + "name": "length", + "start": 1156, + "type": "Identifier" + }, + "start": 1156, + "type": "ObjectProperty", + "value": { + "end": 1182, + "name": "boltHexFlatLength", + "start": 1165, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "start": 1124, + "type": "ObjectExpression", + "type": "ObjectExpression" + }, + { + "end": 1194, + "start": 1193, + "type": "PipeSubstitution", + "type": "PipeSubstitution" + } + ], + "callee": { + "end": 1123, + "name": "angledLine", + "start": 1113, + "type": "Identifier" + }, + "end": 1195, + "start": 1113, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [], + "callee": { + "end": 1208, + "name": "close", + "start": 1203, + "type": "Identifier" + }, + "end": 1210, + "start": 1203, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1232, + "name": "length", + "start": 1226, + "type": "Identifier" + }, + "arg": { + "end": 1257, + "left": { + "argument": { + "end": 1250, + "name": "boltHeadLength", + "start": 1236, + "type": "Identifier", + "type": "Identifier" + }, + "end": 1250, + "operator": "-", + "start": 1235, + "type": "UnaryExpression", + "type": "UnaryExpression" + }, + "operator": "*", + "right": { + "end": 1257, + "raw": "0.75", + "start": 1253, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.75, + "suffix": "None" + } + }, + "start": 1235, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + } + ], + "callee": { + "end": 1225, + "name": "extrude", + "start": 1218, + "type": "Identifier" + }, + "end": 1258, + "start": 1218, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1258, + "start": 615, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 596, + "type": "VariableDeclarator" + }, + "end": 1258, + "kind": "const", + "start": 596, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "declaration": { + "end": 1552, + "id": { + "end": 1270, + "name": "boltBody", + "start": 1262, + "type": "Identifier" + }, + "init": { + "body": [ + { + "arguments": [ + { + "end": 1295, + "name": "boltHead", + "start": 1287, + "type": "Identifier", + "type": "Identifier" + }, + { + "end": 1302, + "raw": "'end'", + "start": 1297, + "type": "Literal", + "type": "Literal", + "value": "end" + } + ], + "callee": { + "end": 1286, + "name": "startSketchOn", + "start": 1273, + "type": "Identifier" + }, + "end": 1303, + "start": 1273, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1324, + "name": "center", + "start": 1318, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 1329, + "raw": "0", + "start": 1328, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 1332, + "raw": "0", + "start": 1331, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 1333, + "start": 1327, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1341, + "name": "radius", + "start": 1335, + "type": "Identifier" + }, + "arg": { + "end": 1360, + "left": { + "end": 1356, + "name": "boltDiameter", + "start": 1344, + "type": "Identifier", + "type": "Identifier" + }, + "operator": "/", + "right": { + "end": 1360, + "raw": "2", + "start": 1359, + "type": "Literal", + "type": "Literal", + "value": { + "value": 2.0, + "suffix": "None" + } + }, + "start": 1344, + "type": "BinaryExpression", + "type": "BinaryExpression" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1365, + "name": "tag", + "start": 1362, + "type": "Identifier" + }, + "arg": { + "end": 1379, + "start": 1368, + "type": "TagDeclarator", + "type": "TagDeclarator", + "value": "filletEdge" + } + } + ], + "callee": { + "end": 1317, + "name": "circle", + "start": 1311, + "type": "Identifier" + }, + "end": 1380, + "start": 1311, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1402, + "name": "length", + "start": 1396, + "type": "Identifier" + }, + "arg": { + "end": 1415, + "name": "boltLength", + "start": 1405, + "type": "Identifier", + "type": "Identifier" + } + } + ], + "callee": { + "end": 1395, + "name": "extrude", + "start": 1388, + "type": "Identifier" + }, + "end": 1416, + "start": 1388, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1437, + "name": "radius", + "start": 1431, + "type": "Identifier" + }, + "arg": { + "end": 1444, + "raw": ".020", + "start": 1440, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.02, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1450, + "name": "tags", + "start": 1446, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "arguments": [ + { + "end": 1480, + "name": "filletEdge", + "start": 1470, + "type": "Identifier", + "type": "Identifier" + } + ], + "callee": { + "end": 1469, + "name": "getOppositeEdge", + "start": 1454, + "type": "Identifier" + }, + "end": 1481, + "start": 1454, + "type": "CallExpression", + "type": "CallExpression" + } + ], + "end": 1482, + "start": 1453, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "end": 1430, + "name": "fillet", + "start": 1424, + "type": "Identifier" + }, + "end": 1483, + "start": 1424, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1507, + "name": "color", + "start": 1502, + "type": "Identifier" + }, + "arg": { + "end": 1519, + "raw": "\"#4dd043\"", + "start": 1510, + "type": "Literal", + "type": "Literal", + "value": "#4dd043" + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1530, + "name": "metalness", + "start": 1521, + "type": "Identifier" + }, + "arg": { + "end": 1535, + "raw": "90", + "start": 1533, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + }, + { + "type": "LabeledArg", + "label": { + "end": 1546, + "name": "roughness", + "start": 1537, + "type": "Identifier" + }, + "arg": { + "end": 1551, + "raw": "90", + "start": 1549, + "type": "Literal", + "type": "Literal", + "value": { + "value": 90.0, + "suffix": "None" + } + } + } + ], + "callee": { + "end": 1501, + "name": "appearance", + "start": 1491, + "type": "Identifier" + }, + "end": 1552, + "start": 1491, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1552, + "start": 1273, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 1262, + "type": "VariableDeclarator" + }, + "end": 1552, + "kind": "const", + "start": 1262, + "type": "VariableDeclaration", + "type": "VariableDeclaration" + }, + { + "argument": { + "end": 1571, + "name": "boltBody", + "start": 1563, + "type": "Identifier", + "type": "Identifier" + }, + "end": 1571, + "start": 1556, + "type": "ReturnStatement", + "type": "ReturnStatement" + } + ], + "end": 1573, + "nonCodeMeta": { + "nonCodeNodes": { + "1": [ + { + "end": 1262, + "start": 1258, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "2": [ + { + "end": 1556, + "start": 1552, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [ + { + "end": 307, + "start": 268, + "type": "NonCodeNode", + "value": { + "type": "blockComment", + "value": "Create the head of the cap screw", + "style": "line" + } + } + ] + }, + "start": 268 + }, + "end": 1573, + "params": [], + "start": 264, + "type": "FunctionExpression", + "type": "FunctionExpression" + }, + "start": 260, + "type": "VariableDeclarator" + }, + "end": 1573, + "kind": "fn", + "start": 250, + "type": "VariableDeclaration", + "type": "VariableDeclaration", + "visibility": "export" + }, + { + "end": 1660, + "expression": { + "body": [ + { + "arguments": [], + "callee": { + "end": 1579, + "name": "bolt", + "start": 1575, + "type": "Identifier" + }, + "end": 1581, + "start": 1575, + "type": "CallExpression", + "type": "CallExpression" + }, + { + "arguments": [ + { + "type": "LabeledArg", + "label": { + "end": 1606, + "name": "translate", + "start": 1597, + "type": "Identifier" + }, + "arg": { + "elements": [ + { + "end": 1612, + "raw": "10", + "start": 1610, + "type": "Literal", + "type": "Literal", + "value": { + "value": 10.0, + "suffix": "None" + } + }, + { + "end": 1615, + "raw": "0", + "start": 1614, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + }, + { + "end": 1618, + "raw": "0", + "start": 1617, + "type": "Literal", + "type": "Literal", + "value": { + "value": 0.0, + "suffix": "None" + } + } + ], + "end": 1619, + "start": 1609, + "type": "ArrayExpression", + "type": "ArrayExpression" + } + } + ], + "callee": { + "end": 1596, + "name": "translate", + "start": 1587, + "type": "Identifier" + }, + "end": 1620, + "start": 1587, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null + } + ], + "end": 1660, + "nonCodeMeta": { + "nonCodeNodes": { + "1": [ + { + "end": 1660, + "start": 1620, + "type": "NonCodeNode", + "value": { + "type": "newLineBlockComment", + "value": "https://www.mcmaster.com/91251a404/", + "style": "line" + } + } + ] + }, + "startNodes": [] + }, + "start": 1575, + "type": "PipeExpression", + "type": "PipeExpression" + }, + "start": 1575, + "type": "ExpressionStatement", + "type": "ExpressionStatement" + } + ], + "end": 1661, + "nonCodeMeta": { + "nonCodeNodes": { + "6": [ + { + "end": 250, + "start": 248, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ], + "7": [ + { + "end": 1575, + "start": 1573, + "type": "NonCodeNode", + "value": { + "type": "newLine" + } + } + ] + }, + "startNodes": [] + }, + "start": 0 + } +} diff --git a/rust/kcl-lib/tests/translate_after_fillet/input.kcl b/rust/kcl-lib/tests/translate_after_fillet/input.kcl new file mode 100644 index 000000000..99489a82a --- /dev/null +++ b/rust/kcl-lib/tests/translate_after_fillet/input.kcl @@ -0,0 +1,57 @@ +export boltDiameter = 0.625 +export boltLength = 2.500 +export boltHeadLength = boltDiameter +export boltHeadDiameter = 0.938 +export boltHexDrive = 1 / 2 +export boltHexFlatLength = boltHexDrive / (2 * cos(toRadians(30))) +export boltThreadLength = 1.75 + +export fn bolt() { + // Create the head of the cap screw + boltHead = startSketchOn('XZ') + |> circle(center = [0, 0], radius = boltHeadDiameter / 2, tag = $topEdge) + |> extrude(length = -boltHeadLength) + |> fillet(radius = 0.020, tags = [topEdge, getOppositeEdge(topEdge)]) + + // Define the sketch of the hex pattern on the screw head + hexPatternSketch = startSketchOn(boltHead, 'start') + |> startProfileAt([ + boltHexDrive / 2, + boltHexFlatLength / 2 + ], %) + |> angledLine({ + angle = 270, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 210, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 150, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 90, + length = boltHexFlatLength + }, %) + |> angledLine({ + angle = 30, + length = boltHexFlatLength + }, %) + |> close() + |> extrude(length = -boltHeadLength * 0.75) + + boltBody = startSketchOn(boltHead, 'end') + |> circle(center = [0, 0], radius = boltDiameter / 2, tag = $filletEdge) + |> extrude(length = boltLength) + |> fillet(radius = .020, tags = [getOppositeEdge(filletEdge)]) + |> appearance(color = "#4dd043", metalness = 90, roughness = 90) + + return boltBody +} + +bolt() + |> translate(translate = [10, 0, 0]) + +// https://www.mcmaster.com/91251a404/ diff --git a/rust/kcl-lib/tests/translate_after_fillet/ops.snap b/rust/kcl-lib/tests/translate_after_fillet/ops.snap new file mode 100644 index 000000000..e08480352 --- /dev/null +++ b/rust/kcl-lib/tests/translate_after_fillet/ops.snap @@ -0,0 +1,390 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Operations executed translate_after_fillet.kcl +--- +[ + { + "type": "UserDefinedFunctionCall", + "name": "cos", + "functionSourceRange": [ + 0, + 0, + 0 + ], + "unlabeledArg": null, + "labeledArgs": {}, + "sourceRange": [ + 198, + 216, + 0 + ] + }, + { + "type": "UserDefinedFunctionReturn" + }, + { + "type": "UserDefinedFunctionCall", + "name": "bolt", + "functionSourceRange": [ + 264, + 1573, + 0 + ], + "unlabeledArg": null, + "labeledArgs": {}, + "sourceRange": [ + 1575, + 1581, + 0 + ] + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "String", + "value": "XZ" + }, + "sourceRange": [ + 334, + 338, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 320, + 339, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": -0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 442, + 457, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 425, + 458, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 425, + 458, + 0 + ] + } + }, + { + "labeledArgs": { + "radius": { + "value": { + "type": "Number", + "value": 0.02, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 482, + 487, + 0 + ] + }, + "tags": { + "value": { + "type": "Array", + "value": [ + { + "type": "TagIdentifier", + "value": "topEdge", + "artifact_id": "[uuid]" + }, + { + "type": "Uuid", + "value": "[uuid]" + } + ] + }, + "sourceRange": [ + 496, + 531, + 0 + ] + } + }, + "name": "fillet", + "sourceRange": [ + 466, + 532, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 466, + 532, + 0 + ] + } + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 629, + 637, + 0 + ] + }, + "tag": { + "value": { + "type": "String", + "value": "start" + }, + "sourceRange": [ + 639, + 646, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 615, + 647, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": -0.46875, + "ty": { + "type": "Unknown" + } + }, + "sourceRange": [ + 1235, + 1257, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 1218, + 1258, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1218, + 1258, + 0 + ] + } + }, + { + "labeledArgs": { + "data": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1287, + 1295, + 0 + ] + }, + "tag": { + "value": { + "type": "String", + "value": "end" + }, + "sourceRange": [ + 1297, + 1302, + 0 + ] + } + }, + "name": "startSketchOn", + "sourceRange": [ + 1273, + 1303, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": null + }, + { + "labeledArgs": { + "length": { + "value": { + "type": "Number", + "value": 2.5, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 1405, + 1415, + 0 + ] + } + }, + "name": "extrude", + "sourceRange": [ + 1388, + 1416, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Sketch", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1388, + 1416, + 0 + ] + } + }, + { + "labeledArgs": { + "radius": { + "value": { + "type": "Number", + "value": 0.02, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "sourceRange": [ + 1440, + 1444, + 0 + ] + }, + "tags": { + "value": { + "type": "Array", + "value": [ + { + "type": "Uuid", + "value": "[uuid]" + } + ] + }, + "sourceRange": [ + 1453, + 1482, + 0 + ] + } + }, + "name": "fillet", + "sourceRange": [ + 1424, + 1483, + 0 + ], + "type": "StdLibCall", + "unlabeledArg": { + "value": { + "type": "Solid", + "value": { + "artifactId": "[uuid]" + } + }, + "sourceRange": [ + 1424, + 1483, + 0 + ] + } + }, + { + "type": "UserDefinedFunctionReturn" + } +] diff --git a/rust/kcl-lib/tests/translate_after_fillet/program_memory.snap b/rust/kcl-lib/tests/translate_after_fillet/program_memory.snap new file mode 100644 index 000000000..6235f73c5 --- /dev/null +++ b/rust/kcl-lib/tests/translate_after_fillet/program_memory.snap @@ -0,0 +1,93 @@ +--- +source: kcl-lib/src/simulation_tests.rs +description: Variables in memory after executing translate_after_fillet.kcl +--- +{ + "bolt": { + "type": "Function" + }, + "boltDiameter": { + "type": "Number", + "value": 0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHeadDiameter": { + "type": "Number", + "value": 0.938, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHeadLength": { + "type": "Number", + "value": 0.625, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltHexDrive": { + "type": "Number", + "value": 0.5, + "ty": { + "type": "Unknown" + } + }, + "boltHexFlatLength": { + "type": "Number", + "value": 0.2887, + "ty": { + "type": "Unknown" + } + }, + "boltLength": { + "type": "Number", + "value": 2.5, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "boltThreadLength": { + "type": "Number", + "value": 1.75, + "ty": { + "type": "Default", + "len": { + "type": "Mm" + }, + "angle": { + "type": "Degrees" + } + } + }, + "filletEdge": { + "type": "TagIdentifier", + "type": "TagIdentifier", + "value": "filletEdge" + } +} diff --git a/rust/kcl-lib/tests/translate_after_fillet/rendered_model.png b/rust/kcl-lib/tests/translate_after_fillet/rendered_model.png new file mode 100644 index 000000000..e3413b791 Binary files /dev/null and b/rust/kcl-lib/tests/translate_after_fillet/rendered_model.png differ