Skip to content

Do multiple fillets in one API call #6750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
90 changes: 57 additions & 33 deletions rust/kcl-lib/src/std/fillet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,43 +82,67 @@ async fn inner_fillet(
exec_state: &mut ExecState,
args: Args,
) -> Result<Box<Solid>, KclError> {
// If you try and tag multiple edges with a tagged fillet, we want to return an
// error to the user that they can only tag one edge at a time.
if tag.is_some() && tags.len() > 1 {
return Err(KclError::Type(KclErrorDetails {
message: "You can only tag one edge at a time with a tagged fillet. Either delete the tag for the fillet fn if you don't need it OR separate into individual fillet functions for each tag.".to_string(),
source_ranges: vec![args.source_range],
backtrace: Default::default(),
}));
}
if tags.is_empty() {
return Err(KclError::Semantic(KclErrorDetails {
source_ranges: vec![args.source_range],
message: "You must fillet at least one tag".to_owned(),
backtrace: Default::default(),
}));
}

let mut solid = solid.clone();
for edge_tag in tags {
let edge_id = edge_tag.get_engine_id(exec_state, &args)?;
let edge_ids = tags
.into_iter()
.map(|edge_tag| edge_tag.get_engine_id(exec_state, &args))
.collect::<Result<Vec<_>, _>>()?;

let id = exec_state.next_uuid();
args.batch_end_cmd(
id,
ModelingCmd::from(mcmd::Solid3dFilletEdge {
edge_id: None,
edge_ids: vec![edge_id],
extra_face_ids: vec![],
strategy: Default::default(),
object_id: solid.id,
radius: LengthUnit(radius.to_mm()),
tolerance: LengthUnit(tolerance.as_ref().map(|t| t.to_mm()).unwrap_or(DEFAULT_TOLERANCE)),
cut_type: CutType::Fillet,
}),
)
.await?;
let id = exec_state.next_uuid();
let mut extra_face_ids = Vec::new();
let num_extra_ids = edge_ids.len() - 1;
for _ in 0..num_extra_ids {
extra_face_ids.push(exec_state.next_uuid());
}
args.batch_end_cmd(
id,
ModelingCmd::from(mcmd::Solid3dFilletEdge {
edge_id: None,
edge_ids: edge_ids.clone(),
extra_face_ids,
strategy: Default::default(),
object_id: solid.id,
radius: LengthUnit(radius.to_mm()),
tolerance: LengthUnit(tolerance.as_ref().map(|t| t.to_mm()).unwrap_or(DEFAULT_TOLERANCE)),
cut_type: CutType::Fillet,
}),
)
.await?;

solid.edge_cuts.push(EdgeCut::Fillet {
id,
edge_id,
radius: radius.clone(),
tag: Box::new(tag.clone()),
});
let new_edge_cuts = edge_ids.into_iter().map(|edge_id| EdgeCut::Fillet {
id,
edge_id,
radius: radius.clone(),
tag: Box::new(tag.clone()),
});
solid.edge_cuts.extend(new_edge_cuts);

if let Some(ref tag) = tag {
solid.value.push(ExtrudeSurface::Fillet(FilletSurface {
face_id: id,
tag: Some(tag.clone()),
geo_meta: GeoMeta {
id,
metadata: args.source_range.into(),
},
}));
}
if let Some(ref tag) = tag {
solid.value.push(ExtrudeSurface::Fillet(FilletSurface {
face_id: id,
tag: Some(tag.clone()),
geo_meta: GeoMeta {
id,
metadata: args.source_range.into(),
},
}));
}

Ok(solid)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,30 +224,16 @@ description: Artifact commands basic_fillet_cube_close_opposite.kcl
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"[uuid]",
"[uuid]"
],
"radius": 2.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_fillet_edge",
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"extra_face_ids": [
"[uuid]"
],
"radius": 2.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
]
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ flowchart LR
22["SweepEdge Adjacent"]
23["EdgeCut Fillet<br>[221, 281, 0]"]
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
24["EdgeCut Fillet<br>[221, 281, 0]"]
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
1 --- 2
2 --- 3
2 --- 4
Expand All @@ -64,7 +62,7 @@ flowchart LR
6 x--> 13
6 --- 15
6 --- 19
6 --- 24
6 --- 23
8 --- 9
8 --- 10
8 --- 11
Expand Down Expand Up @@ -95,5 +93,4 @@ flowchart LR
16 <--x 14
17 <--x 14
18 <--x 14
15 <--x 23
```
20 changes: 3 additions & 17 deletions rust/kcl-lib/tests/basic_fillet_cube_end/artifact_commands.snap
Original file line number Diff line number Diff line change
Expand Up @@ -224,30 +224,16 @@ description: Artifact commands basic_fillet_cube_end.kcl
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"[uuid]",
"[uuid]"
],
"radius": 2.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_fillet_edge",
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"extra_face_ids": [
"[uuid]"
],
"radius": 2.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
]
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ flowchart LR
22["SweepEdge Adjacent"]
23["EdgeCut Fillet<br>[209, 267, 0]"]
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
24["EdgeCut Fillet<br>[209, 267, 0]"]
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
1 --- 2
2 --- 3
2 --- 4
Expand All @@ -52,7 +50,7 @@ flowchart LR
3 x--> 13
3 --- 18
3 --- 22
3 --- 24
3 --- 23
4 --- 10
4 x--> 13
4 --- 17
Expand Down Expand Up @@ -95,5 +93,4 @@ flowchart LR
16 <--x 14
17 <--x 14
18 <--x 14
18 <--x 23
```
Original file line number Diff line number Diff line change
Expand Up @@ -224,30 +224,16 @@ description: Artifact commands basic_fillet_cube_start.kcl
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"[uuid]",
"[uuid]"
],
"radius": 2.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_fillet_edge",
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"extra_face_ids": [
"[uuid]"
],
"radius": 2.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
]
}
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ flowchart LR
22["SweepEdge Adjacent"]
23["EdgeCut Fillet<br>[209, 251, 0]"]
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
24["EdgeCut Fillet<br>[209, 251, 0]"]
%% [ProgramBodyItem { index: 0 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
1 --- 2
2 --- 3
2 --- 4
Expand All @@ -61,7 +59,6 @@ flowchart LR
5 x--> 13
5 --- 16
5 --- 20
5 --- 24
6 --- 11
6 x--> 13
6 --- 15
Expand Down
58 changes: 7 additions & 51 deletions rust/kcl-lib/tests/fillet-and-shell/artifact_commands.snap
Original file line number Diff line number Diff line change
Expand Up @@ -351,64 +351,20 @@ description: Artifact commands fillet-and-shell.kcl
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"[uuid]",
"[uuid]",
"[uuid]",
"[uuid]"
],
"radius": 1.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_fillet_edge",
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"extra_face_ids": [
"[uuid]",
"[uuid]",
"[uuid]"
],
"radius": 1.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_fillet_edge",
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"[uuid]"
],
"radius": 1.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
}
},
{
"cmdId": "[uuid]",
"range": [],
"command": {
"type": "solid3d_fillet_edge",
"object_id": "[uuid]",
"edge_id": null,
"edge_ids": [
"[uuid]"
],
"radius": 1.0,
"tolerance": 0.0000001,
"cut_type": "fillet",
"strategy": "automatic",
"extra_face_ids": []
]
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,12 +174,6 @@ flowchart LR
85["SweepEdge Adjacent"]
86["EdgeCut Fillet<br>[1068, 1274, 0]"]
%% [ProgramBodyItem { index: 17 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
87["EdgeCut Fillet<br>[1068, 1274, 0]"]
%% [ProgramBodyItem { index: 17 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
88["EdgeCut Fillet<br>[1068, 1274, 0]"]
%% [ProgramBodyItem { index: 17 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
89["EdgeCut Fillet<br>[1068, 1274, 0]"]
%% [ProgramBodyItem { index: 17 }, VariableDeclarationDeclaration, VariableDeclarationInit, PipeBodyItem { index: 7 }]
1 --- 7
2 --- 8
3 --- 10
Expand Down Expand Up @@ -319,8 +313,5 @@ flowchart LR
74 <--x 69
75 <--x 69
76 <--x 69
81 <--x 89
82 <--x 87
83 <--x 88
84 <--x 86
81 <--x 86
```
Loading
Loading