sketch on chamfer start

This commit is contained in:
Kurt Hutten Irev-Dev
2024-09-19 16:37:35 +10:00
parent 9f22882c68
commit a84f53e2ed
4 changed files with 72 additions and 4 deletions

View File

@ -11,6 +11,7 @@ import {
getCapCodeRef, getCapCodeRef,
getSweepEdgeCodeRef, getSweepEdgeCodeRef,
getSweepFromSuspectedSweepSurface, getSweepFromSuspectedSweepSurface,
getEdgeCuteConsumedCodeRef,
getSolid2dCodeRef, getSolid2dCodeRef,
getWallCodeRef, getWallCodeRef,
} from 'lang/std/artifactGraph' } from 'lang/std/artifactGraph'
@ -72,6 +73,17 @@ export function useEngineConnectionSubscriptions() {
editorManager.setHighlightRange([ editorManager.setHighlightRange([
artifact?.codeRef?.range || [0, 0], artifact?.codeRef?.range || [0, 0],
]) ])
} else if (artifact?.type === 'edgeCut') {
const codeRef = artifact.codeRef
const consumedCodeRef = getEdgeCuteConsumedCodeRef(
artifact,
engineCommandManager.artifactGraph
)
editorManager.setHighlightRange(
err(consumedCodeRef)
? [codeRef.range]
: [codeRef.range, consumedCodeRef.range]
)
} else { } else {
editorManager.setHighlightRange([[0, 0]]) editorManager.setHighlightRange([[0, 0]])
} }
@ -177,12 +189,21 @@ export function useEngineConnectionSubscriptions() {
engineCommandManager.artifactGraph engineCommandManager.artifactGraph
) )
if (artifact?.type !== 'cap' && artifact?.type !== 'wall') return if (
artifact?.type !== 'cap' &&
artifact?.type !== 'wall' &&
!(
artifact?.type === 'edgeCut' && artifact.subType === 'chamfer'
)
)
return
const codeRef = const codeRef =
artifact.type === 'cap' artifact.type === 'cap'
? getCapCodeRef(artifact, engineCommandManager.artifactGraph) ? getCapCodeRef(artifact, engineCommandManager.artifactGraph)
: getWallCodeRef(artifact, engineCommandManager.artifactGraph) : artifact.type === 'wall'
? getWallCodeRef(artifact, engineCommandManager.artifactGraph)
: artifact.codeRef
const faceInfo = await getFaceDetails(faceId) const faceInfo = await getFaceDetails(faceId)
if (!faceInfo?.origin || !faceInfo?.z_axis || !faceInfo?.y_axis) if (!faceInfo?.origin || !faceInfo?.z_axis || !faceInfo?.y_axis)

View File

@ -724,18 +724,52 @@ export function getSweepEdgeCodeRef(
if (err(seg)) return seg if (err(seg)) return seg
return seg.codeRef return seg.codeRef
} }
export function getEdgeCuteConsumedCodeRef(
edge: EdgeCut,
artifactGraph: ArtifactGraph
): CommonCommandProperties | Error {
const seg = getArtifactOfTypes(
{ key: edge.consumedEdgeId, types: ['segment', 'sweepEdge'] },
artifactGraph
)
if (err(seg)) return seg
if (seg.type === 'segment') return seg.codeRef
return getSweepEdgeCodeRef(seg, artifactGraph)
}
export function getSweepFromSuspectedSweepSurface( export function getSweepFromSuspectedSweepSurface(
id: ArtifactId, id: ArtifactId,
artifactGraph: ArtifactGraph artifactGraph: ArtifactGraph
): SweepArtifact | Error { ): SweepArtifact | Error {
const artifact = getArtifactOfTypes( const artifact = getArtifactOfTypes(
{ key: id, types: ['wall', 'cap'] }, { key: id, types: ['wall', 'cap', 'edgeCut'] },
artifactGraph artifactGraph
) )
if (err(artifact)) return artifact if (err(artifact)) return artifact
if (artifact.type === 'wall' || artifact.type === 'cap') {
return getArtifactOfTypes(
{ key: artifact.sweepId, types: ['sweep'] },
artifactGraph
)
}
const segOrEdge = getArtifactOfTypes(
{ key: artifact.consumedEdgeId, types: ['segment', 'sweepEdge'] },
artifactGraph
)
if (err(segOrEdge)) return segOrEdge
if (segOrEdge.type === 'segment') {
const path = getArtifactOfTypes(
{ key: segOrEdge.pathId, types: ['path'] },
artifactGraph
)
if (err(path)) return path
return getArtifactOfTypes(
{ key: path.sweepId, types: ['sweep'] },
artifactGraph
)
}
return getArtifactOfTypes( return getArtifactOfTypes(
{ key: artifact.sweepId, types: ['sweep'] }, { key: segOrEdge.sweepId, types: ['sweep'] },
artifactGraph artifactGraph
) )
} }

View File

@ -1902,6 +1902,11 @@ export function addTagForSketchOnFace(
if (expressionName === 'close') { if (expressionName === 'close') {
return addTag(1)(tagInfo) return addTag(1)(tagInfo)
} }
if (expressionName === 'chamfer') {
// TODO: if there are two (or more) tags on the chamfer, it needs to pull out
// the relevant tag and put it into a separate chamfer call
return addTag(2)(tagInfo)
}
if (expressionName in sketchLineHelperMap) { if (expressionName in sketchLineHelperMap) {
const { addTag } = sketchLineHelperMap[expressionName] const { addTag } = sketchLineHelperMap[expressionName]
return addTag(tagInfo) return addTag(tagInfo)

View File

@ -164,6 +164,14 @@ export async function getEventForSelectWithPoint({
}, },
} }
} }
if (_artifact.type === 'edgeCut')
return {
type: 'Set selection',
data: {
selectionType: 'singleCodeCursor',
selection: { range: _artifact.codeRef.range, type: 'default' },
},
}
return null return null
} }