Skip to content

Commit

Permalink
Release 101 (#1161)
Browse files Browse the repository at this point in the history
* WIP release

* Integrate changes to the text-to-cad API

* Update walkie talkie example
  • Loading branch information
adamchalmers authored Feb 27, 2025
1 parent 201f221 commit d7107dd
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 91 deletions.
177 changes: 104 additions & 73 deletions Cargo.lock

Large diffs are not rendered by default.

12 changes: 6 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "zoo"
version = "0.2.101"
version = "0.2.102"
edition = "2021"
build = "build.rs"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
Expand All @@ -22,10 +22,10 @@ git_rev = "0.1.0"
heck = "0.5.0"
http = "1"
itertools = "0.12.1"
kcl-lib = { version = "0.2.34", features = ["disable-println"] }
kcl-test-server = "0.1.21"
kittycad = { version = "0.3.28", features = ["clap", "tabled", "requests", "retry"] }
kittycad-modeling-cmds = { version = "=0.2.95", features = ["websocket", "convert_client_crate", "tabled"] }
kcl-lib = { version = "0.2.39", features = ["disable-println"] }
kcl-test-server = "0.1.39"
kittycad = { version = "0.3.30", features = ["clap", "tabled", "requests", "retry"] }
kittycad-modeling-cmds = { version = "0.2.100", features = ["websocket", "convert_client_crate", "tabled"] }
log = "0.4.25"
nu-ansi-term = "0.50.1"
num-traits = "0.2.19"
Expand All @@ -46,7 +46,7 @@ slog-async = "2"
slog-scope = "4"
slog-stdlog = "4"
slog-term = "2"
tabled = { version = "0.17.0", features = ["ansi"] }
tabled = { version = "0.18.0", features = ["ansi"] }
tabwriter = "1.4.1"
terminal_size = "0.4.0"
thiserror = "2"
Expand Down
7 changes: 4 additions & 3 deletions src/cmd_kcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use crate::kcl_error_fmt;
use anyhow::Result;
use clap::Parser;
use kcmc::each_cmd as mcmd;
use kcmc::format::OutputFormat;
use kcmc::format::OutputFormat3d as OutputFormat;
use kittycad::types as kt;
use kittycad_modeling_cmds as kcmc;
use kittycad_modeling_cmds::ModelingCmd;
Expand Down Expand Up @@ -125,7 +125,8 @@ impl crate::cmd::Command for CmdKclExport {
let session_data = ectx
.run(&program, &mut state)
.await
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?;
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?
.1;

// Zoom on the object.
ectx.engine
Expand Down Expand Up @@ -487,7 +488,7 @@ pub fn get_image_format_from_extension(ext: &str) -> Result<kittycad_modeling_cm
fn get_output_format(
format: &kittycad::types::FileExportFormat,
src_unit: kittycad_modeling_cmds::units::UnitLength,
) -> kittycad_modeling_cmds::format::OutputFormat {
) -> OutputFormat {
// Zoo co-ordinate system.
//
// * Forward: -Y
Expand Down
3 changes: 3 additions & 0 deletions src/cmd_ml/cmd_kcl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl crate::cmd::Command for CmdKclEdit {
vec![kittycad::types::SourceRangePrompt {
range: convert_to_source_range(source_range)?,
prompt: prompt.clone(),
file: None,
}]
} else {
Default::default()
Expand All @@ -73,6 +74,8 @@ impl crate::cmd::Command for CmdKclEdit {
original_source_code: input.to_string(),
prompt: if source_ranges.is_empty() { Some(prompt) } else { None },
source_ranges,
project_name: None,
kcl_version: Some(kcl_lib::version().to_owned()),
};

let model = ctx.get_edit_for_prompt("", &body).await?;
Expand Down
4 changes: 2 additions & 2 deletions src/cmd_ml/cmd_text_to_cad.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use anyhow::Result;
use clap::Parser;
use kcl_lib::EngineManager;
use kcmc::each_cmd as mcmd;
use kcmc::format::InputFormat;
use kcmc::format::InputFormat3d;
use kcmc::ok_response::OkModelingCmdResponse;
use kcmc::websocket::OkWebSocketResponseData;
use kcmc::{ImageFormat, ModelingCmd};
Expand Down Expand Up @@ -375,7 +375,7 @@ async fn get_image_bytes(
path: "model.gltf".to_string(),
data: gltf_bytes.to_vec(),
}],
format: InputFormat::Gltf(Default::default()),
format: InputFormat3d::Gltf(Default::default()),
}),
)
.await?;
Expand Down
7 changes: 6 additions & 1 deletion src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ impl Context<'_> {
let session_data = ctx
.run(&program, &mut state)
.await
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?;
.map_err(|err| kcl_error_fmt::KclError::new(code.to_string(), err))?
.1;

// Zoom on the object.
ctx.engine
Expand Down Expand Up @@ -200,6 +201,8 @@ impl Context<'_> {
format.into(),
&TextToCadCreateBody {
prompt: prompt.to_string(),
kcl_version: Some(kcl_lib::version().to_owned()),
project_name: None,
},
)
.await?;
Expand Down Expand Up @@ -233,6 +236,7 @@ impl Context<'_> {
user_id,
code,
model,
kcl_version,
} = result
{
gen_model = TextToCad {
Expand All @@ -251,6 +255,7 @@ impl Context<'_> {
user_id,
code,
model,
kcl_version,
};
} else {
anyhow::bail!("Unexpected response type: {:?}", result);
Expand Down
4 changes: 2 additions & 2 deletions tests/walkie-talkie/body.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ bodySketch = startSketchOn('XZ')
|> xLine(-width, %, $chamfer3)
|> close(tag = $chamfer4)
bodyExtrude = extrude(bodySketch, length = thickness)
|> chamfer({
|> chamfer(
length = chamferLength,
tags = [
getNextAdjacentEdge(chamfer1),
getNextAdjacentEdge(chamfer2),
getNextAdjacentEdge(chamfer3),
getNextAdjacentEdge(chamfer4)
]
}, %)
)

// Define the offset for the indentation
sketch002 = startSketchOn(bodyExtrude, 'END')
Expand Down
4 changes: 2 additions & 2 deletions tests/walkie-talkie/button.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ export fn button(origin, rotation, plane) {
}, %)
|> close()
buttonExtrude = extrude(buttonSketch, length = buttonThickness)
|> chamfer({
|> chamfer(
length = .050,
tags = [
getNextAdjacentEdge(tag1),
getNextAdjacentEdge(tag2)
]
}, %)
)
|> appearance(color = "#ff0000")

return buttonExtrude
Expand Down
4 changes: 2 additions & 2 deletions tests/walkie-talkie/talk-button.kcl
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ talkButtonSketch = startSketchOn(talkButtonPlane)

// Create the talk button and apply fillets
extrude(talkButtonSketch, length = talkButtonHeight)
|> fillet({
|> fillet(
radius = 0.050,
tags = [
getNextAdjacentEdge(tag1),
getNextAdjacentEdge(tag2),
getNextAdjacentEdge(tag3),
getNextAdjacentEdge(tag4)
]
}, %)
)
|> appearance(color = '#D0FF01', metalness = 90, roughness = 90)

0 comments on commit d7107dd

Please sign in to comment.