Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
Signed-off-by: Jess Frazelle <[email protected]>
  • Loading branch information
jessfraz committed Sep 12, 2024
1 parent 5442fb1 commit e3458a4
Showing 1 changed file with 49 additions and 1 deletion.
50 changes: 49 additions & 1 deletion src/wasm-lib/kcl/src/std/patterns.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::{
errors::{KclError, KclErrorDetails},
executor::{
ExtrudeGroup, ExtrudeGroupSet, Geometries, Geometry, KclValue, Point3d, SketchGroup, SketchGroupSet,
SourceRange, UserVal,
SketchSurface, SourceRange, UserVal,
},
function_param::FunctionParam,
std::{types::Uint, Args},
Expand Down Expand Up @@ -475,13 +475,37 @@ async fn inner_pattern_linear_3d(

let mut extrude_groups = Vec::new();
for extrude_group in starting_extrude_groups.iter() {
// Before we pattern, we need to enable the sketch mode.
// We do this so if the user is patterning a sketch on a face,
// it patterns correctly.
args.batch_modeling_cmd(
uuid::Uuid::new_v4(),
kittycad::types::ModelingCmd::EnableSketchMode {
animated: false,
ortho: false,
entity_id: extrude_group.sketch_group.on.id(),
adjust_camera: false,
planar_normal: if let SketchSurface::Plane(plane) = &extrude_group.sketch_group.on {
// We pass in the normal for the plane here.
Some(plane.z_axis.into())
} else {
None
},
},
)
.await?;

let geometries = pattern_linear(
LinearPattern::ThreeD(data.clone()),
Geometry::ExtrudeGroup(extrude_group.clone()),
args.clone(),
)
.await?;

// Disable the sketch mode.
args.batch_modeling_cmd(uuid::Uuid::new_v4(), kittycad::types::ModelingCmd::SketchModeDisable {})
.await?;

let Geometries::ExtrudeGroups(new_extrude_groups) = geometries else {
return Err(KclError::Semantic(KclErrorDetails {
message: "Expected a vec of extrude groups".to_string(),
Expand Down Expand Up @@ -798,13 +822,37 @@ async fn inner_pattern_circular_3d(

let mut extrude_groups = Vec::new();
for extrude_group in starting_extrude_groups.iter() {
// Before we pattern, we need to enable the sketch mode.
// We do this so if the user is patterning a sketch on a face,
// it patterns correctly.
args.batch_modeling_cmd(
uuid::Uuid::new_v4(),
kittycad::types::ModelingCmd::EnableSketchMode {
animated: false,
ortho: false,
entity_id: extrude_group.sketch_group.on.id(),
adjust_camera: false,
planar_normal: if let SketchSurface::Plane(plane) = &extrude_group.sketch_group.on {
// We pass in the normal for the plane here.
Some(plane.z_axis.into())
} else {
None
},
},
)
.await?;

let geometries = pattern_circular(
CircularPattern::ThreeD(data.clone()),
Geometry::ExtrudeGroup(extrude_group.clone()),
args.clone(),
)
.await?;

// Disable the sketch mode.
args.batch_modeling_cmd(uuid::Uuid::new_v4(), kittycad::types::ModelingCmd::SketchModeDisable {})
.await?;

let Geometries::ExtrudeGroups(new_extrude_groups) = geometries else {
return Err(KclError::Semantic(KclErrorDetails {
message: "Expected a vec of extrude groups".to_string(),
Expand Down

0 comments on commit e3458a4

Please sign in to comment.