Script to cut windows and doors into walls
 1-6  7-26  27-29

Previous
Next
 From:  Frenchy Pilou (PILOU)
10907.7 
You don't try the Elephant nodes system ?
---
Pilou
Is beautiful that please without concept!
My Moi French Site My Gallery My MagicaVoxel Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.8 In reply to 10907.7 
Hi Pilou,

I haven't used the Elephant, probably because I've never been much interested in visual programming tools--I prefer to work with more traditional code... ;-}

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.9 
Problem solved & I updated the first message in this thread with the solution and description.

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
10907.10 In reply to 10907.9 
Cool you recreate a SketchUp Like prog! ;)

Maybe name _CutWalls for separate from native commands...

I Just use it by instinct without read text! :)

But maybe seems Glass is not at the good place ? (Must be at the middle of the thickness' frame ?


And cool works with any curves, Circles etc...
In no time the French version! ;) Done! ;)
https://moiscript.weebly.com/uploads/3/9/3/8/3938813/_cutwalls_fr.zip

EDITED: 1 Jan 2023 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.11 In reply to 10907.10 
Hi Pilou,

I thought that you might enjoy making curvy windows!

Thanks for the feedback on the location of the glass. I added the option to create the “glass” so that when you look at one of the side views of the building you wouldn’t be looking through the windows and be distracted by interior features—more like a piece of plywood than glass… I will set the glass just inside of the wall, like a modern window normally is, but probably not right in the middle of the wall.

It is odd to see that your images do not show the units on the two distance fields. Maybe that got turned off in one of your settings? The “probe depth” is set by default to 15 inches, but is then translated to whatever unit system the model uses.

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
10907.12 In reply to 10907.11 
Yes was just "Without Unity System" Options! ;)

So...


Not the middle of the "wall" but middle of the "Frame" thickness! ;)

EDITED: 2 Jan 2023 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.13 In reply to 10907.12 
Hi Pilou,

> Yes was just "Without Unity System" Options! ;)

Ah, something that I had not tested!

Thank you for the suggestion to move the glass, I think it looks much better now.

I also added the option to keep or remove the window curves, consistent with the Boolean Difference command.

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  pressure (PEER)
10907.14 In reply to 10907.13 
Hi Larry,

It's nice to see your project come to fruition. Happy New Year!

- Peer
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.15 In reply to 10907.14 
Thanks Peer & thanks again for your suggestions earlier. Still need to get a better handle on using the various dropPoint methods though. Happy New Year to you as well!

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.16 In reply to 10907.12 
Hi Pilou,

With 0.7 I've improved the .htm along with the .js, so although I can only mumble a little bit of French, I also updated your French version.

--Larry
Attachments:

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
10907.17 In reply to 10907.16 
I will see that tomorrow! :)

EDITED: 2 Jan 2023 by PILOU

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
10907.18 In reply to 10907.16 
Thx for the Fr Version! Absolutely perfect!
And the very cool thing is that you can make any number of different "Windows" in the same time!!!
I must add it to my repository! :)
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Frenchy Pilou (PILOU)
10907.19 
Done! ;) https://moiscript.weebly.com/portes-et-fenecirctres.html

Your last challenge put a frames & Glass in each piercing...


---
Pilou
Is beautiful that please without concept!
My Moi French Site My Gallery My MagicaVoxel Gallery
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.20 In reply to 10907.19 
Hi Pilou,

> And the very cool thing is that you can make any number of different "Windows" in the same time!!!

Indeed, that was my original goal, but I think our models are a little different. Think about a model of a building where you have many windows of differing sizes and locations as well as interior partition walls for rooms. My intent was to put a 2D curve on the outside of the walls wherever a window was to be located. Using the two phase selection model (like Boolean Difference), the script allows selecting all the walls to be cut followed by selecting all the window curves. Then the script examines the wall behind each window’s curve to determine that wall’s thickness and finally the script cuts and frames each window into its wall. Since a door is similar to a window, the script can also work for cutting and framing doors, but doesn’t go so far as to make the doors themselves.

> Your last challenge put a frames & Glass in each piercing…

Well…it already does that for my intended use… ;-}

Originally the “probe depth” was fixed at 15 inches which I thought would be sufficient for models of buildings. I like to avoid hidden constants if I can, and so to allow for other use cases, I exposed it as an option. The purpose of this probe depth is so that the script can figure out how thick each wall is while allowing for the selected walls to be of differing thickness. Ideally probe depth should only be a little deeper than the wall is thick. This probing business is kind of a hack because I couldn’t figure out another way to have the script discover the adjacent objects…something that I was asking Michael about on the V5 wish list thread.

When you make the probe depth super deep like you are showing, that causes the script to make a mistake in determining the adjacent wall’s thickness: it blasts through multiple walls. With a 200cm probe depth, you’re telling the script that a single wall may be up to 200cm thick, but that’s not what your model shows.

You’re also putting the window curve well outside of the wall rather than on the wall like I was originally thinking.

Both of these things suggest that maybe I can improve the logic a bit to avoid the errors of one window and frame poking through multiple walls, and the pane of glass not being inside of the wall. The challenge is to work on many different types of walls, some of which can have multiple layers with spaces in between the layers.

Thanks for providing a different use case to think about!

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.21 
Hi Michael,

Sorry, questions like this may cause you some frustration or irritation… I'll understand if you say "go away kid, you bother me!"

I've run into an interesting bug that I haven’t been able to figure out. After a fresh start of MoI, if I use my CutWalls script to cut a single window into one or more solids, the solids' names are preserved as one would expect. However if I then either Undo or reload the saved model and use the script in the exact same way the solids' names are deleted. Making it stranger still, if I point the script at a surface or joined surface and do the same operations, the surface names are never deleted. So basically the script only works correctly once after a fresh start of MoI, any subsequent use and the names of solids being cut are deleted.

I have narrowed the loss of object name down to the boolean difference operation, and of course a normal Construct > Boolean Difference behaves normally—object names are not deleted. Same issue with MoI v4 and v5 May beta.

With v5 the puzzle is more interesting in that solids which are part of a group do not have their names deleted.

Prior to the boolean difference, the script seeks to determine the thickness of the wall by creating a probe line normal to the curve and doing an intersect on the wall and the curve. It then moves the curve slightly outside of the wall and extrudes a solid which extends slightly through the wall on the other side (to be able to cut surfaces as well as solids). That solid is then used by the boolean difference to cut the wall objects.

The script is designed to be able to cut multiple windows and walls, and allows the walls to be of varying thickness. To accomplish this, the script loops through the set of window curves probing the wall behind each, making solid cutters, frames and glass as necessary. There is a single boolean difference at the end of the script to do all the cutting at once. (if I put the boolean difference into the loop, then the objects being cut replicate…)

If there are multiple windows being cut, then even with a fresh start of MoI, the names of the solids are being deleted.

All of this leaves me thinking that there is some state information that’s somehow not getting cleaned up, and that the various operations that the script performs are causing something to leak into the boolean difference, triggering the behavior. Beyond that hunch, I’m a bit clueless. Doesn't matter if input #2 (keep objects) is true or false.

To reproduce, create a box about 6” thick to represent a wall object, then draw a closed planar curve on one side to represent a window opening to be cut. Name the two objects then execute CutWalls. Select the box as the base object and the curve as the object to subtract. Don’t need to tick any of the option checkboxes. The window will be cut and the box’s name will be removed. Or, the other case, put two window curves on the box & the names are always removed.

--Larry

EDITED: 6 Jan 2023 by FAHNOE

  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10907.22 In reply to 10907.21 
Hi Larry, I'll try to take a look later but this is a great example of why I don't try to advertise that scripting in Moi is a thing that you can do, because it can be very difficult to come up to speed with complex scripts and try to support them.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10907.23 In reply to 10907.21 
Hi Larry, so for losing the object name - it looks like that's happening because on the result of a boolean where the new object has pieces in it that come from multiple objects, the new object's name will be inherited from the ancestor object that was first selected.

That's so there is a way to control which object will take precedence for keeping the top level name when doing boolean union.

In your script the thing that is different compared to the regular boolean difference command is that the cutting objects are "loose objects" generated inside the script and haven't been added into the geometry database and haven't ever been selected. It happens in that case that it gets the default selection order value of 0 and that makes the "assign top level object name from earliest selected original object" function think that the cutting objects have the priority.

I'll see about using some other method for this situation where some objects have never been selected before, but for the time being if you insert this line indicated with >>> <<< into the script does it clear it up?

code:
    var factory = moi.command.createFactory( 'booleandifference');
    factory.setInput( 0, baseObjs);
>>>    cutters.setProperty( 'selected', true );  <<<
    factory.setInput( 1, cutters);
    factory.setInput( 2, false); // Don't keep objects 
    factory.commit();

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.24 In reply to 10907.23 
Hi Michael,

Indeed, selecting the loose cutting objects prior to the boolean difference clears up both the loss of the name as well as the Undo/reload behavior.

I really appreciate your time and insight, but at the same time appreciate that it diverts you from your other objectives. Clearly my hunch that there was some state data leaking and causing unexpected behavior was off base, but it looked to me like there might be an issue worth reporting. To be clear, I don’t want to put you in the position of having to support something I wrote, but I also get that you potentially wind up in that situation regardless of my intentions. I suppose it is part of the blessing and the curse of providing the opportunity for users to contribute to your environment. As I’ve said before, I think that the scripting capabilities are one of MoI’s many stellar attributes.

Thanks again for your willingness to explain and provide background information!!

--Larry
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Michael Gibson
10907.25 In reply to 10907.24 
Hi Larry, I'm glad that solved it for the time being! I think I'll update this so that if any of the contributing source objects has never been selected before (which only happens with scripting) it will use the order that the objects have been set on the factory. That should then give a way to control it with boolean union for scripts and also boolean difference will automatically give priority to the base objects over cutting objects since that's in a lower factory input.

Thanks for reporting the problem.

- Michael
  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged

Previous
Next
 From:  Larry Fahnoe (FAHNOE)
10907.26 
Here’s an example of why I wrote this script. I have a modeling project for an old house which has a bunch of windows and doors, many more than I wanted to cut one at a time. So after I created the interior and exterior walls, I drew 2D curves on one side of each wall where there was to be a window or door. The curves were named Windows and Doors and the walls were named Ext. Walls and Int. Walls. I then ran the CutWalls script, selected Int. Walls and Ext. Walls as the base objects, and selected Windows as the objects to subtract, chose 0.75” frames named Window Frames, and Glass for the glass. The script then cut, framed and glazed 39 windows. Next I ran the script again, selecting the walls again as the base objects, but this time selected Doors and didn’t have it put the glass in. The script made 13 door frames. So, all the doors and windows were done in less than a minute. :-)

--Larry

Here’s the before and after:




  Reply Reply More Options
Post Options
Reply as PM Reply as PM
Print Print
Mark as unread Mark as unread
Relationship Relationship
IP Logged
 

Reply to All Reply to All

 

 
Show messages:  1-6  7-26  27-29