Skip to content

Commit 0a0e6ab

Browse files
authored
KCL: Autocomplete snippets for 'center' should suggest the origin (#7164)
Pattern functions and `polygon` both take a parameter `center` which defaulted to [3.14, 3.14] for silly reasons. They now default to [0, 0].
1 parent 9c7aee3 commit 0a0e6ab

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

docs/kcl-std/std.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127335,6 +127335,10 @@
127335127335
},
127336127336
"required": true,
127337127337
"includeInSnippet": true,
127338+
"snippetValueArray": [
127339+
"0",
127340+
"0"
127341+
],
127338127342
"description": "The center about which to make the pattern. This is a 2D vector.",
127339127343
"labelRequired": true
127340127344
},
@@ -140204,6 +140208,11 @@
140204140208
},
140205140209
"required": true,
140206140210
"includeInSnippet": true,
140211+
"snippetValueArray": [
140212+
"0",
140213+
"0",
140214+
"0"
140215+
],
140207140216
"description": "The center about which to make the pattern. This is a 3D vector.",
140208140217
"labelRequired": true
140209140218
},
@@ -172401,6 +172410,10 @@
172401172410
},
172402172411
"required": true,
172403172412
"includeInSnippet": true,
172413+
"snippetValueArray": [
172414+
"0",
172415+
"0"
172416+
],
172404172417
"description": "The center point of the polygon",
172405172418
"labelRequired": true
172406172419
},

rust/kcl-lib/src/docs/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ mod tests {
10181018
let snippet = pattern_fn.to_autocomplete_snippet().unwrap();
10191019
assert_eq!(
10201020
snippet,
1021-
r#"patternCircular3d(${0:%}, instances = ${1:10}, axis = [${2:3.14}, ${3:3.14}, ${4:3.14}], center = [${5:3.14}, ${6:3.14}, ${7:3.14}])"#
1021+
r#"patternCircular3d(${0:%}, instances = ${1:10}, axis = [${2:3.14}, ${3:3.14}, ${4:3.14}], center = [${5:0}, ${6:0}, ${7:0}])"#
10221022
);
10231023
}
10241024

rust/kcl-lib/src/std/patterns.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ pub async fn pattern_circular_2d(exec_state: &mut ExecState, args: Args) -> Resu
941941
args = {
942942
sketch_set = { docs = "Which sketch(es) to pattern" },
943943
instances = { docs = "The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect."},
944-
center = { docs = "The center about which to make the pattern. This is a 2D vector."},
944+
center = { docs = "The center about which to make the pattern. This is a 2D vector.", snippet_value_array = ["0", "0"]},
945945
arc_degrees = { docs = "The arc angle (in degrees) to place the repetitions. Must be greater than 0. Defaults to 360."},
946946
rotate_duplicates= { docs = "Whether or not to rotate the duplicates as they are copied. Defaults to true."},
947947
use_original= { docs = "If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false."},
@@ -1083,7 +1083,7 @@ pub async fn pattern_circular_3d(exec_state: &mut ExecState, args: Args) -> Resu
10831083
solids = { docs = "Which solid(s) to pattern" },
10841084
instances = { docs = "The number of total instances. Must be greater than or equal to 1. This includes the original entity. For example, if instances is 2, there will be two copies -- the original, and one new copy. If instances is 1, this has no effect."},
10851085
axis = { docs = "The axis around which to make the pattern. This is a 3D vector"},
1086-
center = { docs = "The center about which to make the pattern. This is a 3D vector."},
1086+
center = { docs = "The center about which to make the pattern. This is a 3D vector.", snippet_value_array = ["0", "0", "0"]},
10871087
arc_degrees = { docs = "The arc angle (in degrees) to place the repetitions. Must be greater than 0. Defaults to 360."},
10881088
rotate_duplicates = { docs = "Whether or not to rotate the duplicates as they are copied. Defaults to true."},
10891089
use_original = { docs = "If the target was sketched on an extrusion, setting this will use the original sketch as the target, not the entire joined solid. Defaults to false."},

rust/kcl-lib/src/std/shapes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ pub async fn polygon(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
328328
sketch_surface_or_group = { docs = "Plane or surface to sketch on" },
329329
radius = { docs = "The radius of the polygon", include_in_snippet = true },
330330
num_sides = { docs = "The number of sides in the polygon", include_in_snippet = true },
331-
center = { docs = "The center point of the polygon", include_in_snippet = true },
331+
center = { docs = "The center point of the polygon", snippet_value_array = ["0", "0"] },
332332
inscribed = { docs = "Whether the polygon is inscribed (true, the default) or circumscribed (false) about a circle with the specified radius" },
333333
},
334334
tags = ["sketch"]

0 commit comments

Comments
 (0)