Add Angle & Length constraint/value, and modal for the details (#54)

* setup UI for getting length and Angle values from user

* enable setLength-angle for angledLines with an exisiting constraining value
This commit is contained in:
Kurt Hutten
2023-03-10 08:48:50 +11:00
committed by GitHub
parent 2bb987b3b5
commit c3ead3b074
8 changed files with 485 additions and 27 deletions

View File

@ -160,12 +160,15 @@ export const lineTo: SketchLineHelper = {
])
const callIndex = getLastIndex(pathToNode)
if (replaceExisting && createCallback) {
const boop = createCallback(newVals, referencedSegment)
pipe.body[callIndex] = boop.callExp
const { callExp, valueUsedInTransform } = createCallback(
newVals,
referencedSegment
)
pipe.body[callIndex] = callExp
return {
modifiedAst: _node,
pathToNode,
valueUsedInTransform: boop.valueUsedInTransform,
valueUsedInTransform: valueUsedInTransform,
}
} else {
pipe.body = [...pipe.body, newLine]
@ -599,16 +602,23 @@ export const angledLine: SketchLineHelper = {
const newAngleVal = createLiteral(roundOff(getAngle(from, to), 0))
const newLengthVal = createLiteral(roundOff(getLength(from, to), 2))
const newLine = createCallback
? createCallback([newAngleVal, newLengthVal]).callExp
: createCallExpression('angledLine', [
createArrayExpression([newAngleVal, newLengthVal]),
createPipeSubstitution(),
])
const newLine = createCallExpression('angledLine', [
createArrayExpression([newAngleVal, newLengthVal]),
createPipeSubstitution(),
])
const callIndex = getLastIndex(pathToNode)
if (replaceExisting) {
pipe.body[callIndex] = newLine
if (replaceExisting && createCallback) {
const { callExp, valueUsedInTransform } = createCallback([
newAngleVal,
newLengthVal,
])
pipe.body[callIndex] = callExp
return {
modifiedAst: _node,
pathToNode,
valueUsedInTransform,
}
} else {
pipe.body = [...pipe.body, newLine]
}