getSketchSegmentIndexFromSourceRange bug fix (#75)

* getSketchSegmentIndexFromSourceRange bug fix

* test was verbose

* rename function
This commit is contained in:
Kurt Hutten
2023-03-20 07:09:19 +11:00
committed by GitHub
parent 1ac3713a79
commit 37ebfd072c
4 changed files with 49 additions and 10 deletions

View File

@ -24,7 +24,7 @@ import {
} from '../modifyAst'
import { createFirstArg, getFirstArg, replaceSketchLine } from './sketch'
import { ProgramMemory } from '../executor'
import { getSketchSegmentIndexFromSourceRange } from './sketchConstraints'
import { getSketchSegmentFromSourceRange } from './sketchConstraints'
import { getAngle, roundOff } from '../../lib/utils'
type LineInputsType =
@ -1157,12 +1157,9 @@ export function transformAstSketchLines({
const sketchGroup = programMemory.root?.[varName]
if (!sketchGroup || sketchGroup.type !== 'sketchGroup')
throw new Error('not a sketch group')
const seg = getSketchSegmentIndexFromSourceRange(sketchGroup, range)
const seg = getSketchSegmentFromSourceRange(sketchGroup, range)
const referencedSegment = referencedSegmentRange
? getSketchSegmentIndexFromSourceRange(
sketchGroup,
referencedSegmentRange
)
? getSketchSegmentFromSourceRange(sketchGroup, referencedSegmentRange)
: sketchGroup.value.find((path) => path.name === referenceSegName)
const { to, from } = seg
const { modifiedAst, valueUsedInTransform } = replaceSketchLine({