-
Beta Was this translation helpful? Give feedback.
Replies: 8 comments 2 replies
-
I'm afraid that 3D VNF unioning has not as yet been implemented in BOSL2. It's a difficult and slow operation to implement in the OpenSCAD language. |
Beta Was this translation helpful? Give feedback.
-
What you're suggesting sounds like re-writing modules through VNFs. In other words, to make a super-VNF data structures that is a boolean operator tree of VNFs. We can already do that by writing a module, and it doesn't seem to offer any obvious advantage over using the existing module method. Is it possible that you're not aware that you can have modules for each shape? That approach will enable code modularity. |
Beta Was this translation helpful? Give feedback.
-
I am still mentally struggling with this ... so take what I say with a grain of salt. The modules are a solution to insert a transformation matrix ahead of running its children. The shape that is generated is basically caused by the side effects of the modules.
The scale module will set a new "current" transformation that doubles the x,y, and z after which it calls its children. It is an interesting way to do this although it took me some time to 'get' it. One of the really nice things of BOSL2 is that it can do this:
So instead of committing to an output, I can transform a shape before I make render it. For example, since I can get the bounding box of each VNF, I can take a list of VNFs and distribute them evenly in a given space. This cannot be done with he Although the concept of children is interesting, it is kind of awkward to use a programmer. For example, I wrote a module that inserted a shape with holes into a solid table. If you do a difference, you lose the holes, if you do an intersect, you just have the original shape. The solution was to pass the solid as the first child, and then the other children as the insertables with holes.
Clearly the first child needs to be treated special, it would be cleaner if this could be parameterized with a proper name and default. I also had the problem that I needed to create a tableau with different inserts in rows and columns. There were about 10 different insert types. In the end I passed the modules that created the shapes as children and then passed an array with indexes that specified the layout. Works, but feels very indirect. So my issues with the
Then again, a lot of this is moot. The BOSL2 library is quite incredible but the VNF supports makes it painfully slow. If this was going to be an idea, it would probably need native support. thanks for the feedback. |
Beta Was this translation helpful? Give feedback.
-
Yes, it's true that you can modify the vnf with the scale operation as you show above to produce a new vnf. You say, "So instead of committing to an output, I can transform a shape before I make render it." But you don't really say why this is a useful thing, other than the business about extracting bounding boxes from the vnf, which is a weak advantage. Note that precisely the same thing can be done with modules: module vnf() cube(3); I do not understand why you think you can only parameterize things by indices. You can parameterize however you want. Use a cascading if statement to check various string options, or use search() on an array of names to get an index and then use that to index. Modules in the BOSL2 library often use scalars, vectors, text strings, booleans, or a combination of all four of these things to define the shape. Arguably extracting bounding boxes from a vnf is not a very interesting capability, nor generally useful. I don't think I have made any models where I needed to distribute a bunch of objects of unknown size over an area. At least for the 3d printing I do, that's not a typical situation. That said, the inability to extract information from OpenSCAD geometry is a major frustration. You can work around this a bit. More on that below. I do not understand what you mean about modules "using side effects in a functional environment". First of all, most OpenSCAD users do all of their work entirely with modules. Arguably modules are the dominant and defining feature of the OpenSCAD environment. Furthermore, modules operate in a functional way. It's just that there are two mechanisms for passing parameters, one for variables and one for geometry. Side effects do exist, but it doesn't sound like you're aware of them or are using them. What I would call side effects are the variables that start with a $ that you can use in a module to change the behavior of children. I think you need to read the BOSL2 Attachments Tutorial to gain some insight into a way of working around geometry not revealing information: the module can know the information, since it made the geometry, and pass it through $ variables to children. The methods described in that tutorial should enable you to work around the problem you described of wanting to combine an object with a second object that has a hole. https://github.com/BelfrySCAD/BOSL2/wiki/Tutorial-Attachments |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
There's a guy who posts to the forum who uses Python to do all the geometry and just uses OpenSCAD as a rendering engine. Perhaps this approach would appeal to you. I agree that it would be nice to be able to get information out of geometry. I'm not sure I understand how constructing the geometry is a "side effect". What makes it "side"? It's the effect. The OpenSCAD file represents the CGAL data structure----that's the purpose of the file. So how is it a "side" effect? The issue of getting information out of geometry is fundamental. Things like positioning objects could be done without needing the VNF if we could extract object size information from the geometry. I think actually the reason that you cannot do this is that extracting that information would be a side effect. That is, you have to render() the geometry to know what it is to be able to extract the geometry data. With tags you probably need to create a tag scope to prevent tags at multiple levels from interfering. I use the distribute modules (xdistribute, ydistribute, zdistribute) fairly often----but only for the purpose of laying out a set of example objects in the BOSL2 manual, not for any real modeling purpose. When you talk about "the speed penalty" what are you referring to? Is there some existing BOSL2 operation that is problematic? |
Beta Was this translation helpful? Give feedback.
-
The CGAL tree is the output of an OpenSCAD program. Modules are a mapping from inputs to the CGAL tree. Yes, it's global. Does that mean the relationship is not functional? (Note also that OpenSCAD is moving towards Manifold instead of CGAL. Manifold is a lot faster.) In terms of BOSL2 design, it's actually frustrating that we are forced to make functions instead of being able to provide better integrated modules. This is due to the inaccessibility of the geometry. It means a division in approach depending on whether you have geometry or data available. However, modules perfectly allow for reusable "functions". I do not understand how using functions running on VNFs is different in any practical sense if we posit modules that can see inside the geometry. (And for VNFs to work we need to make a similar assumption, that we have access to geometric operations, so neither thing is presently possible.) I believe that the OpenSCAD developers see modules as the central feature of OpenSCAD and are likely to enable us to make better modules rather than making it easier to write code that works on VNFs. (A few years ago Revar tried to get them to include code for applying 2d union/intersection etc to paths and that has not been accepted.) The reason that you have to render() to get shape information out of geometry in OpenSCAD is because the shape information doesn't exist until you do so. It is created during the rendering process. Until render is run there's just a tree of commands. The skin and sweep methods should not be particularly slow (except in the case of skin with the O(n^3) vertex alignment method). What do you mean by slow? I'm also not sure what you mean when you say "any function that returns a shape must return a VNF" like this is a limitation or disadvantage somehow? For tags you can declare a local scope by doing |
Beta Was this translation helpful? Give feedback.
-
I think that is the crux ... :-) I think we're not that far of. |
Beta Was this translation helpful? Give feedback.
I'm afraid that 3D VNF unioning has not as yet been implemented in BOSL2. It's a difficult and slow operation to implement in the OpenSCAD language.