Replace plane strings with literals (#6592)
Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
@ -736,7 +736,7 @@ fn get_autocomplete_string_from_schema(schema: &schemars::schema::Schema) -> Res
|
||||
for enum_value in enum_values {
|
||||
if let serde_json::value::Value::String(enum_value) = enum_value {
|
||||
had_enum_string = true;
|
||||
parsed_enum_values.push(format!("\"{}\"", enum_value));
|
||||
parsed_enum_values.push(enum_value.to_owned());
|
||||
} else {
|
||||
had_enum_string = false;
|
||||
break;
|
||||
@ -925,7 +925,7 @@ mod tests {
|
||||
fn get_autocomplete_snippet_start_sketch_on() {
|
||||
let start_sketch_on_fn: Box<dyn StdLibFn> = Box::new(crate::std::sketch::StartSketchOn);
|
||||
let snippet = start_sketch_on_fn.to_autocomplete_snippet().unwrap();
|
||||
assert_eq!(snippet, r#"startSketchOn(${0:"XY"})"#);
|
||||
assert_eq!(snippet, r#"startSketchOn(${0:XY})"#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
@ -248,7 +248,7 @@ mod tests {
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_changed_program_same_code() {
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -279,7 +279,7 @@ shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_changed_program_same_code_changed_whitespace() {
|
||||
let old = r#" // Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -291,7 +291,7 @@ firstSketch = startSketchOn('XY')
|
||||
shell(firstSketch, faces = [END], thickness = 0.25) "#;
|
||||
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -324,7 +324,7 @@ shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_changed_program_same_code_changed_code_comment_start_of_program() {
|
||||
let old = r#" // Removed the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -336,7 +336,7 @@ firstSketch = startSketchOn('XY')
|
||||
shell(firstSketch, faces = [END], thickness = 0.25) "#;
|
||||
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -371,7 +371,7 @@ shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
let old = r#"@foo(whatever = whatever)
|
||||
@bar
|
||||
// Removed the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -385,7 +385,7 @@ shell(firstSketch, faces = [END], thickness = 0.25) "#;
|
||||
let new = r#"@foo(whatever = 42)
|
||||
@baz
|
||||
// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -419,7 +419,7 @@ shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_changed_program_same_code_but_different_grid_setting() {
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -456,7 +456,7 @@ shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_changed_program_same_code_but_different_edge_visiblity_setting() {
|
||||
let new = r#"// Remove the end face for the extrusion.
|
||||
firstSketch = startSketchOn('XY')
|
||||
firstSketch = startSketchOn(XY)
|
||||
|> startProfile(at = [-12, 12])
|
||||
|> line(end = [24, 0])
|
||||
|> line(end = [0, -24])
|
||||
@ -530,10 +530,10 @@ shell(firstSketch, faces = [END], thickness = 0.25)"#;
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_changed_program_same_code_but_different_unit_setting_using_annotation() {
|
||||
let old_code = r#"@settings(defaultLengthUnit = in)
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
"#;
|
||||
let new_code = r#"@settings(defaultLengthUnit = mm)
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
"#;
|
||||
|
||||
let ExecTestResults { program, exec_ctxt, .. } = parse_execute(old_code).await.unwrap();
|
||||
@ -568,10 +568,10 @@ startSketchOn('XY')
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_get_changed_program_same_code_but_removed_unit_setting_using_annotation() {
|
||||
let old_code = r#"@settings(defaultLengthUnit = in)
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
"#;
|
||||
let new_code = r#"
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
"#;
|
||||
|
||||
let ExecTestResults { program, exec_ctxt, .. } = parse_execute(old_code).await.unwrap();
|
||||
|
@ -2057,7 +2057,7 @@ w = f() + f()
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_changing_a_setting_updates_the_cached_state() {
|
||||
let code = r#"sketch001 = startSketchOn('XZ')
|
||||
let code = r#"sketch001 = startSketchOn(XZ)
|
||||
|> startProfile(at = [61.74, 206.13])
|
||||
|> xLine(length = 305.11, tag = $seg01)
|
||||
|> yLine(length = -291.85)
|
||||
|
@ -527,13 +527,13 @@ impl ElseIf {
|
||||
mod test {
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn test_parse_digest() {
|
||||
let prog1_string = r#"startSketchOn('XY')
|
||||
let prog1_string = r#"startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line([5, 5], %)
|
||||
"#;
|
||||
let prog1_digest = crate::parsing::top_level_parse(prog1_string).unwrap().compute_digest();
|
||||
|
||||
let prog2_string = r#"startSketchOn('XY')
|
||||
let prog2_string = r#"startSketchOn(XY)
|
||||
|> startProfile(at = [0, 2])
|
||||
|> line([5, 5], %)
|
||||
"#;
|
||||
@ -541,7 +541,7 @@ mod test {
|
||||
|
||||
assert!(prog1_digest != prog2_digest);
|
||||
|
||||
let prog3_string = r#"startSketchOn('XY')
|
||||
let prog3_string = r#"startSketchOn(XY)
|
||||
|> startProfile(at = [0, 0])
|
||||
|> line([5, 5], %)
|
||||
"#;
|
||||
@ -554,12 +554,12 @@ mod test {
|
||||
async fn test_annotations_digest() {
|
||||
// Settings annotations should be included in the digest.
|
||||
let prog1_string = r#"@settings(defaultLengthUnit = in)
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
"#;
|
||||
let prog1_digest = crate::parsing::top_level_parse(prog1_string).unwrap().compute_digest();
|
||||
|
||||
let prog2_string = r#"@settings(defaultLengthUnit = mm)
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
"#;
|
||||
let prog2_digest = crate::parsing::top_level_parse(prog2_string).unwrap().compute_digest();
|
||||
|
||||
|
@ -4104,7 +4104,7 @@ mySk1 = startSketchOn(XY)
|
||||
#[test]
|
||||
fn test_parse_half_pipe_small() {
|
||||
assert_err_contains(
|
||||
"secondExtrude = startSketchOn('XY')
|
||||
"secondExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|",
|
||||
"Unexpected token: |",
|
||||
@ -4197,7 +4197,7 @@ height = [obj["a"] -1, 0]"#;
|
||||
fn test_parse_half_pipe() {
|
||||
let code = "height = 10
|
||||
|
||||
firstExtrude = startSketchOn('XY')
|
||||
firstExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|> line([0, 8], %)
|
||||
|> line([20, 0], %)
|
||||
@ -4205,7 +4205,7 @@ firstExtrude = startSketchOn('XY')
|
||||
|> close()
|
||||
|> extrude(length=2)
|
||||
|
||||
secondExtrude = startSketchOn('XY')
|
||||
secondExtrude = startSketchOn(XY)
|
||||
|> startProfileAt([0,0], %)
|
||||
|";
|
||||
assert_err_contains(code, "Unexpected token: |");
|
||||
@ -4476,7 +4476,7 @@ e
|
||||
let code = r#"/// Compute the cosine of a number (in radians).
|
||||
///
|
||||
/// ```
|
||||
/// exampleSketch = startSketchOn("XZ")
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfileAt([0, 0], %)
|
||||
/// |> angledLine(
|
||||
/// angle = 30,
|
||||
@ -4628,7 +4628,7 @@ thing(false)
|
||||
|
||||
#[test]
|
||||
fn random_words_fail() {
|
||||
let test_program = r#"part001 = startSketchOn('-XZ')
|
||||
let test_program = r#"part001 = startSketchOn(-XZ)
|
||||
|> startProfileAt([8.53, 11.8], %)
|
||||
asdasd asdasd
|
||||
|> line([11.12, -14.82], %)
|
||||
@ -4642,7 +4642,7 @@ thing(false)
|
||||
#[test]
|
||||
fn test_member_expression_sketch() {
|
||||
let some_program_string = r#"fn cube(pos, scale) {
|
||||
sg = startSketchOn('XY')
|
||||
sg = startSketchOn(XY)
|
||||
|> startProfileAt(pos, %)
|
||||
|> line([0, scale], %)
|
||||
|> line([scale, 0], %)
|
||||
@ -4670,7 +4670,7 @@ let other_thing = 2 * cos(3)"#;
|
||||
#[test]
|
||||
fn test_negative_arguments() {
|
||||
let some_program_string = r#"fn box(p, h, l, w) {
|
||||
myBox = startSketchOn('XY')
|
||||
myBox = startSketchOn(XY)
|
||||
|> startProfileAt(p, %)
|
||||
|> line([0, l], %)
|
||||
|> line([w, 0], %)
|
||||
@ -4696,89 +4696,89 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
|
||||
#[test]
|
||||
fn test_parse_tag_named_std_lib() {
|
||||
let some_program_string = r#"startSketchOn('XY')
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([5, 5], %, $xLine)
|
||||
"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Cannot assign a tag to a reserved keyword: xLine",
|
||||
[76, 82],
|
||||
[74, 80],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_empty_tag_brace() {
|
||||
let some_program_string = r#"startSketchOn('XY')
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not be empty", [69, 70]);
|
||||
assert_err(some_program_string, "Tag names must not be empty", [67, 68]);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_empty_tag_whitespace() {
|
||||
let some_program_string = r#"startSketchOn('XY')
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $ ,01)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not be empty", [69, 70]);
|
||||
assert_err(some_program_string, "Tag names must not be empty", [67, 68]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_empty_tag_comma() {
|
||||
let some_program_string = r#"startSketchOn('XY')
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $,)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not be empty", [69, 70]);
|
||||
assert_err(some_program_string, "Tag names must not be empty", [67, 68]);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_digit() {
|
||||
let some_program_string = r#"
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $01)"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Tag names must not start with a number. Tag starts with `01`",
|
||||
[74, 76],
|
||||
[72, 74],
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_tag_including_digit() {
|
||||
let some_program_string = r#"
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $var01)"#;
|
||||
assert_no_err(some_program_string);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_bang() {
|
||||
let some_program_string = r#"startSketchOn('XY')
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $!var,01)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not start with a bang", [69, 70]);
|
||||
assert_err(some_program_string, "Tag names must not start with a bang", [67, 68]);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_dollar() {
|
||||
let some_program_string = r#"startSketchOn('XY')
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $$,01)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not start with a dollar", [69, 70]);
|
||||
assert_err(some_program_string, "Tag names must not start with a dollar", [67, 68]);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_fn() {
|
||||
let some_program_string = r#"startSketchOn('XY')
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $fn,01)
|
||||
"#;
|
||||
assert_err(some_program_string, "Tag names must not start with a keyword", [69, 71]);
|
||||
assert_err(some_program_string, "Tag names must not start with a keyword", [67, 69]);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_tag_starting_with_a_comment() {
|
||||
let some_program_string = r#"startSketchOn('XY')
|
||||
let some_program_string = r#"startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line(%, $//
|
||||
,01)
|
||||
@ -4786,14 +4786,14 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Tag names must not start with a lineComment",
|
||||
[69, 71],
|
||||
[67, 69],
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_tag_with_reserved_in_middle_works() {
|
||||
let some_program_string = r#"
|
||||
startSketchOn('XY')
|
||||
startSketchOn(XY)
|
||||
|> startProfileAt([0, 0], %)
|
||||
|> line([5, 5], %, $sketching)
|
||||
"#;
|
||||
@ -4803,21 +4803,21 @@ let myBox = box([0,0], -3, -16, -10)
|
||||
#[test]
|
||||
fn test_parse_array_missing_closing_bracket() {
|
||||
let some_program_string = r#"
|
||||
sketch001 = startSketchOn('XZ') |> startProfileAt([90.45, 119.09, %)"#;
|
||||
sketch001 = startSketchOn(XZ) |> startProfileAt([90.45, 119.09, %)"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Encountered an unexpected character(s) before finding a closing bracket(`]`) for the array",
|
||||
[51, 67],
|
||||
[49, 65],
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_array_missing_comma() {
|
||||
let some_program_string = r#"
|
||||
sketch001 = startSketchOn('XZ') |> startProfileAt([90.45 119.09], %)"#;
|
||||
sketch001 = startSketchOn(XZ) |> startProfileAt([90.45 119.09], %)"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Unexpected character encountered. You might be missing a comma in between elements.",
|
||||
[52, 65],
|
||||
[50, 63],
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
@ -4825,21 +4825,21 @@ sketch001 = startSketchOn('XZ') |> startProfileAt([90.45 119.09], %)"#;
|
||||
// since there is an early exit if encountering a reserved word, the error should be about
|
||||
// that and not the missing comma
|
||||
let some_program_string = r#"
|
||||
sketch001 = startSketchOn('XZ') |> startProfileAt([90.45 $struct], %)"#;
|
||||
sketch001 = startSketchOn(XZ) |> startProfileAt([90.45 $struct], %)"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Encountered an unexpected character(s) before finding a closing bracket(`]`) for the array",
|
||||
[51, 52],
|
||||
[49, 50],
|
||||
);
|
||||
}
|
||||
#[test]
|
||||
fn test_parse_array_random_brace() {
|
||||
let some_program_string = r#"
|
||||
sketch001 = startSketchOn('XZ') |> startProfileAt([}], %)"#;
|
||||
sketch001 = startSketchOn(XZ) |> startProfileAt([}], %)"#;
|
||||
assert_err(
|
||||
some_program_string,
|
||||
"Encountered an unexpected character(s) before finding a closing bracket(`]`) for the array",
|
||||
[51, 52],
|
||||
[49, 50],
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
|
||||
/// ```no_run
|
||||
/// r = 10 // radius
|
||||
/// fn drawCircle(id) {
|
||||
/// return startSketchOn("XY")
|
||||
/// return startSketchOn(XY)
|
||||
/// |> circle( center= [id * 2 * r, 0], radius= r)
|
||||
/// }
|
||||
///
|
||||
@ -45,7 +45,7 @@ pub async fn map(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kcl
|
||||
/// circles = map(
|
||||
/// [1..3],
|
||||
/// f = fn(id) {
|
||||
/// return startSketchOn("XY")
|
||||
/// return startSketchOn(XY)
|
||||
/// |> circle( center= [id * 2 * r, 0], radius= r)
|
||||
/// }
|
||||
/// )
|
||||
|
@ -40,7 +40,7 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// // Union two cubes using the stdlib functions.
|
||||
///
|
||||
/// fn cube(center, size) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [center[0] - size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] + size])
|
||||
@ -62,7 +62,7 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// // Codemods will generate the stdlib function call instead.
|
||||
///
|
||||
/// fn cube(center, size) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [center[0] - size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] + size])
|
||||
@ -85,7 +85,7 @@ pub async fn union(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// // Codemods will generate the stdlib function call instead.
|
||||
///
|
||||
/// fn cube(center, size) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [center[0] - size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] + size])
|
||||
@ -190,7 +190,7 @@ pub async fn intersect(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// // Intersect two cubes using the stdlib functions.
|
||||
///
|
||||
/// fn cube(center, size) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [center[0] - size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] + size])
|
||||
@ -212,7 +212,7 @@ pub async fn intersect(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// // Codemods will generate the stdlib function call instead.
|
||||
///
|
||||
/// fn cube(center, size) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [center[0] - size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] + size])
|
||||
@ -323,7 +323,7 @@ pub async fn subtract(exec_state: &mut ExecState, args: Args) -> Result<KclValue
|
||||
/// // Subtract a cylinder from a cube using the stdlib functions.
|
||||
///
|
||||
/// fn cube(center, size) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [center[0] - size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] + size])
|
||||
@ -345,7 +345,7 @@ pub async fn subtract(exec_state: &mut ExecState, args: Args) -> Result<KclValue
|
||||
/// // Codemods will generate the stdlib function call instead.
|
||||
///
|
||||
/// fn cube(center, size) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [center[0] - size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] - size])
|
||||
/// |> line(endAbsolute = [center[0] + size, center[1] + size])
|
||||
|
@ -26,7 +26,7 @@ pub async fn get_opposite_edge(exec_state: &mut ExecState, args: Args) -> Result
|
||||
/// Get the opposite edge to the edge given.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [10, 0])
|
||||
/// |> angledLine(
|
||||
@ -109,7 +109,7 @@ pub async fn get_next_adjacent_edge(exec_state: &mut ExecState, args: Args) -> R
|
||||
/// Get the next adjacent edge to the edge given.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [10, 0])
|
||||
/// |> angledLine(
|
||||
@ -201,7 +201,7 @@ pub async fn get_previous_adjacent_edge(exec_state: &mut ExecState, args: Args)
|
||||
/// Get the previous adjacent edge to the edge given.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [10, 0])
|
||||
/// |> angledLine(
|
||||
@ -295,7 +295,7 @@ pub async fn get_common_edge(exec_state: &mut ExecState, args: Args) -> Result<K
|
||||
/// // Get an edge shared between two faces, created after a chamfer.
|
||||
///
|
||||
/// scale = 20
|
||||
/// part001 = startSketchOn('XY')
|
||||
/// part001 = startSketchOn(XY)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [0, scale])
|
||||
/// |> line(end = [scale, 0])
|
||||
|
@ -59,7 +59,7 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// extruded in the same direction.
|
||||
///
|
||||
/// ```no_run
|
||||
/// example = startSketchOn('XZ')
|
||||
/// example = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [10, 0])
|
||||
/// |> arc(
|
||||
@ -80,7 +80,7 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [-10, 0])
|
||||
/// |> arc(
|
||||
/// angleStart = 120,
|
||||
@ -102,7 +102,7 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [-10, 0])
|
||||
/// |> arc(
|
||||
/// angleStart = 120,
|
||||
@ -124,7 +124,7 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [-10, 0])
|
||||
/// |> arc(
|
||||
/// angleStart = 120,
|
||||
|
@ -58,7 +58,7 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Loft a square and a triangle.
|
||||
/// squareSketch = startSketchOn('XY')
|
||||
/// squareSketch = startSketchOn(XY)
|
||||
/// |> startProfile(at = [-100, 200])
|
||||
/// |> line(end = [200, 0])
|
||||
/// |> line(end = [0, -200])
|
||||
@ -66,7 +66,7 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
|
||||
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
/// |> close()
|
||||
///
|
||||
/// triangleSketch = startSketchOn(offsetPlane('XY', offset = 75))
|
||||
/// triangleSketch = startSketchOn(offsetPlane(XY, offset = 75))
|
||||
/// |> startProfile(at = [0, 125])
|
||||
/// |> line(end = [-15, -30])
|
||||
/// |> line(end = [30, 0])
|
||||
@ -78,7 +78,7 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Loft a square, a circle, and another circle.
|
||||
/// squareSketch = startSketchOn('XY')
|
||||
/// squareSketch = startSketchOn(XY)
|
||||
/// |> startProfile(at = [-100, 200])
|
||||
/// |> line(end = [200, 0])
|
||||
/// |> line(end = [0, -200])
|
||||
@ -86,10 +86,10 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
|
||||
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
/// |> close()
|
||||
///
|
||||
/// circleSketch0 = startSketchOn(offsetPlane('XY', offset = 75))
|
||||
/// circleSketch0 = startSketchOn(offsetPlane(XY, offset = 75))
|
||||
/// |> circle( center = [0, 100], radius = 50 )
|
||||
///
|
||||
/// circleSketch1 = startSketchOn(offsetPlane('XY', offset = 150))
|
||||
/// circleSketch1 = startSketchOn(offsetPlane(XY, offset = 150))
|
||||
/// |> circle( center = [0, 100], radius = 20 )
|
||||
///
|
||||
/// loft([squareSketch, circleSketch0, circleSketch1])
|
||||
@ -97,7 +97,7 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Loft a square, a circle, and another circle with options.
|
||||
/// squareSketch = startSketchOn('XY')
|
||||
/// squareSketch = startSketchOn(XY)
|
||||
/// |> startProfile(at = [-100, 200])
|
||||
/// |> line(end = [200, 0])
|
||||
/// |> line(end = [0, -200])
|
||||
@ -105,10 +105,10 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result<KclValue, Kc
|
||||
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
|
||||
/// |> close()
|
||||
///
|
||||
/// circleSketch0 = startSketchOn(offsetPlane('XY', offset = 75))
|
||||
/// circleSketch0 = startSketchOn(offsetPlane(XY, offset = 75))
|
||||
/// |> circle( center = [0, 100], radius = 50 )
|
||||
///
|
||||
/// circleSketch1 = startSketchOn(offsetPlane('XY', offset = 150))
|
||||
/// circleSketch1 = startSketchOn(offsetPlane(XY, offset = 150))
|
||||
/// |> circle( center = [0, 100], radius = 20 )
|
||||
///
|
||||
/// loft([squareSketch, circleSketch0, circleSketch1],
|
||||
|
@ -101,7 +101,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// }
|
||||
///
|
||||
/// // Sketch 4 cylinders.
|
||||
/// sketch001 = startSketchOn('XZ')
|
||||
/// sketch001 = startSketchOn(XZ)
|
||||
/// |> circle(center = [0, 0], radius = 2)
|
||||
/// |> extrude(length = 5)
|
||||
/// |> patternTransform(instances = 4, transform = transform)
|
||||
@ -169,7 +169,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res
|
||||
/// p2 = [ l + x, l + y]
|
||||
/// p3 = [ l + x, -l + y]
|
||||
///
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = p0)
|
||||
/// |> line(endAbsolute = p1)
|
||||
/// |> line(endAbsolute = p2)
|
||||
|
@ -26,7 +26,7 @@ pub async fn segment_end(exec_state: &mut ExecState, args: Args) -> Result<KclVa
|
||||
///
|
||||
/// ```no_run
|
||||
/// w = 15
|
||||
/// cube = startSketchOn('XY')
|
||||
/// cube = startSketchOn(XY)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [w, 0], tag = $line1)
|
||||
/// |> line(end = [0, w], tag = $line2)
|
||||
@ -36,7 +36,7 @@ pub async fn segment_end(exec_state: &mut ExecState, args: Args) -> Result<KclVa
|
||||
/// |> extrude(length = 5)
|
||||
///
|
||||
/// fn cylinder(radius, tag) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> circle(radius = radius, center = segEnd(tag) )
|
||||
/// |> extrude(length = radius)
|
||||
@ -78,7 +78,7 @@ pub async fn segment_end_x(exec_state: &mut ExecState, args: Args) -> Result<Kcl
|
||||
/// Compute the ending point of the provided line segment along the 'x' axis.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [20, 0], tag = $thing)
|
||||
/// |> line(end = [0, 5])
|
||||
@ -119,7 +119,7 @@ pub async fn segment_end_y(exec_state: &mut ExecState, args: Args) -> Result<Kcl
|
||||
/// Compute the ending point of the provided line segment along the 'y' axis.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [20, 0])
|
||||
/// |> line(end = [0, 3], tag = $thing)
|
||||
@ -162,7 +162,7 @@ pub async fn segment_start(exec_state: &mut ExecState, args: Args) -> Result<Kcl
|
||||
///
|
||||
/// ```no_run
|
||||
/// w = 15
|
||||
/// cube = startSketchOn('XY')
|
||||
/// cube = startSketchOn(XY)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [w, 0], tag = $line1)
|
||||
/// |> line(end = [0, w], tag = $line2)
|
||||
@ -172,7 +172,7 @@ pub async fn segment_start(exec_state: &mut ExecState, args: Args) -> Result<Kcl
|
||||
/// |> extrude(length = 5)
|
||||
///
|
||||
/// fn cylinder(radius, tag) {
|
||||
/// return startSketchOn('XY')
|
||||
/// return startSketchOn(XY)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> circle( radius = radius, center = segStart(tag) )
|
||||
/// |> extrude(length = radius)
|
||||
@ -214,7 +214,7 @@ pub async fn segment_start_x(exec_state: &mut ExecState, args: Args) -> Result<K
|
||||
/// Compute the starting point of the provided line segment along the 'x' axis.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [20, 0], tag = $thing)
|
||||
/// |> line(end = [0, 5])
|
||||
@ -255,7 +255,7 @@ pub async fn segment_start_y(exec_state: &mut ExecState, args: Args) -> Result<K
|
||||
/// Compute the starting point of the provided line segment along the 'y' axis.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [20, 0])
|
||||
/// |> line(end = [0, 3], tag = $thing)
|
||||
@ -298,7 +298,7 @@ pub async fn last_segment_x(exec_state: &mut ExecState, args: Args) -> Result<Kc
|
||||
/// sketch.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn("XZ")
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [5, 0])
|
||||
/// |> line(end = [20, 5])
|
||||
@ -344,7 +344,7 @@ pub async fn last_segment_y(exec_state: &mut ExecState, args: Args) -> Result<Kc
|
||||
/// sketch.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn("XZ")
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [5, 0])
|
||||
/// |> line(end = [20, 5])
|
||||
@ -387,7 +387,7 @@ pub async fn segment_length(exec_state: &mut ExecState, args: Args) -> Result<Kc
|
||||
/// Compute the length of the provided line segment.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn("XZ")
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> angledLine(
|
||||
/// angle = 60,
|
||||
@ -434,7 +434,7 @@ pub async fn segment_angle(exec_state: &mut ExecState, args: Args) -> Result<Kcl
|
||||
/// Compute the angle (in degrees) of the provided line segment.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn('XZ')
|
||||
/// exampleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [10, 0])
|
||||
/// |> line(end = [5, 10], tag = $seg01)
|
||||
@ -480,7 +480,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result<Kc
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Horizontal pill.
|
||||
/// pillSketch = startSketchOn('XZ')
|
||||
/// pillSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [20, 0])
|
||||
/// |> tangentialArc(end = [0, 10], tag = $arc1)
|
||||
@ -496,7 +496,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result<Kc
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Vertical pill. Use absolute coordinate for arc.
|
||||
/// pillSketch = startSketchOn('XZ')
|
||||
/// pillSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [0, 20])
|
||||
/// |> tangentialArc(endAbsolute = [10, 20], tag = $arc1)
|
||||
@ -511,7 +511,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result<Kc
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// rectangleSketch = startSketchOn('XZ')
|
||||
/// rectangleSketch = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> line(end = [10, 0], tag = $seg1)
|
||||
/// |> angledLine(
|
||||
@ -526,7 +526,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result<Kc
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// bottom = startSketchOn("XY")
|
||||
/// bottom = startSketchOn(XY)
|
||||
/// |> startProfile(at = [0, 0])
|
||||
/// |> arc(
|
||||
/// endAbsolute = [10, 10],
|
||||
@ -538,10 +538,10 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result<Kc
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// circSketch = startSketchOn("XY")
|
||||
/// circSketch = startSketchOn(XY)
|
||||
/// |> circle( center= [0, 0], radius= 3 , tag= $circ)
|
||||
///
|
||||
/// triangleSketch = startSketchOn("XY")
|
||||
/// triangleSketch = startSketchOn(XY)
|
||||
/// |> startProfile(at = [-5, 0])
|
||||
/// |> angledLine(angle = tangentToEnd(circ), length = 10)
|
||||
/// |> line(end = [-15, 0])
|
||||
|
@ -140,7 +140,7 @@ pub async fn circle_three_point(exec_state: &mut ExecState, args: Args) -> Resul
|
||||
/// Construct a circle derived from 3 points.
|
||||
///
|
||||
/// ```no_run
|
||||
/// exampleSketch = startSketchOn("XY")
|
||||
/// exampleSketch = startSketchOn(XY)
|
||||
/// |> circleThreePoint(p1 = [10,10], p2 = [20,8], p3 = [15,5])
|
||||
/// |> extrude(length = 5)
|
||||
/// ```
|
||||
@ -278,7 +278,7 @@ pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Create a regular hexagon inscribed in a circle of radius 10
|
||||
/// hex = startSketchOn('XY')
|
||||
/// hex = startSketchOn(XY)
|
||||
/// |> polygon(
|
||||
/// radius = 10,
|
||||
/// numSides = 6,
|
||||
@ -291,7 +291,7 @@ pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Create a square circumscribed around a circle of radius 5
|
||||
/// square = startSketchOn('XY')
|
||||
/// square = startSketchOn(XY)
|
||||
/// |> polygon(
|
||||
/// radius = 5.0,
|
||||
/// numSides = 4,
|
||||
|
@ -139,7 +139,7 @@ pub async fn sweep(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// sketch001 = startSketchOn(XY)
|
||||
/// circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
|
||||
///
|
||||
/// sketch002 = startSketchOn('YZ')
|
||||
/// sketch002 = startSketchOn(YZ)
|
||||
/// sweepPath = startProfile(sketch002, at = [0, 0])
|
||||
/// |> yLine(length = 231.81)
|
||||
/// |> tangentialArc(radius = 80, angle = -90)
|
||||
|
@ -74,7 +74,7 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// // Scale a pipe.
|
||||
///
|
||||
/// // Create a path for the sweep.
|
||||
/// sweepPath = startSketchOn('XZ')
|
||||
/// sweepPath = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0.05, 0.05])
|
||||
/// |> line(end = [0, 7])
|
||||
/// |> tangentialArc(angle = 90, radius = 5)
|
||||
@ -83,13 +83,13 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// |> line(end = [0, 7])
|
||||
///
|
||||
/// // Create a hole for the pipe.
|
||||
/// pipeHole = startSketchOn('XY')
|
||||
/// pipeHole = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 1.5,
|
||||
/// )
|
||||
///
|
||||
/// sweepSketch = startSketchOn('XY')
|
||||
/// sweepSketch = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 2,
|
||||
@ -115,7 +115,7 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
/// ```
|
||||
/// // Sweep two sketches along the same path.
|
||||
///
|
||||
/// sketch001 = startSketchOn('XY')
|
||||
/// sketch001 = startSketchOn(XY)
|
||||
/// rectangleSketch = startProfile(sketch001, at = [-200, 23.86])
|
||||
/// |> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001)
|
||||
/// |> angledLine(
|
||||
@ -131,7 +131,7 @@ pub async fn scale(exec_state: &mut ExecState, args: Args) -> Result<KclValue, K
|
||||
///
|
||||
/// circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
|
||||
///
|
||||
/// sketch002 = startSketchOn('YZ')
|
||||
/// sketch002 = startSketchOn(YZ)
|
||||
/// sweepPath = startProfile(sketch002, at = [0, 0])
|
||||
/// |> yLine(length = 231.81)
|
||||
/// |> tangentialArc(radius = 80, angle = -90)
|
||||
@ -240,7 +240,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// // Move a pipe.
|
||||
///
|
||||
/// // Create a path for the sweep.
|
||||
/// sweepPath = startSketchOn('XZ')
|
||||
/// sweepPath = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0.05, 0.05])
|
||||
/// |> line(end = [0, 7])
|
||||
/// |> tangentialArc(angle = 90, radius = 5)
|
||||
@ -249,13 +249,13 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// |> line(end = [0, 7])
|
||||
///
|
||||
/// // Create a hole for the pipe.
|
||||
/// pipeHole = startSketchOn('XY')
|
||||
/// pipeHole = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 1.5,
|
||||
/// )
|
||||
///
|
||||
/// sweepSketch = startSketchOn('XY')
|
||||
/// sweepSketch = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 2,
|
||||
@ -275,7 +275,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// import "tests/inputs/cube.sldprt" as cube
|
||||
///
|
||||
/// // Circle so you actually see the move.
|
||||
/// startSketchOn('XY')
|
||||
/// startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [-10, -10],
|
||||
/// radius = 10,
|
||||
@ -295,7 +295,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
/// ```
|
||||
/// // Sweep two sketches along the same path.
|
||||
///
|
||||
/// sketch001 = startSketchOn('XY')
|
||||
/// sketch001 = startSketchOn(XY)
|
||||
/// rectangleSketch = startProfile(sketch001, at = [-200, 23.86])
|
||||
/// |> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001)
|
||||
/// |> angledLine(
|
||||
@ -311,7 +311,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
///
|
||||
/// circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
|
||||
///
|
||||
/// sketch002 = startSketchOn('YZ')
|
||||
/// sketch002 = startSketchOn(YZ)
|
||||
/// sweepPath = startProfile(sketch002, at = [0, 0])
|
||||
/// |> yLine(length = 231.81)
|
||||
/// |> tangentialArc(radius = 80, angle = -90)
|
||||
@ -353,7 +353,7 @@ pub async fn translate(exec_state: &mut ExecState, args: Args) -> Result<KclValu
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Translate and rotate a sketch to create a loft.
|
||||
/// sketch001 = startSketchOn('XY')
|
||||
/// sketch001 = startSketchOn(XY)
|
||||
///
|
||||
/// fn square() {
|
||||
/// return startProfile(sketch001, at = [-10, 10])
|
||||
@ -579,7 +579,7 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// // Rotate a pipe with roll, pitch, and yaw.
|
||||
///
|
||||
/// // Create a path for the sweep.
|
||||
/// sweepPath = startSketchOn('XZ')
|
||||
/// sweepPath = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0.05, 0.05])
|
||||
/// |> line(end = [0, 7])
|
||||
/// |> tangentialArc(angle = 90, radius = 5)
|
||||
@ -588,13 +588,13 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// |> line(end = [0, 7])
|
||||
///
|
||||
/// // Create a hole for the pipe.
|
||||
/// pipeHole = startSketchOn('XY')
|
||||
/// pipeHole = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 1.5,
|
||||
/// )
|
||||
///
|
||||
/// sweepSketch = startSketchOn('XY')
|
||||
/// sweepSketch = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 2,
|
||||
@ -612,7 +612,7 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// // Rotate a pipe with just roll.
|
||||
///
|
||||
/// // Create a path for the sweep.
|
||||
/// sweepPath = startSketchOn('XZ')
|
||||
/// sweepPath = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0.05, 0.05])
|
||||
/// |> line(end = [0, 7])
|
||||
/// |> tangentialArc(angle = 90, radius = 5)
|
||||
@ -621,13 +621,13 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// |> line(end = [0, 7])
|
||||
///
|
||||
/// // Create a hole for the pipe.
|
||||
/// pipeHole = startSketchOn('XY')
|
||||
/// pipeHole = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 1.5,
|
||||
/// )
|
||||
///
|
||||
/// sweepSketch = startSketchOn('XY')
|
||||
/// sweepSketch = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 2,
|
||||
@ -643,7 +643,7 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// // Rotate a pipe about an axis with an angle.
|
||||
///
|
||||
/// // Create a path for the sweep.
|
||||
/// sweepPath = startSketchOn('XZ')
|
||||
/// sweepPath = startSketchOn(XZ)
|
||||
/// |> startProfile(at = [0.05, 0.05])
|
||||
/// |> line(end = [0, 7])
|
||||
/// |> tangentialArc(angle = 90, radius = 5)
|
||||
@ -652,13 +652,13 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// |> line(end = [0, 7])
|
||||
///
|
||||
/// // Create a hole for the pipe.
|
||||
/// pipeHole = startSketchOn('XY')
|
||||
/// pipeHole = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 1.5,
|
||||
/// )
|
||||
///
|
||||
/// sweepSketch = startSketchOn('XY')
|
||||
/// sweepSketch = startSketchOn(XY)
|
||||
/// |> circle(
|
||||
/// center = [0, 0],
|
||||
/// radius = 2,
|
||||
@ -686,7 +686,7 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// ```
|
||||
/// // Sweep two sketches along the same path.
|
||||
///
|
||||
/// sketch001 = startSketchOn('XY')
|
||||
/// sketch001 = startSketchOn(XY)
|
||||
/// rectangleSketch = startProfile(sketch001, at = [-200, 23.86])
|
||||
/// |> angledLine(angle = 0, length = 73.47, tag = $rectangleSegmentA001)
|
||||
/// |> angledLine(
|
||||
@ -702,7 +702,7 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
///
|
||||
/// circleSketch = circle(sketch001, center = [200, -30.29], radius = 32.63)
|
||||
///
|
||||
/// sketch002 = startSketchOn('YZ')
|
||||
/// sketch002 = startSketchOn(YZ)
|
||||
/// sweepPath = startProfile(sketch002, at = [0, 0])
|
||||
/// |> yLine(length = 231.81)
|
||||
/// |> tangentialArc(radius = 80, angle = -90)
|
||||
@ -716,7 +716,7 @@ pub async fn rotate(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
///
|
||||
/// ```no_run
|
||||
/// // Translate and rotate a sketch to create a loft.
|
||||
/// sketch001 = startSketchOn('XY')
|
||||
/// sketch001 = startSketchOn(XY)
|
||||
///
|
||||
/// fn square() {
|
||||
/// return startProfile(sketch001, at = [-10, 10])
|
||||
@ -830,7 +830,7 @@ mod tests {
|
||||
|
||||
use crate::execution::parse_execute;
|
||||
|
||||
const PIPE: &str = r#"sweepPath = startSketchOn('XZ')
|
||||
const PIPE: &str = r#"sweepPath = startSketchOn(XZ)
|
||||
|> startProfile(at = [0.05, 0.05])
|
||||
|> line(end = [0, 7])
|
||||
|> tangentialArc(angle = 90, radius = 5)
|
||||
@ -839,12 +839,12 @@ mod tests {
|
||||
|> line(end = [0, 7])
|
||||
|
||||
// Create a hole for the pipe.
|
||||
pipeHole = startSketchOn('XY')
|
||||
pipeHole = startSketchOn(XY)
|
||||
|> circle(
|
||||
center = [0, 0],
|
||||
radius = 1.5,
|
||||
)
|
||||
sweepSketch = startSketchOn('XY')
|
||||
sweepSketch = startSketchOn(XY)
|
||||
|> circle(
|
||||
center = [0, 0],
|
||||
radius = 2,
|
||||
|
@ -1612,7 +1612,7 @@ thk = 5
|
||||
hole_diam = 5
|
||||
// define a rectangular shape func
|
||||
fn rectShape(pos, w, l) {
|
||||
rr = startSketchOn('xy')
|
||||
rr = startSketchOn(XY)
|
||||
|> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] - (l / 2)], tag = $edge1)
|
||||
|> line(endAbsolute = [pos[0] + w / 2, pos[1] + l / 2], tag = $edge2)
|
||||
|
Reference in New Issue
Block a user