Fix adding constraint from UI to work
This commit is contained in:
		| @ -3877,29 +3877,24 @@ export const getCircle = ( | ||||
|   return new Error('expected the arguments to be for a circle') | ||||
| } | ||||
|  | ||||
| const getAngledLineThatIntersects = ( | ||||
|   callExp: CallExpression | ||||
| export const getAngledLineThatIntersects = ( | ||||
|   callExp: CallExpressionKw | ||||
| ): | ||||
|   | { | ||||
|       val: [Expr, Expr, Expr] | ||||
|       tag?: Expr | ||||
|     } | ||||
|   | Error => { | ||||
|   const firstArg = callExp.arguments[0] | ||||
|   if (firstArg.type === 'ObjectExpression') { | ||||
|     const tag = firstArg.properties.find((p) => p.key.name === 'tag')?.value | ||||
|     const angle = firstArg.properties.find((p) => p.key.name === 'angle')?.value | ||||
|     const offset = firstArg.properties.find( | ||||
|       (p) => p.key.name === 'offset' | ||||
|     )?.value | ||||
|     const intersectTag = firstArg.properties.find( | ||||
|       (p) => p.key.name === 'intersectTag' | ||||
|     )?.value | ||||
|     if (angle && offset && intersectTag) { | ||||
|       return { val: [angle, offset, intersectTag], tag } | ||||
|     } | ||||
|   const angle = findKwArg(ARG_ANGLE, callExp) | ||||
|   const intersectTag = findKwArg(ARG_INTERSECT_TAG, callExp) | ||||
|   const offset = findKwArg(ARG_OFFSET, callExp) | ||||
|   if (!angle || !intersectTag || !offset) { | ||||
|     return new Error( | ||||
|       `angledLineThatIntersects call needs angle, intersectTag, and offset args` | ||||
|     ) | ||||
|   } | ||||
|   return new Error('expected ArrayExpression or ObjectExpression') | ||||
|   const tag = findKwArg(ARG_TAG, callExp) | ||||
|   return { val: [angle, intersectTag, offset], tag } | ||||
| } | ||||
|  | ||||
| /** | ||||
| @ -3965,6 +3960,8 @@ export function getArgForEnd(lineCall: CallExpressionKw): | ||||
|       } | ||||
|       return getValuesForXYFns(arg) | ||||
|     } | ||||
|     case 'angledLineThatIntersects': | ||||
|       return getAngledLineThatIntersects(lineCall) | ||||
|     case 'yLine': | ||||
|     case 'xLine': { | ||||
|       const arg = findKwArgAny(DETERMINING_ARGS, lineCall) | ||||
| @ -4024,9 +4021,6 @@ export function getFirstArg(callExp: CallExpression): | ||||
|   if (['xLine', 'yLine', 'xLineTo', 'yLineTo'].includes(name)) { | ||||
|     return getFirstArgValuesForXYLineFns(callExp) | ||||
|   } | ||||
|   if (['angledLineThatIntersects'].includes(name)) { | ||||
|     return getAngledLineThatIntersects(callExp) | ||||
|   } | ||||
|   if (['tangentialArc'].includes(name)) { | ||||
|     // TODO probably needs it's own implementation | ||||
|     return getFirstArgValuesForXYFns(callExp) | ||||
|  | ||||
| @ -7,9 +7,11 @@ import { | ||||
|   ARG_END_ABSOLUTE, | ||||
|   ARG_END_ABSOLUTE_X, | ||||
|   ARG_END_ABSOLUTE_Y, | ||||
|   ARG_INTERSECT_TAG, | ||||
|   ARG_LENGTH, | ||||
|   ARG_LENGTH_X, | ||||
|   ARG_LENGTH_Y, | ||||
|   ARG_OFFSET, | ||||
|   ARG_TAG, | ||||
|   DETERMINING_ARGS, | ||||
| } from '@src/lang/constants' | ||||
| @ -36,6 +38,7 @@ import { | ||||
|   createFirstArg, | ||||
|   fnNameToTooltip, | ||||
|   getAngledLine, | ||||
|   getAngledLineThatIntersects, | ||||
|   getArgForEnd, | ||||
|   getCircle, | ||||
|   getConstraintInfo, | ||||
| @ -345,20 +348,16 @@ function intersectCallWrapper({ | ||||
|   tag?: Expr | ||||
|   valueUsedInTransform?: number | ||||
| }): CreatedSketchExprResult { | ||||
|   const firstArg: any = { | ||||
|     angle: angleVal, | ||||
|     offset: offsetVal, | ||||
|     intersectTag, | ||||
|   } | ||||
|   const args: Expr[] = [ | ||||
|     createObjectExpression(firstArg), | ||||
|     createPipeSubstitution(), | ||||
|   const args: LabeledArg[] = [ | ||||
|     createLabeledArg(ARG_ANGLE, angleVal), | ||||
|     createLabeledArg(ARG_OFFSET, offsetVal), | ||||
|     createLabeledArg(ARG_INTERSECT_TAG, intersectTag), | ||||
|   ] | ||||
|   if (tag) { | ||||
|     args.push(tag) | ||||
|     args.push(createLabeledArg(ARG_TAG, tag)) | ||||
|   } | ||||
|   return { | ||||
|     callExp: createCallExpression(fnName, args), | ||||
|     callExp: createCallExpressionStdLibKw(fnName, null, args), | ||||
|     valueUsedInTransform, | ||||
|   } | ||||
| } | ||||
| @ -2335,6 +2334,9 @@ export function getConstraintLevelFromSourceRange( | ||||
|           ) { | ||||
|             return getAngledLine(nodeMeta.node) | ||||
|           } | ||||
|           if (name === 'angledLineThatIntersects') { | ||||
|             return getAngledLineThatIntersects(nodeMeta.node) | ||||
|           } | ||||
|           const arg = findKwArgAny(DETERMINING_ARGS, nodeMeta.node) | ||||
|           if (arg === undefined) { | ||||
|             const argStr = nodeMeta.node.arguments.map((a) => a.label.name) | ||||
|  | ||||
		Reference in New Issue
	
	Block a user