Fix rebase problems
This commit is contained in:
@ -1,11 +1,5 @@
|
|||||||
{
|
{
|
||||||
<<<<<<< HEAD
|
"original_source_code": "sketch001 = startSketchOn(XZ)\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn('XZ')\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn(XY)\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine(angle = 0, length = 176.4, tag = $rectangleSegmentA001)\n |> angledLine(angle = segAng(rectangleSegmentA001) - 90,\n length = 53.4\n ], tag = $rectangleSegmentB001)\n |> angledLine(angle = segAng(rectangleSegmentA001),\n length = -segLen(rectangleSegmentA001)\n tag = $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n",
|
||||||
"original_source_code": "sketch001 = startSketchOn('XZ')\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn('XZ')\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn(XY)\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine([0, 176.4], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 53.4\n ], %, $rectangleSegmentB001)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %, $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n",
|
|
||||||
||||||| parent of bcbec9f87 (Update KCL in JS project)
|
|
||||||
"original_source_code": "sketch001 = startSketchOn('XZ')\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn('XZ')\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn('XY')\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine([0, 176.4], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 53.4\n ], %, $rectangleSegmentB001)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n ], %, $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n",
|
|
||||||
=======
|
|
||||||
"original_source_code": "sketch001 = startSketchOn('XZ')\nprofile001 = startProfileAt([57.81, 250.51], sketch001)\n |> line(end = [121.13, 56.63], tag = $seg02)\n |> line(end = [83.37, -34.61], tag = $seg01)\n |> line(end = [19.66, -116.4])\n |> line(end = [-221.8, -41.69])\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude001 = extrude(profile001, length = 200)\nsketch002 = startSketchOn('XZ')\n |> startProfileAt([-73.64, -42.89], %)\n |> xLine(length = 173.71)\n |> line(end = [-22.12, -94.4])\n |> xLine(length = -156.98)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude002 = extrude(sketch002, length = 50)\nsketch003 = startSketchOn('XY')\n |> startProfileAt([52.92, 157.81], %)\n |> angledLine(angle = 0, 176.4], %, $rectangleSegmentA001)\n |> angledLine([\n segAng(rectangleSegmentA001) - 90,\n 53.4\n ], %, length = $rectangleSegmentB001)\n |> angledLine([\n segAng(rectangleSegmentA001),\n -segLen(rectangleSegmentA001)\n , tag = $rectangleSegmentC001)\n |> line(endAbsolute = [profileStartX(%), profileStartY(%)])\n |> close()\nextrude003 = extrude(sketch003, length = 20)\n",
|
|
||||||
>>>>>>> bcbec9f87 (Update KCL in JS project)
|
|
||||||
"prompt": "make this neon green please, use #39FF14",
|
"prompt": "make this neon green please, use #39FF14",
|
||||||
"source_ranges": [
|
"source_ranges": [
|
||||||
{
|
{
|
||||||
|
|||||||
@ -58,13 +58,7 @@ test.describe('Testing constraints', { tag: ['@skipWin'] }, () => {
|
|||||||
.click()
|
.click()
|
||||||
|
|
||||||
await expect(page.locator('.cm-content')).toHaveText(
|
await expect(page.locator('.cm-content')).toHaveText(
|
||||||
<<<<<<< HEAD
|
`length001 = 20sketch001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> angledLine(angle = 90, length = length001) |> xLine(length = -20)`
|
||||||
`length001 = 20sketch001 = startSketchOn(XY) |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> angledLine([90, length001], %) |> xLine(length = -20)`
|
|
||||||
||||||| parent of bcbec9f87 (Update KCL in JS project)
|
|
||||||
`length001 = 20sketch001 = startSketchOn('XY') |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> angledLine([90, length001], %) |> xLine(length = -20)`
|
|
||||||
=======
|
|
||||||
`length001 = 20sketch001 = startSketchOn('XY') |> startProfileAt([-10, -10], %) |> line(end = [20, 0]) |> angledLine(angle = 90, length = length001) |> xLine(length = -20)`
|
|
||||||
>>>>>>> bcbec9f87 (Update KCL in JS project)
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Make sure we didn't pop out of sketch mode.
|
// Make sure we didn't pop out of sketch mode.
|
||||||
@ -1156,7 +1150,9 @@ test.describe('Electron constraint tests', () => {
|
|||||||
await clickOnFirstSegmentLabel()
|
await clickOnFirstSegmentLabel()
|
||||||
await cmdBar.progressCmdBar()
|
await cmdBar.progressCmdBar()
|
||||||
await editor.expectEditor.toContain('length001 = 15.3')
|
await editor.expectEditor.toContain('length001 = 15.3')
|
||||||
await editor.expectEditor.toContain('|> angledLine(angle = 9, length = length001)')
|
await editor.expectEditor.toContain(
|
||||||
|
'|> angledLine(angle = 9, length = length001)'
|
||||||
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
await test.step('Double click again and expect failure', async () => {
|
await test.step('Double click again and expect failure', async () => {
|
||||||
|
|||||||
@ -43,20 +43,12 @@ overwrite-sim-test test_name:
|
|||||||
EXPECTORATE=overwrite TWENTY_TWENTY=overwrite {{cita}} -p kcl-lib --no-quiet -- tests::{{test_name}}::kcl_test_execute
|
EXPECTORATE=overwrite TWENTY_TWENTY=overwrite {{cita}} -p kcl-lib --no-quiet -- tests::{{test_name}}::kcl_test_execute
|
||||||
EXPECTORATE=overwrite {{cita}} -p kcl-lib --no-quiet -- simulation_tests::{{test_name}}::test_after_engine
|
EXPECTORATE=overwrite {{cita}} -p kcl-lib --no-quiet -- simulation_tests::{{test_name}}::test_after_engine
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
# Regenerate all the simulation test output.
|
# Regenerate all the simulation test output.
|
||||||
redo-sim-tests:
|
redo-sim-tests:
|
||||||
EXPECTORATE=overwrite TWENTY_TWENTY=overwrite {{cita}} -p kcl-lib --no-quiet -- simulation_tests
|
EXPECTORATE=overwrite TWENTY_TWENTY=overwrite {{cita}} -p kcl-lib --no-quiet -- simulation_tests
|
||||||
||||||| parent of afaad9c3c (Fix KCL examples)
|
|
||||||
=======
|
|
||||||
overwrite-sim-test-sample test_name:
|
|
||||||
EXPECTORATE=overwrite {{cita}} -p kcl-lib --no-quiet -- simulation_tests::kcl_samples::parse_{{test_name}}
|
|
||||||
EXPECTORATE=overwrite {{cita}} -p kcl-lib --no-quiet -- simulation_tests::kcl_samples::unparse_{{test_name}}
|
|
||||||
EXPECTORATE=overwrite TWENTY_TWENTY=overwrite {{cita}} -p kcl-lib --no-quiet -- simulation_tests::kcl_samples::kcl_test_execute_{{test_name}}
|
|
||||||
>>>>>>> afaad9c3c (Fix KCL examples)
|
|
||||||
|
|
||||||
test:
|
test:
|
||||||
export RUST_BRACKTRACE="full" && cargo nextest run --workspace --no-fail-fast
|
export RUST_BRACKTRACE="full" && {{cnr}} --workspace --no-fail-fast
|
||||||
|
|
||||||
bump-kcl-crate-versions bump='patch':
|
bump-kcl-crate-versions bump='patch':
|
||||||
# First build the kcl-bumper tool.
|
# First build the kcl-bumper tool.
|
||||||
|
|||||||
@ -3,23 +3,19 @@
|
|||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use kcl_derive_docs::stdlib;
|
use kcl_derive_docs::stdlib;
|
||||||
use kcmc::{
|
use kcmc::{each_cmd as mcmd, length_unit::LengthUnit, shared::CutType, ModelingCmd};
|
||||||
each_cmd as mcmd, length_unit::LengthUnit, ok_response::OkModelingCmdResponse, shared::CutType,
|
|
||||||
websocket::OkWebSocketResponseData, ModelingCmd,
|
|
||||||
};
|
|
||||||
use kittycad_modeling_cmds as kcmc;
|
use kittycad_modeling_cmds as kcmc;
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use uuid::Uuid;
|
|
||||||
|
|
||||||
|
use super::DEFAULT_TOLERANCE;
|
||||||
use crate::{
|
use crate::{
|
||||||
errors::{KclError, KclErrorDetails},
|
errors::{KclError, KclErrorDetails},
|
||||||
execution::{
|
execution::{
|
||||||
kcl_value::RuntimeType, EdgeCut, ExecState, ExtrudeSurface, FilletSurface, GeoMeta, KclValue, PrimitiveType,
|
types::{PrimitiveType, RuntimeType},
|
||||||
Solid, TagIdentifier,
|
EdgeCut, ExecState, ExtrudeSurface, FilletSurface, GeoMeta, KclValue, Solid, TagIdentifier,
|
||||||
},
|
},
|
||||||
parsing::ast::types::TagNode,
|
parsing::ast::types::TagNode,
|
||||||
settings::types::UnitLength,
|
|
||||||
std::Args,
|
std::Args,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
};
|
};
|
||||||
@ -169,10 +165,8 @@ async fn inner_fillet(
|
|||||||
edge_id,
|
edge_id,
|
||||||
object_id: solid.id,
|
object_id: solid.id,
|
||||||
radius: LengthUnit(radius),
|
radius: LengthUnit(radius),
|
||||||
tolerance: LengthUnit(tolerance.unwrap_or(default_tolerance(&args.ctx.settings.units))),
|
tolerance: LengthUnit(tolerance.unwrap_or(DEFAULT_TOLERANCE)),
|
||||||
cut_type: CutType::Fillet,
|
cut_type: CutType::Fillet,
|
||||||
// We make this a none so that we can remove it in the future.
|
|
||||||
face_id: None,
|
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
@ -199,264 +193,6 @@ async fn inner_fillet(
|
|||||||
Ok(solid)
|
Ok(solid)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the opposite edge to the edge given.
|
|
||||||
pub async fn get_opposite_edge(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
|
||||||
let tag: TagIdentifier = args.get_data()?;
|
|
||||||
|
|
||||||
let edge = inner_get_opposite_edge(tag, exec_state, args.clone()).await?;
|
|
||||||
Ok(KclValue::Uuid {
|
|
||||||
value: edge,
|
|
||||||
meta: vec![args.source_range.into()],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the opposite edge to the edge given.
|
|
||||||
///
|
|
||||||
/// ```no_run
|
|
||||||
/// exampleSketch = startSketchOn('XZ')
|
|
||||||
/// |> startProfileAt([0, 0], %)
|
|
||||||
/// |> line(end = [10, 0])
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 60,
|
|
||||||
/// length = 10,
|
|
||||||
/// )
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 120,
|
|
||||||
/// length = 10,
|
|
||||||
/// )
|
|
||||||
/// |> line(end = [-10, 0])
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 240,
|
|
||||||
/// length = 10,
|
|
||||||
/// tag = $referenceEdge,
|
|
||||||
/// )
|
|
||||||
/// |> close()
|
|
||||||
///
|
|
||||||
/// example = extrude(exampleSketch, length = 5)
|
|
||||||
/// |> fillet(
|
|
||||||
/// radius = 3,
|
|
||||||
/// tags = [getOppositeEdge(referenceEdge)],
|
|
||||||
/// )
|
|
||||||
/// ```
|
|
||||||
#[stdlib {
|
|
||||||
name = "getOppositeEdge",
|
|
||||||
}]
|
|
||||||
async fn inner_get_opposite_edge(tag: TagIdentifier, exec_state: &mut ExecState, args: Args) -> Result<Uuid, KclError> {
|
|
||||||
if args.ctx.no_engine_commands().await {
|
|
||||||
return Ok(exec_state.next_uuid());
|
|
||||||
}
|
|
||||||
let face_id = args.get_adjacent_face_to_tag(exec_state, &tag, false).await?;
|
|
||||||
|
|
||||||
let id = exec_state.next_uuid();
|
|
||||||
let tagged_path = args.get_tag_engine_info(exec_state, &tag)?;
|
|
||||||
|
|
||||||
let resp = args
|
|
||||||
.send_modeling_cmd(
|
|
||||||
id,
|
|
||||||
ModelingCmd::from(mcmd::Solid3dGetOppositeEdge {
|
|
||||||
edge_id: tagged_path.id,
|
|
||||||
object_id: tagged_path.sketch,
|
|
||||||
face_id,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
let OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: OkModelingCmdResponse::Solid3dGetOppositeEdge(opposite_edge),
|
|
||||||
} = &resp
|
|
||||||
else {
|
|
||||||
return Err(KclError::Engine(KclErrorDetails {
|
|
||||||
message: format!("mcmd::Solid3dGetOppositeEdge response was not as expected: {:?}", resp),
|
|
||||||
source_ranges: vec![args.source_range],
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
Ok(opposite_edge.edge)
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the next adjacent edge to the edge given.
|
|
||||||
pub async fn get_next_adjacent_edge(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
|
||||||
let tag: TagIdentifier = args.get_data()?;
|
|
||||||
|
|
||||||
let edge = inner_get_next_adjacent_edge(tag, exec_state, args.clone()).await?;
|
|
||||||
Ok(KclValue::Uuid {
|
|
||||||
value: edge,
|
|
||||||
meta: vec![args.source_range.into()],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the next adjacent edge to the edge given.
|
|
||||||
///
|
|
||||||
/// ```no_run
|
|
||||||
/// exampleSketch = startSketchOn('XZ')
|
|
||||||
/// |> startProfileAt([0, 0], %)
|
|
||||||
/// |> line(end = [10, 0])
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 60,
|
|
||||||
/// length = 10,
|
|
||||||
/// )
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 120,
|
|
||||||
/// length = 10,
|
|
||||||
/// )
|
|
||||||
/// |> line(end = [-10, 0])
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 240,
|
|
||||||
/// length = 10,
|
|
||||||
/// tag = $referenceEdge,
|
|
||||||
/// )
|
|
||||||
/// |> close()
|
|
||||||
///
|
|
||||||
/// example = extrude(exampleSketch, length = 5)
|
|
||||||
/// |> fillet(
|
|
||||||
/// radius = 3,
|
|
||||||
/// tags = [getNextAdjacentEdge(referenceEdge)],
|
|
||||||
/// )
|
|
||||||
/// ```
|
|
||||||
#[stdlib {
|
|
||||||
name = "getNextAdjacentEdge",
|
|
||||||
}]
|
|
||||||
async fn inner_get_next_adjacent_edge(
|
|
||||||
tag: TagIdentifier,
|
|
||||||
exec_state: &mut ExecState,
|
|
||||||
args: Args,
|
|
||||||
) -> Result<Uuid, KclError> {
|
|
||||||
if args.ctx.no_engine_commands().await {
|
|
||||||
return Ok(exec_state.next_uuid());
|
|
||||||
}
|
|
||||||
let face_id = args.get_adjacent_face_to_tag(exec_state, &tag, false).await?;
|
|
||||||
|
|
||||||
let id = exec_state.next_uuid();
|
|
||||||
let tagged_path = args.get_tag_engine_info(exec_state, &tag)?;
|
|
||||||
|
|
||||||
let resp = args
|
|
||||||
.send_modeling_cmd(
|
|
||||||
id,
|
|
||||||
ModelingCmd::from(mcmd::Solid3dGetNextAdjacentEdge {
|
|
||||||
edge_id: tagged_path.id,
|
|
||||||
object_id: tagged_path.sketch,
|
|
||||||
face_id,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
|
|
||||||
let OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: OkModelingCmdResponse::Solid3dGetNextAdjacentEdge(adjacent_edge),
|
|
||||||
} = &resp
|
|
||||||
else {
|
|
||||||
return Err(KclError::Engine(KclErrorDetails {
|
|
||||||
message: format!(
|
|
||||||
"mcmd::Solid3dGetNextAdjacentEdge response was not as expected: {:?}",
|
|
||||||
resp
|
|
||||||
),
|
|
||||||
source_ranges: vec![args.source_range],
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
adjacent_edge.edge.ok_or_else(|| {
|
|
||||||
KclError::Type(KclErrorDetails {
|
|
||||||
message: format!("No edge found next adjacent to tag: `{}`", tag.value),
|
|
||||||
source_ranges: vec![args.source_range],
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the previous adjacent edge to the edge given.
|
|
||||||
pub async fn get_previous_adjacent_edge(exec_state: &mut ExecState, args: Args) -> Result<KclValue, KclError> {
|
|
||||||
let tag: TagIdentifier = args.get_data()?;
|
|
||||||
|
|
||||||
let edge = inner_get_previous_adjacent_edge(tag, exec_state, args.clone()).await?;
|
|
||||||
Ok(KclValue::Uuid {
|
|
||||||
value: edge,
|
|
||||||
meta: vec![args.source_range.into()],
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Get the previous adjacent edge to the edge given.
|
|
||||||
///
|
|
||||||
/// ```no_run
|
|
||||||
/// exampleSketch = startSketchOn('XZ')
|
|
||||||
/// |> startProfileAt([0, 0], %)
|
|
||||||
/// |> line(end = [10, 0])
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 60,
|
|
||||||
/// length = 10,
|
|
||||||
/// )
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 120,
|
|
||||||
/// length = 10,
|
|
||||||
/// )
|
|
||||||
/// |> line(end = [-10, 0])
|
|
||||||
/// |> angledLine(
|
|
||||||
/// angle = 240,
|
|
||||||
/// length = 10,
|
|
||||||
/// tag = $referenceEdge,
|
|
||||||
/// )
|
|
||||||
/// |> close()
|
|
||||||
///
|
|
||||||
/// example = extrude(exampleSketch, length = 5)
|
|
||||||
/// |> fillet(
|
|
||||||
/// radius = 3,
|
|
||||||
/// tags = [getPreviousAdjacentEdge(referenceEdge)],
|
|
||||||
/// )
|
|
||||||
/// ```
|
|
||||||
#[stdlib {
|
|
||||||
name = "getPreviousAdjacentEdge",
|
|
||||||
}]
|
|
||||||
async fn inner_get_previous_adjacent_edge(
|
|
||||||
tag: TagIdentifier,
|
|
||||||
exec_state: &mut ExecState,
|
|
||||||
args: Args,
|
|
||||||
) -> Result<Uuid, KclError> {
|
|
||||||
if args.ctx.no_engine_commands().await {
|
|
||||||
return Ok(exec_state.next_uuid());
|
|
||||||
}
|
|
||||||
let face_id = args.get_adjacent_face_to_tag(exec_state, &tag, false).await?;
|
|
||||||
|
|
||||||
let id = exec_state.next_uuid();
|
|
||||||
let tagged_path = args.get_tag_engine_info(exec_state, &tag)?;
|
|
||||||
|
|
||||||
let resp = args
|
|
||||||
.send_modeling_cmd(
|
|
||||||
id,
|
|
||||||
ModelingCmd::from(mcmd::Solid3dGetPrevAdjacentEdge {
|
|
||||||
edge_id: tagged_path.id,
|
|
||||||
object_id: tagged_path.sketch,
|
|
||||||
face_id,
|
|
||||||
}),
|
|
||||||
)
|
|
||||||
.await?;
|
|
||||||
let OkWebSocketResponseData::Modeling {
|
|
||||||
modeling_response: OkModelingCmdResponse::Solid3dGetPrevAdjacentEdge(adjacent_edge),
|
|
||||||
} = &resp
|
|
||||||
else {
|
|
||||||
return Err(KclError::Engine(KclErrorDetails {
|
|
||||||
message: format!(
|
|
||||||
"mcmd::Solid3dGetPrevAdjacentEdge response was not as expected: {:?}",
|
|
||||||
resp
|
|
||||||
),
|
|
||||||
source_ranges: vec![args.source_range],
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
|
|
||||||
adjacent_edge.edge.ok_or_else(|| {
|
|
||||||
KclError::Type(KclErrorDetails {
|
|
||||||
message: format!("No edge found previous adjacent to tag: `{}`", tag.value),
|
|
||||||
source_ranges: vec![args.source_range],
|
|
||||||
})
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn default_tolerance(units: &UnitLength) -> f64 {
|
|
||||||
match units {
|
|
||||||
UnitLength::Mm => 0.0000001,
|
|
||||||
UnitLength::Cm => 0.0000001,
|
|
||||||
UnitLength::In => 0.0000001,
|
|
||||||
UnitLength::Ft => 0.0001,
|
|
||||||
UnitLength::Yd => 0.001,
|
|
||||||
UnitLength::M => 0.001,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|||||||
@ -236,39 +236,39 @@ const commonConstraintInfoHelper = (
|
|||||||
const pathToFirstArg: PathToNode = isArr
|
const pathToFirstArg: PathToNode = isArr
|
||||||
? [...pathToArrayExpression, [0, 'index']]
|
? [...pathToArrayExpression, [0, 'index']]
|
||||||
: [
|
: [
|
||||||
...pathToArrayExpression,
|
...pathToArrayExpression,
|
||||||
[
|
[
|
||||||
firstArg.properties.findIndex(
|
firstArg.properties.findIndex(
|
||||||
(a) => a.key.name === abbreviatedInputs[0].objInput
|
(a) => a.key.name === abbreviatedInputs[0].objInput
|
||||||
),
|
),
|
||||||
'index',
|
'index',
|
||||||
],
|
],
|
||||||
['value', 'Property'],
|
['value', 'Property'],
|
||||||
]
|
]
|
||||||
|
|
||||||
const pathToSecondArg: PathToNode = isArr
|
const pathToSecondArg: PathToNode = isArr
|
||||||
? [...pathToArrayExpression, [1, 'index']]
|
? [...pathToArrayExpression, [1, 'index']]
|
||||||
: [
|
: [
|
||||||
...pathToArrayExpression,
|
...pathToArrayExpression,
|
||||||
[
|
[
|
||||||
firstArg.properties.findIndex(
|
firstArg.properties.findIndex(
|
||||||
(a) => a.key.name === abbreviatedInputs[1].objInput
|
(a) => a.key.name === abbreviatedInputs[1].objInput
|
||||||
),
|
),
|
||||||
'index',
|
'index',
|
||||||
],
|
],
|
||||||
['value', 'Property'],
|
['value', 'Property'],
|
||||||
]
|
]
|
||||||
|
|
||||||
const input1 = isArr
|
const input1 = isArr
|
||||||
? firstArg.elements[0]
|
? firstArg.elements[0]
|
||||||
: firstArg.properties.find(
|
: firstArg.properties.find(
|
||||||
(a) => a.key.name === abbreviatedInputs[0].objInput
|
(a) => a.key.name === abbreviatedInputs[0].objInput
|
||||||
)?.value
|
)?.value
|
||||||
const input2 = isArr
|
const input2 = isArr
|
||||||
? firstArg.elements[1]
|
? firstArg.elements[1]
|
||||||
: firstArg.properties.find(
|
: firstArg.properties.find(
|
||||||
(a) => a.key.name === abbreviatedInputs[1].objInput
|
(a) => a.key.name === abbreviatedInputs[1].objInput
|
||||||
)?.value
|
)?.value
|
||||||
|
|
||||||
const constraints: ConstrainInfo[] = []
|
const constraints: ConstrainInfo[] = []
|
||||||
if (input1)
|
if (input1)
|
||||||
@ -2759,7 +2759,7 @@ export const angledLineThatIntersects: SketchLineHelper = {
|
|||||||
const intersectTag =
|
const intersectTag =
|
||||||
firstArg.type === 'ObjectExpression'
|
firstArg.type === 'ObjectExpression'
|
||||||
? firstArg.properties.find((p) => p.key.name === 'intersectTag')
|
? firstArg.properties.find((p) => p.key.name === 'intersectTag')
|
||||||
?.value || createLiteral('')
|
?.value || createLiteral('')
|
||||||
: createLiteral('')
|
: createLiteral('')
|
||||||
const intersectTagName =
|
const intersectTagName =
|
||||||
intersectTag.type === 'Name' ? intersectTag.name.name : ''
|
intersectTag.type === 'Name' ? intersectTag.name.name : ''
|
||||||
@ -2954,13 +2954,13 @@ export function changeSketchArguments(
|
|||||||
variables: VariableMap,
|
variables: VariableMap,
|
||||||
sourceRangeOrPath:
|
sourceRangeOrPath:
|
||||||
| {
|
| {
|
||||||
type: 'sourceRange'
|
type: 'sourceRange'
|
||||||
sourceRange: SourceRange
|
sourceRange: SourceRange
|
||||||
}
|
}
|
||||||
| {
|
| {
|
||||||
type: 'path'
|
type: 'path'
|
||||||
pathToNode: PathToNode
|
pathToNode: PathToNode
|
||||||
},
|
},
|
||||||
input: SegmentInputs
|
input: SegmentInputs
|
||||||
): { modifiedAst: Node<Program>; pathToNode: PathToNode } | Error {
|
): { modifiedAst: Node<Program>; pathToNode: PathToNode } | Error {
|
||||||
// TODO/less-than-ideal, this obvious relies on node getting mutated, as changing the following with `_node = structuredClone(node)` breaks the draft line animation.
|
// TODO/less-than-ideal, this obvious relies on node getting mutated, as changing the following with `_node = structuredClone(node)` breaks the draft line animation.
|
||||||
@ -3183,9 +3183,9 @@ export function addNewSketchLn({
|
|||||||
spliceBetween = false,
|
spliceBetween = false,
|
||||||
}: CreateLineFnCallArgs):
|
}: CreateLineFnCallArgs):
|
||||||
| {
|
| {
|
||||||
modifiedAst: Node<Program>
|
modifiedAst: Node<Program>
|
||||||
pathToNode: PathToNode
|
pathToNode: PathToNode
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
const node = structuredClone(_node)
|
const node = structuredClone(_node)
|
||||||
const { add, updateArgs } =
|
const { add, updateArgs } =
|
||||||
@ -3280,10 +3280,10 @@ export function replaceSketchLine({
|
|||||||
referencedSegment?: Path
|
referencedSegment?: Path
|
||||||
}):
|
}):
|
||||||
| {
|
| {
|
||||||
modifiedAst: Node<Program>
|
modifiedAst: Node<Program>
|
||||||
valueUsedInTransform?: number
|
valueUsedInTransform?: number
|
||||||
pathToNode: PathToNode
|
pathToNode: PathToNode
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
if (![...toolTips, 'intersect', 'circle'].includes(fnName)) {
|
if (![...toolTips, 'intersect', 'circle'].includes(fnName)) {
|
||||||
return new Error(`The following function name is not tooltip: ${fnName}`)
|
return new Error(`The following function name is not tooltip: ${fnName}`)
|
||||||
@ -3335,9 +3335,9 @@ function addTagToChamfer(
|
|||||||
edgeCutMeta: EdgeCutInfo
|
edgeCutMeta: EdgeCutInfo
|
||||||
):
|
):
|
||||||
| {
|
| {
|
||||||
modifiedAst: Node<Program>
|
modifiedAst: Node<Program>
|
||||||
tag: string
|
tag: string
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
const _node = structuredClone(tagInfo.node)
|
const _node = structuredClone(tagInfo.node)
|
||||||
let pipeIndex = 0
|
let pipeIndex = 0
|
||||||
@ -3452,9 +3452,9 @@ export function addTagForSketchOnFace(
|
|||||||
edgeCutMeta: EdgeCutInfo | null
|
edgeCutMeta: EdgeCutInfo | null
|
||||||
):
|
):
|
||||||
| {
|
| {
|
||||||
modifiedAst: Node<Program>
|
modifiedAst: Node<Program>
|
||||||
tag: string
|
tag: string
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
if (expressionName === 'close') {
|
if (expressionName === 'close') {
|
||||||
return addTagKw()(tagInfo)
|
return addTagKw()(tagInfo)
|
||||||
@ -3489,35 +3489,8 @@ export function getTagFromCallExpression(
|
|||||||
return new Error(`"${callExp.callee.name.name}" is not a sketch line helper`)
|
return new Error(`"${callExp.callee.name.name}" is not a sketch line helper`)
|
||||||
}
|
}
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
function isAngleLiteral(lineArugement: Expr): boolean {
|
|
||||||
return lineArugement?.type === 'ArrayExpression'
|
|
||||||
? isLiteralArrayOrStatic(lineArugement.elements[0])
|
|
||||||
: lineArugement?.type === 'ObjectExpression'
|
|
||||||
? isLiteralArrayOrStatic(
|
|
||||||
lineArugement.properties.find(({ key }) => key.name === 'angle')
|
|
||||||
?.value
|
|
||||||
)
|
|
||||||
: false
|
|
||||||
||||||| parent of 27a8a2a50 (Start changing JS codemods)
|
|
||||||
function isAngleLiteral(lineArugement: Expr): boolean {
|
|
||||||
return lineArugement?.type === 'ArrayExpression'
|
|
||||||
? isLiteralArrayOrStatic(lineArugement.elements[0])
|
|
||||||
: lineArugement?.type === 'ObjectExpression'
|
|
||||||
? isLiteralArrayOrStatic(
|
|
||||||
lineArugement.properties.find(({ key }) => key.name === 'angle')?.value
|
|
||||||
)
|
|
||||||
: false
|
|
||||||
=======
|
|
||||||
function isAngleLiteral(lineArgument: Expr): boolean {
|
function isAngleLiteral(lineArgument: Expr): boolean {
|
||||||
return lineArgument?.type === 'ArrayExpression'
|
return isLiteralArrayOrStatic(lineArgument)
|
||||||
? isLiteralArrayOrStatic(lineArgument.elements[0])
|
|
||||||
: lineArgument?.type === 'ObjectExpression'
|
|
||||||
? isLiteralArrayOrStatic(
|
|
||||||
lineArgument.properties.find(({ key }) => key.name === 'angle')?.value
|
|
||||||
)
|
|
||||||
: lineArgument?.type === 'Literal'
|
|
||||||
>>>>>>> 27a8a2a50 (Start changing JS codemods)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type addTagFn = (
|
type addTagFn = (
|
||||||
@ -3578,14 +3551,14 @@ function addTagKw(): addTagFn {
|
|||||||
callExpr.node.type === 'CallExpressionKw'
|
callExpr.node.type === 'CallExpressionKw'
|
||||||
? callExpr.node
|
? callExpr.node
|
||||||
: {
|
: {
|
||||||
type: 'CallExpressionKw',
|
type: 'CallExpressionKw',
|
||||||
callee: callExpr.node.callee,
|
callee: callExpr.node.callee,
|
||||||
unlabeled: callExpr.node.arguments.length
|
unlabeled: callExpr.node.arguments.length
|
||||||
? callExpr.node.arguments[0]
|
? callExpr.node.arguments[0]
|
||||||
: null,
|
: null,
|
||||||
nonCodeMeta: nonCodeMetaEmpty(),
|
nonCodeMeta: nonCodeMetaEmpty(),
|
||||||
arguments: [],
|
arguments: [],
|
||||||
}
|
}
|
||||||
const tagArg = findKwArg(ARG_TAG, primaryCallExp)
|
const tagArg = findKwArg(ARG_TAG, primaryCallExp)
|
||||||
const tagDeclarator =
|
const tagDeclarator =
|
||||||
tagArg || createTagDeclarator(findUniqueName(_node, 'seg', 2))
|
tagArg || createTagDeclarator(findUniqueName(_node, 'seg', 2))
|
||||||
@ -3642,9 +3615,9 @@ export function getXComponent(
|
|||||||
|
|
||||||
function getFirstArgValuesForXYFns(callExpression: CallExpression):
|
function getFirstArgValuesForXYFns(callExpression: CallExpression):
|
||||||
| {
|
| {
|
||||||
val: [Expr, Expr]
|
val: [Expr, Expr]
|
||||||
tag?: Expr
|
tag?: Expr
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
// used for lineTo, line
|
// used for lineTo, line
|
||||||
const firstArg = callExpression.arguments[0]
|
const firstArg = callExpression.arguments[0]
|
||||||
@ -3653,9 +3626,9 @@ function getFirstArgValuesForXYFns(callExpression: CallExpression):
|
|||||||
|
|
||||||
function getValuesForXYFns(arg: Expr):
|
function getValuesForXYFns(arg: Expr):
|
||||||
| {
|
| {
|
||||||
val: [Expr, Expr]
|
val: [Expr, Expr]
|
||||||
tag?: Expr
|
tag?: Expr
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
if (arg.type === 'ArrayExpression') {
|
if (arg.type === 'ArrayExpression') {
|
||||||
return { val: [arg.elements[0], arg.elements[1]] }
|
return { val: [arg.elements[0], arg.elements[1]] }
|
||||||
@ -3673,9 +3646,9 @@ function getValuesForXYFns(arg: Expr):
|
|||||||
|
|
||||||
function getFirstArgValuesForAngleFns(callExpression: CallExpression):
|
function getFirstArgValuesForAngleFns(callExpression: CallExpression):
|
||||||
| {
|
| {
|
||||||
val: [Expr, Expr]
|
val: [Expr, Expr]
|
||||||
tag?: Expr
|
tag?: Expr
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
// used for angledLine, angledLineOfXLength, angledLineToX, angledLineOfYLength, angledLineToY
|
// used for angledLine, angledLineOfXLength, angledLineToX, angledLineOfYLength, angledLineToY
|
||||||
const firstArg = callExpression.arguments[0]
|
const firstArg = callExpression.arguments[0]
|
||||||
@ -3758,9 +3731,9 @@ export const getCircle = (
|
|||||||
callExp: CallExpressionKw
|
callExp: CallExpressionKw
|
||||||
):
|
):
|
||||||
| {
|
| {
|
||||||
val: [Expr, Expr, Expr]
|
val: [Expr, Expr, Expr]
|
||||||
tag?: Expr
|
tag?: Expr
|
||||||
}
|
}
|
||||||
| Error => {
|
| Error => {
|
||||||
const firstArg = callExp.arguments[0]
|
const firstArg = callExp.arguments[0]
|
||||||
if (firstArg.type === 'LabeledArg') {
|
if (firstArg.type === 'LabeledArg') {
|
||||||
@ -3787,9 +3760,9 @@ const getAngledLineThatIntersects = (
|
|||||||
callExp: CallExpression
|
callExp: CallExpression
|
||||||
):
|
):
|
||||||
| {
|
| {
|
||||||
val: [Expr, Expr, Expr]
|
val: [Expr, Expr, Expr]
|
||||||
tag?: Expr
|
tag?: Expr
|
||||||
}
|
}
|
||||||
| Error => {
|
| Error => {
|
||||||
const firstArg = callExp.arguments[0]
|
const firstArg = callExp.arguments[0]
|
||||||
if (firstArg.type === 'ObjectExpression') {
|
if (firstArg.type === 'ObjectExpression') {
|
||||||
@ -3853,9 +3826,9 @@ Also known as the 'determining' arg.
|
|||||||
*/
|
*/
|
||||||
export function getArgForEnd(lineCall: CallExpressionKw):
|
export function getArgForEnd(lineCall: CallExpressionKw):
|
||||||
| {
|
| {
|
||||||
val: Expr | [Expr, Expr] | [Expr, Expr, Expr]
|
val: Expr | [Expr, Expr] | [Expr, Expr, Expr]
|
||||||
tag?: Expr
|
tag?: Expr
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
const name = lineCall?.callee?.name.name
|
const name = lineCall?.callee?.name.name
|
||||||
|
|
||||||
@ -3909,9 +3882,9 @@ export function getArgForEnd(lineCall: CallExpressionKw):
|
|||||||
|
|
||||||
export function getFirstArg(callExp: CallExpression):
|
export function getFirstArg(callExp: CallExpression):
|
||||||
| {
|
| {
|
||||||
val: Expr | [Expr, Expr] | [Expr, Expr, Expr]
|
val: Expr | [Expr, Expr] | [Expr, Expr, Expr]
|
||||||
tag?: Expr
|
tag?: Expr
|
||||||
}
|
}
|
||||||
| Error {
|
| Error {
|
||||||
const name = callExp?.callee?.name.name
|
const name = callExp?.callee?.name.name
|
||||||
if (
|
if (
|
||||||
|
|||||||
Reference in New Issue
Block a user