Add CadQuery customizer #547
@@ -2,7 +2,7 @@ FROM public.ecr.aws/lts/ubuntu:20.04_stable
|
||||
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
RUN apt-get update -qq
|
||||
RUN apt-get update --fix-missing -qq
|
||||
RUN apt-get -y -qq install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates xvfb
|
||||
RUN apt-get update -qq
|
||||
RUN apt-get install -y wget
|
||||
@@ -38,9 +38,9 @@ RUN npm install aws-lambda-ric@1.0.0
|
||||
|
||||
# Get the distribution copy of cq-cli
|
||||
RUN apt-get install -y libglew2.1
|
||||
RUN wget https://github.com/CadQuery/cq-cli/releases/download/v2.2-beta.2/cq-cli-Linux-x86_64.zip
|
||||
# Comment the entry above out and uncomment the one below to revert to the stable release
|
||||
# RUN wget https://github.com/CadQuery/cq-cli/releases/download/v2.1.0/cq-cli-Linux-x86_64.zip
|
||||
# RUN wget https://github.com/CadQuery/cq-cli/releases/download/v2.2-beta.2/cq-cli-Linux-x86_64.zip
|
||||
# More cutting edge release
|
||||
RUN wget http://7bindustries.com/static/downloads/cq-cli-Linux-x86_64.zip
|
||||
RUN unzip cq-cli-Linux-x86_64.zip
|
||||
|
||||
RUN chmod +x cq-cli/cq-cli
|
||||
|
||||
@@ -11,21 +11,34 @@ export const runCQ = async ({
|
||||
)
|
||||
const fullPath = `/tmp/${tempFile}/output.gz`
|
||||
const stlPath = `/tmp/${tempFile}/output.stl`
|
||||
const customizerPath = `/tmp/${tempFile}/customizer.param`
|
||||
const command = [
|
||||
`cq-cli/cq-cli`,
|
||||
`--codec stl`,
|
||||
`--infile /tmp/${tempFile}/main.py`,
|
||||
`--outfile ${stlPath}`,
|
||||
`--outputopts "deflection:${deflection};angularDeflection:${deflection};"`,
|
||||
`--params ${customizerPath}`,
|
||||
].join(' ')
|
||||
const command2 = [
|
||||
`cq-cli/cq-cli`,
|
||||
`--getparams true`,
|
||||
`--infile /tmp/${tempFile}/main.py`,
|
||||
`--outfile ${customizerPath}`,
|
||||
]
|
||||
console.log('command', command)
|
||||
let consoleMessage = ''
|
||||
try {
|
||||
consoleMessage = await runCommand(command, 30000)
|
||||
consoleMessage2 = await runCommand(command2, 30000)
|
||||
const params = JSON.parse(
|
||||
await readFile(customizerPath, { encoding: 'ascii'})
|
||||
).parameters
|
||||
await writeFiles(
|
||||
[
|
||||
{
|
||||
file: JSON.stringify({
|
||||
customizerParams: params,
|
||||
consoleMessage,
|
||||
type: 'stl',
|
||||
}),
|
||||
|
||||
@@ -3,7 +3,7 @@ FROM public.ecr.aws/lts/ubuntu:20.04_stable
|
||||
ARG DEBIAN_FRONTEND=noninteractive
|
||||
|
||||
## install things needed to run openscad (xvfb is an important one)
|
||||
RUN apt-get update -qq
|
||||
RUN apt-get update --fix-missing -qq
|
||||
# double check this below, I'm not sure we need inkscape etc
|
||||
RUN apt-get -y -qq install software-properties-common dirmngr apt-transport-https lsb-release ca-certificates xvfb imagemagick unzip inkscape
|
||||
RUN apt-get install -y curl wget
|
||||
|
||||
@@ -43,12 +43,13 @@ export const render: DefaultKernelExport['render'] = async ({
|
||||
}
|
||||
const blob = await response.blob()
|
||||
const text = await new Response(blob).text()
|
||||
const { consoleMessage } = splitGziped(text)
|
||||
const { consoleMessage, customizerParams, type } = splitGziped(text)
|
||||
return createHealthyResponse({
|
||||
type: 'geometry',
|
||||
data: await stlToGeometry(window.URL.createObjectURL(blob)),
|
||||
consoleMessage,
|
||||
date: new Date(),
|
||||
customizerParams: customizerParams,
|
||||
})
|
||||
} catch (e) {
|
||||
return createUnhealthyResponse(new Date())
|
||||
|
||||
Reference in New Issue
Block a user