[HN Gopher] Show HN: Replicad, the Library for CAD in the Browser
___________________________________________________________________
Show HN: Replicad, the Library for CAD in the Browser
Author : sgenoud
Score : 83 points
Date : 2023-02-20 12:55 UTC (10 hours ago)
(HTM) web link (replicad.xyz)
(TXT) w3m dump (replicad.xyz)
| flyingcircus3 wrote:
| I've played around with both three.js and babylon.js, in attempts
| to make a CAD system. Where I get in over my head is moving
| objects relative to each other. For example, I need cube A's top
| right front corner to be 10mm left of the midpoint of cube B's
| rear face, left edge. Fusion360 can select any of these edges,
| vertices, etc, and gives you the controls and necessary visual
| feedback, with distance, angles and alignments.
|
| Trying to implement even the simplest version of this has been a
| project killer.
| arbitrandomuser wrote:
| I don't understand why this cannot be done , One just had to
| calculate the vector and displace cube by said amount . I think
| I'm missing something ?
| flyingcircus3 wrote:
| I'm not talking about the user writing code to move an
| object. I'm talking about the user clicking features on 3D
| objects with their mouse (like a specific vertex), having
| those features become highlighted, drawing the visual cues
| that let the user know that they are in "Move" mode, showing
| distances and angles to give the user the necessary feedback,
| clipping to features like midpoints, etc.
|
| Really, the piece that drove me to eventually give up was
| getting a vertex or edge to be selected, rather than the
| whole object. Its not difficult to calculate for simple
| shapes, but what is really needed is a general solution, that
| doesn't depend on shapes being regular polygons.
| virtualritz wrote:
| See also this thread[1] from yesterday which has some interesting
| comments on the limitations projects based on the OpenCascade
| kernel face.
|
| Mentions an interesting video[2] going through the commercial
| geometry kernel options and their resp. limitations from the
| author of [3].
|
| [1] https://news.ycombinator.com/item?id=34856383
|
| [2] https://youtu.be/WvwiH1DOK1M
|
| [3] https://github.com/nkallen/plasticity
| samwillis wrote:
| That was my thread yesterday. While I have reservations about
| OpenCascade for "industry" scale and capable CAD, having
| OpenCascade in the browser is f-ing awesome! This project looks
| incredible, and I'm am going to have to a play with it. Thanks
| @sgenoud!
| rjsw wrote:
| I realize that this will probably be down to the configuration of
| OpenCascade itself, but the STEP file exported from the "Simple
| vase" example is for ISO 10303-214. This standard has been
| withdrawn and applications should use ISO 10303-242 instead.
| sgenoud wrote:
| I will have a look if OpenCascade has a more recent API which
| saves in the up to date standard. How do you check that a file
| follows the latest standard?
| rjsw wrote:
| Look at the header of the saved file, the FILE_SCHEMA element
| will state which application protocol the file conforms to.
| In the example I just saved:
| FILE_SCHEMA(('AUTOMOTIVE_DESIGN { 1 0 10303 214 1 1 1 1 }'));
|
| vs (random file created by Catia v5.6):
| FILE_SCHEMA(('AP242_MANAGED_MODEL_BASED_3D_ENGINEERING_MIM_LF
| {1 0 10303 442 1 1 4}'));
|
| There seems to be AP242 support in OpenCascade.
| turnsout wrote:
| After spending 5 minutes with Replicad, I canceled my
| subscription to Fusion360. Thank you @sgenoud!
|
| Context: I have design and shipped physical products (injection
| mold plastic), but have found the parametric support in Fusion to
| be almost unusable, as it's tied to the order of operations. For
| a recent laser cutting project, I did the CAD in HTML--using JS
| to lay out SVG elements based on input fields for all the
| parameters.
|
| Given the above, Replicad is a 100% fit for my philosophy and
| needs:
|
| * Code-driven, so I can completely control how things are
| parameterized (and use arbitrary expressions)
|
| * Text-based, so I can work in a Git repo
|
| * Open source & web based, so I don't worry that I'll lose the
| ability to view or edit old files in the future
|
| * Well-funded core (OpenCascade), so I have reasonable hope that
| it will continue to receive updates
|
| * Human-friendly documentation, so I can find what I need quickly
|
| Really nice work!
| naasking wrote:
| Was FreeCAD unsuitable in some way? It's been around forever,
| also based on OpenCascade.
| turnsout wrote:
| afaik, FreeCAD is not code-driven or text-based. In the few
| minutes I played with it, it seems like a massive app which
| is sluggish on fast computers, and stores its data in an
| opaque binary format. So it's not really in the same
| category.
| naasking wrote:
| It has an OpenSCAD workbench if you're familiar with that,
| and it has Python embedded and it's used throughout:
|
| https://wiki.freecad.org/Python
| i-use-nixos-btw wrote:
| I currently use OpenSCAD for hobby projects. I'm very much a
| beginner at it, having used it for about 2 weeks, but so far it
| has been a very shallow learning curve.
|
| In terms of an ecosystem it's quite good, but the language
| frustrates me. It is powerful in its own way, but primitive, and
| I really wish that it just became a library that was used within
| an established language.
|
| There are alternatives, but nothing that has really attracted me.
|
| Until now. Good work.
|
| Have you considered reaching out to Thingiverse? They have
| OpenSCAD integration so users can change parameters and download
| the resulting STL files, but this seems like it'd suit their
| ecosystem just as much - if not more.
| frading wrote:
| I'm very glad to discover this. I'll be evaluating shortly if I
| could/should integrate it in my procedural design tool Polygonjs
| ( https://polygonjs.com )
| sgenoud wrote:
| I have been working for a while on this library to do CAD in the
| browser.
|
| The main inspiration were CadQuery and cascade studio. These are
| two great projects, but my needs were different.
|
| Originally I wanted to create a browser based generator for token
| trays. I prefer not to have any code running on a server (so I
| don't need to pay or operate them). So CadQuery was out of the
| picture. It needed to be in javascript.
|
| I really liked what Cascade Studio was doing - but I wanted to
| create my own UI for configuring boxes - and the studio is only
| an integrated environment - there was no library to just make the
| models.
|
| So replicad was born! You can read the docs at
| https://replicad.xyz/ (and play with the workbench at
| https://studio.replicad.xyz/workbench)
| digdugdirk wrote:
| Truly impressive work. Any recommendations for getting started
| working with the OpenCascade kernel?
| sgenoud wrote:
| I could not find any great documentation. I mostly learnt by
| reading CadQuery's code and implementing in Typescript.
|
| Once you get how it works googling the name of the OC methods
| helps sometimes. But there is not much around.
| boomskats wrote:
| Are you by any chance part of the custom ergonomic keyboard
| community? I can see this being incredibly useful in replacing
| a bunch of existing work to programatically generate
| parameterised custom 3d-printable keyboard cases, currently
| done in Clojure/OpenSCAD/Blenderpy etc.. Currently the REPL
| workflow and toolchain for most such designs is way too long,
| and I can really see that use case driving adoption of your
| library.
|
| How hard would it be to make your workbench pull and render
| code from GitHub repositories, so that for example, authors can
| link to a render of the codebase in their readme?
|
| This is really great work btw. A pleasure to tinker with.
| Following closely.
| sgenoud wrote:
| > How hard would it be to make your workbench pull and render
| code from GitHub repositories, so that for example, authors
| can link to a render of the codebase in their readme?
|
| You can already do some of this. Either by pointing to an
| encoded url (something like this:
| https://studio.replicad.xyz/workbench?from-
| url=https%253A%25...).
|
| There is also a share arrow which will put the current code
| in an url param (and you can have something like this: https:
| //studio.replicad.xyz/workbench?code=UEsDBAoAAAAIANhzV...
| monkmartinez wrote:
| The UI is gorgeous and buttery smooth on my Windows machine.
| Very impressive.
|
| In the docs, the example pages have a nice 'configuration'
| dropdown. Again, this is very nice and I can see a bunch of 3D
| printing websites adopting this as a library. I mean, how many
| times have you seen a model that just needs a slight tweak to
| be perfect, but there is just too much friction (download,
| unpack, load, modify, resave, reupload).
|
| On another note, I wonder if I can train a small LLM to the
| docs. Once trained, I would be able to have a conversation to
| create some really cool geometry. Hmmm...
| pmayrgundter wrote:
| Really nice project!
|
| I'm looking for CAD libraries for our project at bldrs.ai and
| have been considering replicad.
|
| Could you describe the relationship with OpenCascade/OCJS.org
| and also the other projects using it. Replicad is listed on
| their README as one of 4 design tools using it. CascadeStudio
| and your project seem to be similarly targeting general use
| scripting. Are you in touch, with any thoughts on how to
| collaborate?
|
| I'm also curious How do you see the health of OpenCascade. The
| last commit 8 mo ago and their issues look like it's getting
| difficult to build. But I understand it's also a singularly
| valuable open-source CAD kernel.
|
| Thanks, any thoughts appreciated!
| sgenoud wrote:
| We are a loose group of people who interact a little bit!
|
| The person maintaining OCJS works on in bursts - it depends
| on the time he has. He is doing a great job at it!
|
| The difference between replicad and Cascade Studio is that
| replicad is a library first - that you can include in your
| specific project. As a proof of concept I built a development
| environment while Cascade Studio is meant as a development
| environment first. Different aims with different tradeoffs.
|
| People around code cad have been interacting a bit in the
| CadHub discord - but it is a bit quieter lately!
| pmayrgundter wrote:
| Thanks!
|
| Yes, joined CadHub last year but yeah, a little quiet. I'll
| say hi again
| levpopov wrote:
| This is fantastic, thank you for your work! I'm excited to see
| this project combine a clean API in a popular language, with a
| fast online playground that requires no installation. Having
| played with OpenSCAD and CadQuery in the past, this feels like
| a big step forward.
|
| Some suggestions (I'm sure you've already thought of most of
| these):
|
| - It would be great to have notebook-like UI to isolate steps
| and allow faster partial rebuilds.
|
| - live editing is great, but it'd be nice to automatically stop
| in-progress rebuild if another edit is made while it's
| computing. Right now it seems to always let a rebuild complete
| even if it's already out-of-date.
|
| - Search on API/docs page would be really handy
|
| - Face/vertex filtering API looks cleaner than CadQuery's, and
| I'm excited to try it out. In a lot of cases I would still
| really like to just be able to click on the model and get a
| reference in code. Even if it's just an index that would break
| if topology has changed. Auto-generating stable
| references/filters would be even better, when possible.
| sgenoud wrote:
| > - It would be great to have notebook-like UI to isolate
| steps and allow faster partial rebuilds.
|
| Great idea, I have done something in that spirit integrating
| with natto.dev, but something more like a repl might be nice
| as well
| (https://natto.dev/@sgenoud/e2ade00d1fb4406abe78061e7f9a959b)
|
| > - Search on API/docs page would be really handy
|
| Good point, I use docusaurus, there is an algolia
| integration, I will look into it!
|
| > Even if it's just an index that would break if topology has
| changed. Auto-generating stable references/filters would be
| even better, when possible.
|
| Definitely the reference should be easy to implement, the
| stable one... less so.
|
| I have tried to implement a filtering method inspired by cad
| query but which did not invent its own DSL. Always interested
| in feedback!
| beardicus wrote:
| this looks very nice. i think i like the ergonomics of your
| library... the "sketch on a plane then extrude" workflow feels
| nice and familiar.
|
| could you compare and contrast replicad to JSCAD
| (https://openjscad.xyz)?
|
| the examples in your docs are quite sluggish to load in Safari,
| but the workbench is very snappy!
| sgenoud wrote:
| There are two main ways of representing 3D objects, BRep and
| mesh.
|
| BRep is the equivalent of a vector image. It has the advantage
| of having the notions of faces and edges within the
| representation. This is what replicad uses.
|
| Meshes is the equivalent of a raster image. This is how 3D art
| is usually made. It has some performance advantages. This is
| what JSCAD uses.
|
| The reason the example took some time to load is that the code
| needed to get to the page a first time. After this it is snappy
| everywhere.
| iamflimflam1 wrote:
| Very nice. I've played with OpenSCAD a few times and quite enjoy
| the CAD as code idea.
| vutekst wrote:
| This looks like a good replacement for most of what I do in
| fusion360, but one operation I'm not sure about is importing an
| existing SVG file and using it for sketch geometry, say, to put
| an embossed logo onto something. In looking through the Replicad
| docs, the only SVG references I saw were about exporting.
|
| Is this something people have done with Replicad? Perhaps with an
| additional lib for parsing SVG into a set of 2D curves?
| sgenoud wrote:
| Something like this? https://blingmything.sgenoud.com/
|
| You can find the code (with SVG import) here:
| https://github.com/sgenoud/replicad-decorate and
| https://github.com/sgenoud/blingmything
|
| And use it like this (it does not work in Firefox yet, it needs
| module workers):
| https://studio.replicad.xyz/workbench?code=UEsDBAoAAAAIAIyZV...
| vutekst wrote:
| Why yes actually! Thanks for your quick and very helpful
| reply
___________________________________________________________________
(page generated 2023-02-20 23:01 UTC)