JSCAD User Group
    • Tags
    • Popular
    • Users
    • Groups
    • Register
    • Login

    Empty object

    Scheduled Pinned Locked Moved Design Discussions
    2 Posts 2 Posters 747 Views 1 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • udifU Offline
      udif
      last edited by

      What is the canonical way to create an empty OpenJSCAD object?
      I have some code where I need to union() several objects, but each of them is optional.
      I would like to write something like:

      o = empty_object()
      if (cond1) {
        o = union(o, ...)
      }
      if (cond2) {
        o = union(o, ...)
      }
      if (cond3) {
        o = union(o, ...)
      }
      

      I can probably do something like:

      o = intersect(cube(), translate([0, 0, 100], cube()))
      

      But I would rather have something more descriptive.

      z3devZ 1 Reply Last reply Reply Quote 0
      • z3devZ Offline
        z3dev @udif
        last edited by

        @udif great question!

        There are three main objects; geom3, geom2, and path2. You can create empty versions of these…

        const a = geom3.create()
        const b = geom2.create()
        const c = path2.create()
        
        1 Reply Last reply Reply Quote 1

        Hello! It looks like you're interested in this conversation, but you don't have an account yet.

        Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

        With your input, this post could be even better 💗

        Register Login
        • First post
          Last post
        Powered by NodeBB | Contributors