transform after fillet bug fix (#5882)
* fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * rotate Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * its not jsut translate Signed-off-by: Jess Frazelle <github@jessfraz.com> * its not jsut translate Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -2289,3 +2289,66 @@ mod bad_units_in_annotation {
|
|||||||
super::execute(TEST_NAME, true).await
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -376,7 +376,7 @@ impl Args {
|
|||||||
pub(crate) async fn flush_batch_for_solids(
|
pub(crate) async fn flush_batch_for_solids(
|
||||||
&self,
|
&self,
|
||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
solids: Vec<Solid>,
|
solids: &[Solid],
|
||||||
) -> Result<(), KclError> {
|
) -> Result<(), KclError> {
|
||||||
// Make sure we don't traverse sketches more than once.
|
// Make sure we don't traverse sketches more than once.
|
||||||
let mut traversed_sketches = Vec::new();
|
let mut traversed_sketches = Vec::new();
|
||||||
|
@ -363,7 +363,7 @@ async fn execute_pattern_transform<T: GeometryTrait>(
|
|||||||
// Flush the batch for our fillets/chamfers if there are any.
|
// 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.
|
// 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.
|
// 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<T> = geo_set.into();
|
let starting: Vec<T> = geo_set.into();
|
||||||
|
|
||||||
if args.ctx.context_type == crate::execution::ContextType::Mock {
|
if args.ctx.context_type == crate::execution::ContextType::Mock {
|
||||||
@ -614,7 +614,7 @@ trait GeometryTrait: Clone {
|
|||||||
fn original_id(&self) -> Uuid;
|
fn original_id(&self) -> Uuid;
|
||||||
fn set_id(&mut self, id: Uuid);
|
fn set_id(&mut self, id: Uuid);
|
||||||
fn array_to_point3d(val: &KclValue, source_ranges: Vec<SourceRange>) -> Result<Point3d, KclError>;
|
fn array_to_point3d(val: &KclValue, source_ranges: Vec<SourceRange>) -> Result<Point3d, KclError>;
|
||||||
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 {
|
impl GeometryTrait for Sketch {
|
||||||
@ -633,7 +633,7 @@ impl GeometryTrait for Sketch {
|
|||||||
Ok(Point3d { x, y, z: 0.0 })
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -656,7 +656,7 @@ impl GeometryTrait for Solid {
|
|||||||
array_to_point3d(val, source_ranges)
|
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
|
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.
|
// 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.
|
// 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.
|
// 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;
|
let starting_solids = solids;
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ async fn inner_shell(
|
|||||||
for solid in &solids {
|
for solid in &solids {
|
||||||
// Flush the batch for our fillets/chamfers if there are any.
|
// 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.
|
// 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 {
|
for tag in &faces {
|
||||||
let extrude_plane_id = tag.get_face_id(solid, exec_state, &args, false).await?;
|
let extrude_plane_id = tag.get_face_id(solid, exec_state, &args, false).await?;
|
||||||
@ -320,7 +320,7 @@ async fn inner_hollow(
|
|||||||
) -> Result<Box<Solid>, KclError> {
|
) -> Result<Box<Solid>, KclError> {
|
||||||
// Flush the batch for our fillets/chamfers if there are any.
|
// 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.
|
// 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(
|
args.batch_modeling_cmd(
|
||||||
exec_state.next_uuid(),
|
exec_state.next_uuid(),
|
||||||
|
@ -1269,7 +1269,7 @@ pub(crate) async fn inner_start_profile_at(
|
|||||||
SketchSurface::Face(face) => {
|
SketchSurface::Face(face) => {
|
||||||
// Flush the batch for our fillets/chamfers if there are any.
|
// 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.
|
// 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?;
|
.await?;
|
||||||
}
|
}
|
||||||
SketchSurface::Plane(plane) if !plane.is_standard() => {
|
SketchSurface::Plane(plane) if !plane.is_standard() => {
|
||||||
|
@ -147,6 +147,12 @@ async fn inner_scale(
|
|||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
args: Args,
|
args: Args,
|
||||||
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
|
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
|
||||||
|
// 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() {
|
for object_id in objects.ids() {
|
||||||
let id = exec_state.next_uuid();
|
let id = exec_state.next_uuid();
|
||||||
|
|
||||||
@ -344,6 +350,12 @@ async fn inner_translate(
|
|||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
args: Args,
|
args: Args,
|
||||||
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
|
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
|
||||||
|
// 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() {
|
for object_id in objects.ids() {
|
||||||
let id = exec_state.next_uuid();
|
let id = exec_state.next_uuid();
|
||||||
|
|
||||||
@ -690,6 +702,12 @@ async fn inner_rotate(
|
|||||||
exec_state: &mut ExecState,
|
exec_state: &mut ExecState,
|
||||||
args: Args,
|
args: Args,
|
||||||
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
|
) -> Result<SolidOrSketchOrImportedGeometry, KclError> {
|
||||||
|
// 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() {
|
for object_id in objects.ids() {
|
||||||
let id = exec_state.next_uuid();
|
let id = exec_state.next_uuid();
|
||||||
|
|
||||||
|
1004
rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap
Normal file
1004
rust/kcl-lib/tests/rotate_after_fillet/artifact_commands.snap
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
source: kcl-lib/src/simulation_tests.rs
|
||||||
|
description: Artifact graph flowchart rotate_after_fillet.kcl
|
||||||
|
extension: md
|
||||||
|
snapshot_kind: binary
|
||||||
|
---
|
@ -0,0 +1,134 @@
|
|||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
subgraph path2 [Path]
|
||||||
|
2["Path<br>[347, 417, 0]"]
|
||||||
|
3["Segment<br>[347, 417, 0]"]
|
||||||
|
4[Solid2d]
|
||||||
|
end
|
||||||
|
subgraph path13 [Path]
|
||||||
|
13["Path<br>[655, 742, 0]"]
|
||||||
|
14["Segment<br>[750, 833, 0]"]
|
||||||
|
15["Segment<br>[841, 924, 0]"]
|
||||||
|
16["Segment<br>[932, 1015, 0]"]
|
||||||
|
17["Segment<br>[1023, 1105, 0]"]
|
||||||
|
18["Segment<br>[1113, 1195, 0]"]
|
||||||
|
19["Segment<br>[1203, 1210, 0]"]
|
||||||
|
20[Solid2d]
|
||||||
|
end
|
||||||
|
subgraph path41 [Path]
|
||||||
|
41["Path<br>[1311, 1380, 0]"]
|
||||||
|
42["Segment<br>[1311, 1380, 0]"]
|
||||||
|
43[Solid2d]
|
||||||
|
end
|
||||||
|
1["Plane<br>[320, 339, 0]"]
|
||||||
|
5["Sweep Extrusion<br>[425, 458, 0]"]
|
||||||
|
6[Wall]
|
||||||
|
7["Cap Start"]
|
||||||
|
8["Cap End"]
|
||||||
|
9["SweepEdge Opposite"]
|
||||||
|
10["SweepEdge Adjacent"]
|
||||||
|
11["EdgeCut Fillet<br>[466, 532, 0]"]
|
||||||
|
12["EdgeCut Fillet<br>[466, 532, 0]"]
|
||||||
|
21["Sweep Extrusion<br>[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<br>[1388, 1416, 0]"]
|
||||||
|
45[Wall]
|
||||||
|
46["Cap End"]
|
||||||
|
47["SweepEdge Opposite"]
|
||||||
|
48["SweepEdge Adjacent"]
|
||||||
|
49["EdgeCut Fillet<br>[1424, 1483, 0]"]
|
||||||
|
50["StartSketchOnFace<br>[615, 647, 0]"]
|
||||||
|
51["StartSketchOnFace<br>[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
|
||||||
|
```
|
1685
rust/kcl-lib/tests/rotate_after_fillet/ast.snap
Normal file
1685
rust/kcl-lib/tests/rotate_after_fillet/ast.snap
Normal file
File diff suppressed because it is too large
Load Diff
57
rust/kcl-lib/tests/rotate_after_fillet/input.kcl
Normal file
57
rust/kcl-lib/tests/rotate_after_fillet/input.kcl
Normal file
@ -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/
|
390
rust/kcl-lib/tests/rotate_after_fillet/ops.snap
Normal file
390
rust/kcl-lib/tests/rotate_after_fillet/ops.snap
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
93
rust/kcl-lib/tests/rotate_after_fillet/program_memory.snap
Normal file
93
rust/kcl-lib/tests/rotate_after_fillet/program_memory.snap
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
BIN
rust/kcl-lib/tests/rotate_after_fillet/rendered_model.png
Normal file
BIN
rust/kcl-lib/tests/rotate_after_fillet/rendered_model.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
1004
rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap
Normal file
1004
rust/kcl-lib/tests/scale_after_fillet/artifact_commands.snap
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
source: kcl-lib/src/simulation_tests.rs
|
||||||
|
description: Artifact graph flowchart scale_after_fillet.kcl
|
||||||
|
extension: md
|
||||||
|
snapshot_kind: binary
|
||||||
|
---
|
@ -0,0 +1,134 @@
|
|||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
subgraph path2 [Path]
|
||||||
|
2["Path<br>[347, 417, 0]"]
|
||||||
|
3["Segment<br>[347, 417, 0]"]
|
||||||
|
4[Solid2d]
|
||||||
|
end
|
||||||
|
subgraph path13 [Path]
|
||||||
|
13["Path<br>[655, 742, 0]"]
|
||||||
|
14["Segment<br>[750, 833, 0]"]
|
||||||
|
15["Segment<br>[841, 924, 0]"]
|
||||||
|
16["Segment<br>[932, 1015, 0]"]
|
||||||
|
17["Segment<br>[1023, 1105, 0]"]
|
||||||
|
18["Segment<br>[1113, 1195, 0]"]
|
||||||
|
19["Segment<br>[1203, 1210, 0]"]
|
||||||
|
20[Solid2d]
|
||||||
|
end
|
||||||
|
subgraph path41 [Path]
|
||||||
|
41["Path<br>[1311, 1380, 0]"]
|
||||||
|
42["Segment<br>[1311, 1380, 0]"]
|
||||||
|
43[Solid2d]
|
||||||
|
end
|
||||||
|
1["Plane<br>[320, 339, 0]"]
|
||||||
|
5["Sweep Extrusion<br>[425, 458, 0]"]
|
||||||
|
6[Wall]
|
||||||
|
7["Cap Start"]
|
||||||
|
8["Cap End"]
|
||||||
|
9["SweepEdge Opposite"]
|
||||||
|
10["SweepEdge Adjacent"]
|
||||||
|
11["EdgeCut Fillet<br>[466, 532, 0]"]
|
||||||
|
12["EdgeCut Fillet<br>[466, 532, 0]"]
|
||||||
|
21["Sweep Extrusion<br>[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<br>[1388, 1416, 0]"]
|
||||||
|
45[Wall]
|
||||||
|
46["Cap End"]
|
||||||
|
47["SweepEdge Opposite"]
|
||||||
|
48["SweepEdge Adjacent"]
|
||||||
|
49["EdgeCut Fillet<br>[1424, 1483, 0]"]
|
||||||
|
50["StartSketchOnFace<br>[615, 647, 0]"]
|
||||||
|
51["StartSketchOnFace<br>[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
|
||||||
|
```
|
1675
rust/kcl-lib/tests/scale_after_fillet/ast.snap
Normal file
1675
rust/kcl-lib/tests/scale_after_fillet/ast.snap
Normal file
File diff suppressed because it is too large
Load Diff
57
rust/kcl-lib/tests/scale_after_fillet/input.kcl
Normal file
57
rust/kcl-lib/tests/scale_after_fillet/input.kcl
Normal file
@ -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/
|
390
rust/kcl-lib/tests/scale_after_fillet/ops.snap
Normal file
390
rust/kcl-lib/tests/scale_after_fillet/ops.snap
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
93
rust/kcl-lib/tests/scale_after_fillet/program_memory.snap
Normal file
93
rust/kcl-lib/tests/scale_after_fillet/program_memory.snap
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
}
|
BIN
rust/kcl-lib/tests/scale_after_fillet/rendered_model.png
Normal file
BIN
rust/kcl-lib/tests/scale_after_fillet/rendered_model.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 66 KiB |
1004
rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap
Normal file
1004
rust/kcl-lib/tests/translate_after_fillet/artifact_commands.snap
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,6 @@
|
|||||||
|
---
|
||||||
|
source: kcl-lib/src/simulation_tests.rs
|
||||||
|
description: Artifact graph flowchart translate_after_fillet.kcl
|
||||||
|
extension: md
|
||||||
|
snapshot_kind: binary
|
||||||
|
---
|
@ -0,0 +1,134 @@
|
|||||||
|
```mermaid
|
||||||
|
flowchart LR
|
||||||
|
subgraph path2 [Path]
|
||||||
|
2["Path<br>[347, 417, 0]"]
|
||||||
|
3["Segment<br>[347, 417, 0]"]
|
||||||
|
4[Solid2d]
|
||||||
|
end
|
||||||
|
subgraph path13 [Path]
|
||||||
|
13["Path<br>[655, 742, 0]"]
|
||||||
|
14["Segment<br>[750, 833, 0]"]
|
||||||
|
15["Segment<br>[841, 924, 0]"]
|
||||||
|
16["Segment<br>[932, 1015, 0]"]
|
||||||
|
17["Segment<br>[1023, 1105, 0]"]
|
||||||
|
18["Segment<br>[1113, 1195, 0]"]
|
||||||
|
19["Segment<br>[1203, 1210, 0]"]
|
||||||
|
20[Solid2d]
|
||||||
|
end
|
||||||
|
subgraph path41 [Path]
|
||||||
|
41["Path<br>[1311, 1380, 0]"]
|
||||||
|
42["Segment<br>[1311, 1380, 0]"]
|
||||||
|
43[Solid2d]
|
||||||
|
end
|
||||||
|
1["Plane<br>[320, 339, 0]"]
|
||||||
|
5["Sweep Extrusion<br>[425, 458, 0]"]
|
||||||
|
6[Wall]
|
||||||
|
7["Cap Start"]
|
||||||
|
8["Cap End"]
|
||||||
|
9["SweepEdge Opposite"]
|
||||||
|
10["SweepEdge Adjacent"]
|
||||||
|
11["EdgeCut Fillet<br>[466, 532, 0]"]
|
||||||
|
12["EdgeCut Fillet<br>[466, 532, 0]"]
|
||||||
|
21["Sweep Extrusion<br>[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<br>[1388, 1416, 0]"]
|
||||||
|
45[Wall]
|
||||||
|
46["Cap End"]
|
||||||
|
47["SweepEdge Opposite"]
|
||||||
|
48["SweepEdge Adjacent"]
|
||||||
|
49["EdgeCut Fillet<br>[1424, 1483, 0]"]
|
||||||
|
50["StartSketchOnFace<br>[615, 647, 0]"]
|
||||||
|
51["StartSketchOnFace<br>[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
|
||||||
|
```
|
1675
rust/kcl-lib/tests/translate_after_fillet/ast.snap
Normal file
1675
rust/kcl-lib/tests/translate_after_fillet/ast.snap
Normal file
File diff suppressed because it is too large
Load Diff
57
rust/kcl-lib/tests/translate_after_fillet/input.kcl
Normal file
57
rust/kcl-lib/tests/translate_after_fillet/input.kcl
Normal file
@ -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/
|
390
rust/kcl-lib/tests/translate_after_fillet/ops.snap
Normal file
390
rust/kcl-lib/tests/translate_after_fillet/ops.snap
Normal file
@ -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"
|
||||||
|
}
|
||||||
|
]
|
@ -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"
|
||||||
|
}
|
||||||
|
}
|
BIN
rust/kcl-lib/tests/translate_after_fillet/rendered_model.png
Normal file
BIN
rust/kcl-lib/tests/translate_after_fillet/rendered_model.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 67 KiB |
Reference in New Issue
Block a user