[HN Gopher] Code CAD - Use code to create CAD models
       ___________________________________________________________________
        
       Code CAD - Use code to create CAD models
        
       Author : todsacerdoti
       Score  : 127 points
       Date   : 2021-10-18 15:47 UTC (7 hours ago)
        
 (HTM) web link (cadhub.xyz)
 (TXT) w3m dump (cadhub.xyz)
        
       | wilsonjholmes wrote:
       | Love this site! Keep up the great work.
        
       | ravenstine wrote:
       | I'm not sure I understand the thing about the models not being
       | live previews. Is OpenSCAD effectively being run on the server
       | and the code needs to be sent to it every time you modify code or
       | change the camera?
        
         | hobofan wrote:
         | See the link to the explanation just above it:
         | https://learn.cadhub.xyz/docs/general-cadhub/openscad-previe...
        
           | ravenstine wrote:
           | Honestly, that still doesn't really answer my question.
           | 
           | I can run OpenSCAD locally and there's never a lag like that
           | when I pan/tilt/zoom the camera. I could understand if that
           | lag occurs in this web app if OpenSCAD wasn't actually
           | running in the browser but instead as an instance on a
           | server, but the page you linked to doesn't state whether
           | that's what's happening.
           | 
           | Or maybe it's just an approach to "bake" the model into an
           | image to save resources or prevent potential freezes?
           | 
           | I'm not criticizing it but am just curious about the
           | reasoning.
        
             | MH15 wrote:
             | For real this is almost unusable. Would be curious to see
             | what's going on here, the rest of this tool looks well-
             | designed.
        
               | meetups323 wrote:
               | Quick check in the network tab shows that each camera
               | move sends the full buffer and camera coords to some aws
               | server where it spends a second rendering then comes back
               | with an image.
               | 
               | The JSCAD integration is however all in-browser and is
               | _far_ smoother. They should lead with it, IMO.
        
               | imtringued wrote:
               | That sounds unbelievably stupid. Why render 3D graphics
               | on a server that has no hardware acceleration?
        
               | ajuc wrote:
               | that way you can use open source and don't share your
               | code :)
        
             | billconan wrote:
             | there is a web version openscad
             | http://openjscad.azurewebsites.net/
        
               | randomsilence wrote:
               | Could this be an older version?
               | 
               | The current version should be:
               | 
               | https://www.openjscad.xyz/
        
         | cassianoleal wrote:
         | OpenJSCAD [0] does live camera and the performance is great.
         | 
         | [0] https://openjscad.xyz/
        
       | sk2020 wrote:
       | Programmatically generating geometry is very cool, but I don't
       | know of anyone doing real work with it. OpenSCAD is probably the
       | best power-hobbyist software I know of for this purpose. AutoDesk
       | seems to be trying this approach with DyanamoBIM, which I'm
       | excited to experiment with (I just don't get visual programming
       | though).
       | 
       | Personally, I would never consider a web-based software for
       | professional use. An opaque profit model makes me think you're
       | looting my intellectual property to resell, mining crypto with
       | obfuscated JS or WASM, or you're snatching up market share to get
       | bought by Google who will just kill the service and leave me
       | hanging.
       | 
       | There's a lot of room for better software in AEC but CAD is
       | pretty robust and very affordable at this point.
        
         | zokier wrote:
         | I think the parametric constraint driven way of doing CAD is
         | actually already pretty programmatic. While I'm not sure, I'm
         | imaging that there might be some sort of isomorphism between
         | CAD-style constraints and Prolog-style logic programming...
        
         | mywittyname wrote:
         | > Personally, I would never consider a web-based software for
         | professional use. An opaque profit model
         | 
         | I worked on a web-based version of a major player in the
         | industry and the projected ended up getting canned. Ironically,
         | because (I think) they really couldn't figure out a good way to
         | profit from it. A license for the desktop product was like
         | $xx,000, but the ideas tossed around for the web-based version
         | were like $y.00 per minute of instance time (basically like EC2
         | pricing). Turns out that $y would need to be Very Large to be
         | even remotely profitable.
         | 
         | The product itself was pretty slick though. I was really
         | surprised at how well it performed.
        
         | criddell wrote:
         | AutoDesk has supported this kind of automation from almost the
         | very beginning (originally you had to use their Lisp variant
         | AutoLisp but now there's more flexibility).
         | 
         | I agree with you about the web-based criticism though. Working
         | in a browser feels pretty limiting and it's so slow.
        
         | buildsjets wrote:
         | I've been programmatically generating geometry in Dassault
         | CATIA since 1998 or so. Relational Design is essentially the
         | CAD version of object oriented programming.
        
         | GordonS wrote:
         | I've previously worked at 2 large engineering companies in the
         | oil and gas space, and both were using automation to generate
         | CAD models from configuration - not _exactly_ the same thing,
         | but close enough. They were doing this with both AutoCAD and
         | SolidWorks.
        
         | xupybd wrote:
         | We use https://www.cadcode.com/ for our production of
         | furniture.
         | 
         | It's a little different but essentially it takes data to define
         | geometry and machine operations. We generate that data in code
         | and pass it on to cadcode. Cadcode then passes that on to our
         | NC machines.
        
         | jpgleeson wrote:
         | Grasshopper, which Dynamo is really trying to compete against,
         | is in wide use in the architecture world.
        
           | [deleted]
        
           | andreseg wrote:
           | I would encourage looking into Rhino3D and Grasshopper3D. As
           | @jpgleeson mentions - this is already widely used by
           | architects as they move from a world of buildings made up of
           | mass-produced identical components (e.g., every brick is the
           | same shape and size), to a world where mass customization is
           | possible (e.g., every brick has variable shape, massing,
           | structural properties, etc.). Being able to prescribe that
           | programmatically has a lot of promise. Tools like Grasshopper
           | already enable some of this customization via code as you can
           | see here
           | https://developer.rhino3d.com/guides/rhinopython/ghpython-
           | ca...
           | 
           | Plugging into existing frameworks (like Rhino) is quite easy
           | and can open the door to other realms of
           | optimization/simulation for the designs you are scripting.
           | For instance you could leverage generative design (e.g.,
           | https://www.youtube.com/watch?v=-HLRtXSG7fQ) and other
           | software that can be used to evaluate designs according
           | against variety of criteria ranging from structural
           | integrity, to environmental performance, to 3d-printability,
           | etc. If there's open source frameworks you can plug into,
           | even better.. and if not.. then maybe that's what's missing:
           | an easy standard way for various opensource projects to share
           | and edit information.
           | 
           | Programmatically-defined designs make sense to me only if you
           | can easily change parameters to quickly produce, evaluate,
           | and optimize the designs/variations/results. Otherwise -
           | Better to use a GUI that allows for more direct (and less
           | abstracted) expression of designer intent
           | 
           | Similarly open source CAD makes sense if it can be augmented
           | by other open source projects - including sharing and editing
           | data from these various projects
        
           | xor99 wrote:
           | Yeah these are mostly used for architecture. Seemingly
           | exclusively to produce the same generative style
        
             | somewhereoutth wrote:
             | Styles are going to be strongly influenced by the tools
             | used to communicate them, so possibly no surprise
        
         | ahupp wrote:
         | > Personally, I would never consider a web-based software for
         | professional use.
         | 
         | I've seen a lot of enthusiasm for OnShape (a relatively new
         | web-based CAD tool) among professional CAD users, particularly
         | when there's more than a handful of people working on one
         | project.
        
       | xor99 wrote:
       | https://www.libfive.com/
       | 
       | Libfive is quite good to check out too but yes openscad and
       | cadquery are the most used.
        
         | ur-whale wrote:
         | > Libfive is quite good to check out too
         | 
         | Lots of potential, but IMO not really usable for real world
         | work.
         | 
         | For example, there isn't any (or I haven't found any) simple
         | way to create a clean fillet between two complex surfaces other
         | than blending them and hoping for the best.
         | 
         | Documentation of the API is lacking, except for a bunch of
         | examples in scheme (not exactly the most popular language for
         | CAD folks).
         | 
         | Python API exists, but documentation is ... reading the source
         | code.
         | 
         | Finally, the implicit surface tessellation algos used in
         | libfive are IMO somewhat unpredictable and getting them to
         | produce precise shapes (which is something fairly desirable in
         | mechanical engineering) is hard.
        
           | app4soft wrote:
           | > _Lots of potential, but IMO not really usable for real
           | world work._
           | 
           | What about _Antimony_ and _VisualScriptCAD_?[0,1]
           | 
           | [0] https://github.com/mkeeter/antimony
           | 
           | [1] https://github.com/kovacsv/VisualScriptCAD
        
       | jetrink wrote:
       | The tool looks very nice, but the syntax, which looks pretty
       | close to OpenSCAD, is pretty ungainly. It makes me wish lisp-
       | style syntax were more widely accepted.
       | difference() {           hull() {             ...           }
       | translate([1, 0])             circle(r)         }
       | 
       | I mean, those are just s-expressions in disguise.
       | (difference           (hull ...)           (translate
       | (circle r)             [1, 0]))
       | 
       | The distinction between modules and functions also seems
       | unnecessary.
        
         | tjoff wrote:
         | There is a small clojure project that transpiles clojure to
         | openscad, (if I remember correctly...)
         | 
         | https://github.com/farrellm/scad-clj
         | 
         | Demonstrated and talked about in this clip:
         | https://www.youtube.com/watch?v=uk3A41U0iO4
         | 
         | edit: it is a fantastic talk but the part related to this
         | starts at 17:35
        
         | traverseda wrote:
         | https://libfive.com/studio/
        
         | eurasiantiger wrote:
         | Language-wise, OpenSCAD is very functional-ish indeed. Try
         | writing code to distribute a vector of length multipliers
         | evenly along some arbitrary length, e.g. [1,2,1] times 20 over
         | 100 coordinate units. It is only possible by recursively
         | calculating a vector of coordinate positions, in our example
         | [0,5,25,30,70,75,95,100]. Not the easiest task for the
         | uninitiated.
        
       | dividedbyzero wrote:
       | I've been using CadQuery [1] a lot of late to develop custom
       | parts for 3D printing, and while it's nice to be able to write
       | plain Python and the abstractions are somewhat more intuitive
       | than OpenSCAD, it's still kind of brittle and complex parts are
       | hard work.
       | 
       | There are things CAD-as-code excels at, but once you leave the
       | happy path of simple primitives with a few holes and a bit of
       | chamfer, I found things can get really ugly real quick. Organic
       | shapes are very hard to construct, and simply generating
       | polylines or the like either fails because OpenSCAD takes literal
       | hours to render or because CadQuery throws some weird error
       | halfway through and I just can't get it to work.
       | 
       | I'd love to see a free or at least affordable (for hobbyists) CAD
       | solution that isn't code-only, cloud-only, totally crippled in
       | terms of functionality, or extremely arcane. I believe Fusion 360
       | went cloud-only (or almost) last year or so, and between Fusion
       | 360 and FreeCAD (which I tried to learn, but couldn't figure out)
       | there seems to be a big opportunity for an affordable, user-
       | friendly, open CAD tool for the 3D printer owning masses (there
       | are dozens of us!)
       | 
       | 1: https://github.com/CadQuery/cadquery
        
       | empressplay wrote:
       | I think this stuff is really awesome, I make turtleSpaces which
       | lets you create and export STL models using the Logo programming
       | language https://turtlespaces.org -- creating a shape using an
       | algorithm and then 3D printing it is really cool!
        
       | ChrisArchitect wrote:
       | Further discussion 4 months ago:
       | 
       | https://news.ycombinator.com/item?id=27649270
        
       | rowanG077 wrote:
       | Honestly openSCAD is pretty cool but you quickly run into
       | limitations because of it's DSL. One major reason I don't like it
       | is that it uses mesh-based modeling and not boundary
       | representation. With the former you can never get a "perfectly"
       | smooth sphere for example. Most CNC shops require the latter. So
       | a few years back I moved to CadQuery[1]. CadQuery uses boundary
       | representation and uses Python as it's host language. This
       | essentially makes it superior in almost every way to openSCAD.
       | 
       | [1] https://github.com/CadQuery/cadquery
        
         | ravenstine wrote:
         | Oh wow, I've never heard of this and might have to check it
         | out. I love OpenSCAD in contrast to other free CAD programs
         | I've tried, but not being able to directly work with STEP has
         | been a limitation.
        
           | [deleted]
        
         | phrz wrote:
         | Unfortunately CadQuery (primarily its GUI) seems like its
         | development has fizzled out, without getting it to the point of
         | functionality on macOS. OpenSCAD, on the other hand, works
         | quite reliably on Mac.
         | 
         | Also, it's clunky, but I've had success by using Python to
         | _generate_ OpenSCAD code. The best application of this was an
         | SVG to OpenSCAD path converter.
        
           | rowanG077 wrote:
           | Doesn't https://github.com/CadQuery/CQ-editor work on MacOS?
           | I don't really see how development has fizzed out. There have
           | been quite a few commits the last couple of months.
        
             | freeopinion wrote:
             | I wanted to kick the tires on CadQuery, but I had to
             | install and understand Anaconda first. Any tool that
             | requires me to understand a build system or a language
             | package manager to correctly and safely build the software
             | before I can use it is not ready for prime time.
             | 
             | If this was important for my life, I might put in the
             | effort. If it is for passing curiosity, I probably won't.
             | Especially when it impacts not just this software but opens
             | an entire universe of what exploits can now be run on my
             | PC.
             | 
             | When I have to set up a VM to sandbox an environment for a
             | tool, it stretches my patience. It makes the tool extremely
             | cumbersome.
        
               | grawp wrote:
               | I feel you. (Un)fortunately for me CQ is important enough
               | because OpenSCAD and similar are not CADs... they are
               | just _simple_ generators without an ability to reference,
               | use already drawn things. Whereas CadQuery has the main
               | feature which is missing from OpenSCAD directly in its
               | name:  "Query".
               | 
               | I'm actively working on bringing CadQuery and all its
               | dependencies to Nix because *Conda is an abomination of
               | highest order.
               | 
               | Moreover the pywrap and OCP which are CadQuery's
               | dependencies are even much worse. They are like galleries
               | of every DevOps anti-pattern ever invented. The more you
               | dive into them the more horrible it gets.
               | 
               | CQ is actually nice though.
        
               | dbrueck wrote:
               | FWIW I'm not familiar with Anaconda either and it took
               | about 10 minutes to get it and the cadquery editor up and
               | running. To each his own though!
        
               | amelius wrote:
               | Which is ironic given that Anaconda was made to
               | _simplify_ package management and deployment.
        
               | freeopinion wrote:
               | Of course, when the tool is actually a library for a
               | particular programming language, considerations of build
               | environment and package manager are more germane. But you
               | still might question if it is worth it.
        
         | meetups323 wrote:
         | Worth noting that this product is able to operate on CadQuery
         | and JSCAD in addition to OpenSCAD.
        
         | dbrueck wrote:
         | cadquery is great! I had been a Fusion 360 user for 3D
         | printing, but then Autodesk started getting weird with hobbyist
         | licensing. And Fusion's insistence on being cloud-based was
         | frustrating. Anyway, I went hunting for something else and
         | found cadquery and haven't looked back.
         | 
         | Modelling via code in cadquery is definitely a different
         | approach in a lot of ways, but it is extremely powerful too:
         | you get all the goodies like parameter-based, non-destructive
         | history but also things that might not be obvious up front,
         | like being able to "comment out" sections of your model (not
         | just hide them - but skip generating them) temporarily,
         | building up reusable helper routines, easily swapping out rough
         | prototype vs thoroughly designed parts that are depended upon
         | downstream in the model, and being able to organize complex
         | models into separate modules.
         | 
         | I don't think I'd necessarily recommend this approach to
         | modelling to a non-developer, but if you're already a
         | developer, it is tough to beat (for 3D printing at least).
        
         | amelius wrote:
         | I really would like to know how programs like CadQuery maintain
         | a robust geometric representation given the inevitable rounding
         | errors that will occur in floating point. For example, how can
         | CadQuery guarantee that a surface will never self-intersect
         | after a number of operations have been performed on it?
         | 
         | Wikipedia has a page on it [1], but quickly skims over some
         | techniques without much details.
         | 
         | [1] https://en.wikipedia.org/wiki/Robust_geometric_computation
        
           | [deleted]
        
         | aaaaaaaaaaab wrote:
         | Actually, you can get a perfectly smooth sphere both with
         | constructive solid geometry and boundary representation. Where
         | you cannot get a perfect sphere is mesh-based modelers.
        
           | rowanG077 wrote:
           | You are right. I was confusing the two. I have edited my
           | comment.
        
             | croes wrote:
             | Isn't OpenSCAD based on CSG and not mesh based?
        
               | rowanG077 wrote:
               | It's CSG using CGAL which is mesh based.
        
       | irevdev wrote:
       | Hey, I created CadHub.
       | 
       | I'm really bullish on software driven CAD, myself and other
       | CadHub volunteers talk regularly about a future in which
       | Mechanical Engineering and design is very similar to software
       | engineering.
       | 
       | I'll be the first person it admit that some of the current
       | CodeCAD tools aren't production ready, OpenSCAD for example I
       | can't imagine being used by mechanical engineers. So the idea is
       | mostly about unifying the community with a website dedicated to
       | this paradigm, and if we're lucky we play a small role in
       | promoting more development and better tools in the future.
       | 
       | Some of the reasons it's got potential:
       | 
       | - 3d-diffs on pull requests [1]
       | 
       | - Automated FEM, CFD etc simulations akin to CI/CD [2]
       | 
       | - PLM managed through git
       | 
       | - plus git in general is such a good way for teams to work
       | together
       | 
       | [1] https://learn.cadhub.xyz/blog/3d-diffs/
       | 
       | [2] https://learn.cadhub.xyz/blog/testing-code-cad/
        
         | TaylorAlexander wrote:
         | Howdy! Well we absolutely need more open source CAD tools.
         | 
         | That said as a mechanical engineer for going on two decades
         | now, I really get no value from this kind of mechanical design.
         | I grew up on Solidworks and now use OnShape. That kind of
         | physical modeling is very important. Being able to click on a
         | face and sketch some geometry and then extrude it really feels
         | like the right modality for me. I'd really love to see more
         | investment in that kind of parametric visual CAD.
         | 
         | EDIT: An example of one of my recent projects:
         | https://twitter.com/TLAlexander/status/1450001567088713730
        
           | OJFord wrote:
           | My background is software, I do (mechanical) CAD just for
           | hobby stuff, but I agree about the GUI being a convenient way
           | of working on it.
           | 
           | What I desparately want though is an on-disk format that's
           | plaintext, makes sense, and results in reasonable diffs so
           | that I can use git for version control.
           | 
           | I just don't understand, being familiar with git, how people
           | can work with 'save and mark new version' style 'version
           | control' that's so prevalent among tools that have anything
           | at all.
        
           | app4soft wrote:
           | > _I grew up on Solidworks and now use OnShape... I'd really
           | love to see more investment in that kind of parametric visual
           | CAD._
           | 
           | Has You tried _SolveSpace_ app?
           | 
           | [0] https://solvespace.com
           | 
           | [1] https://git.io/SolveSpace3x (latest nightly builds +
           | various useful resources)
        
           | irevdev wrote:
           | "why not both"
           | 
           | Direct manipulation/GUI will always be faster at producing
           | content. It worth exploring how much the two can we wedded
           | with code synthesis. I get that code synthesis attempts
           | normally produce poor quality code, but maybe a hybrid work
           | flow could work between using the GUI and fixing up code.
           | 
           | It's a shame that the current CodeCAD tools have very little
           | interaction with he part viewer.
           | 
           | https://www.youtube.com/watch?t=290&v=jC2_O5Jh_Rg&feature=yo.
           | ..
           | 
           | https://www.youtube.com/watch?v=xF8arSFKI1k
        
             | TaylorAlexander wrote:
             | Maybe both would be fine, I am just saying the code part is
             | much less useful to me than the visual/parametric editor.
             | Onshape for example has scripts which can do things like
             | generate gears and that is great, but I use scripts for
             | less than 0.1% of my onshape work. The visual/parametric
             | component is what users like me really need. I added it
             | late to my comment but here is an example of one of my
             | recent CAD projects.
             | 
             | https://twitter.com/TLAlexander/status/1450001567088713730
             | 
             | I will check out those videos when I get a chance.
        
             | amenghra wrote:
             | Onshape is a good combination of visual + you can set exact
             | values for things. I'm always happy to try new tools, but I
             | tend to fallback to Blender for artsy stuff and Onshape for
             | more precise parts.
             | 
             | I suck at 3d modeling, so I evaluate tools from a "how much
             | value can a noob get" point of view.
        
               | TaylorAlexander wrote:
               | That is definitely an important user perspective. My
               | angle is that I am a professional robotics engineer as
               | well as an open source evangelist. I design a lot of open
               | source CAD and I'd really like it if the CAD package
               | itself was open source as it is important to me to have a
               | community of users who fork my designs. So far open
               | source CAD does not feel adequate as a design tool for
               | me. FreeCAD is conceptually the closest but it seems like
               | the project needs more investment. I recently tried it
               | again and it seems extremely simple compared to
               | Solidworks or Onshape.
               | 
               | Honestly CAD is very complex software and is not well
               | suited to a single engineer working in their hobby time.
               | I think a huge reason Blender has been successful is that
               | they built a sustainable crowd funding system. They
               | currently pull in $166k each month with that system:
               | https://fund.blender.org/
               | 
               | I am pleased to see also Godot engine (a similar type of
               | tool) pulling in over $7k/month (last I checked) on
               | Patreon.
               | 
               | Anyway there is a "business model" for open source
               | projects even if they don't sell anything. Call it a
               | funding model. I think open source projects need to get a
               | handle on that for anything that exceeds a very small
               | team.
               | 
               | I am trying to build this kind of sustainable funding for
               | my own open source farming robot (link in profile) and I
               | think we're going to go with Open Collective at least as
               | a front end.
               | 
               | https://opencollective.com/
               | 
               | For fiscal hosting we've applied to the Open Collective
               | Foundation and the Software Freedom Conservancy.
               | 
               | https://sfconservancy.org/
               | 
               | I think open source CAD really needs a funding plan like
               | this. It's a very large software project and we've seen
               | how Blender and Godot are able to actually get traction
               | and produce a compelling program with resources like
               | that.
        
               | irevdev wrote:
               | Some really interesting thoughts in funding, thankyou.
               | The gotdot and blender examples useful.
        
           | mywittyname wrote:
           | From what I've seen, most programmatic integrations comes on
           | the CAE/simulation side of the house. Faces of the part are
           | given specific names/metadata by the designer and a script is
           | used to automatically apply the loads/constraints and run it
           | through the simulation.
        
         | thedavidprice wrote:
         | > So the idea is mostly about unifying the community with a
         | website dedicated to this paradigm, and if we're lucky we play
         | a small role in promoting more development and better tools in
         | the future.
         | 
         | Yes, please!
        
       | marcodiego wrote:
       | Since the links doesn't indicates, its license is GPLV3:
       | https://github.com/Irev-Dev/cadhub
        
       ___________________________________________________________________
       (page generated 2021-10-18 23:00 UTC)