Script to cut windows and doors into walls
 1-20  21-29

Next
 From:  Larry Fahnoe (FAHNOE)
10907.1 
I have an idea for a script that I’d appreciate a little advice or help on.

When I make a model of a building, I create the walls and then add the windows and doors. The walls may be either multiple surfaces with empty space between, or multiple layers of solids (representing the building materials). I draw the outlines of the windows on one side of the walls. Next I cut the windows through the walls leaving behind the framed opening (just simple surfaces). Since a model has many windows to cut out, and several steps are required for each window, a script would be helpful and save time.

Outline of steps for each window:
1. Select outline curve of window
2. Extrude (without capping ends) to wall thickness
3. Select layers of the wall
4. Boolean difference using the extrusion as the cutting object (keep objects)
5. If wall was composed of solids, delete each solid layer

One challenge is to determine the thickness of the wall so as to know how deep the cutting extrusion needs to be. An alternative might be to use a plausible oversized estimate of the wall thickness, but then an additional step would be needed to trim off the excess of the cutting object. I can visualize the script traversing the normal from one surface, collecting a list of intersecting objects to be cut, but I don’t yet see something in the API that might work, so this is an area I’m seeking advice. In the case of a wall composed of solids, after the boolean difference, the normal would again need to be traversed but this time intersecting objects would be deleted.

===================================
1/1/2023

After some tinkering with MoI's API here’s the script that I came up with to solve the problem I described above.

CutWalls is primarily intended for cutting windows and doors in the walls of architectural models. It can optionally create a solid frame and a surface to represent a pane of glass, either of which may be named.

Windows to be cut are expected to be represented by closed, planar curves located on one of the wall's surfaces. Because of MoI’s flexibility the script can be used on more than architectural models. Potential ideas might include different shapes of windows or curves set on on angle to the walls—though this gets a little bizarre.

Walls may be made up of surfaces and/or solids. The FindPts() function seeks to find the thickness of the wall by looking for selected wall (base) objects on either side of the window curve. Probe depth (which defaults to 15 inches) defines how far on either side. If a frame is to be made it will be extruded to this thickness. I was hoping to be able to have the script find the neighboring objects without having to “probe” for them like this, but haven’t figured out a way to do that. I appreciated Peer's suggestion though I wasn’t successful with the dropPoint method…something perhaps for a different script.

In a sense this is a specialized variation on the theme of MoI's Boolean Difference command which served as one of the examples that I used.

===================================
1/6/2023

Some improvements to the logic of finding the wall's thickness and positioning the glass, as well as not inadvertently deleting the names of solids. Also added Pilou's translation to French.

--Larry

EDITED: 8 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:  bemfarmer
10907.2 In reply to 10907.1 
Hi Larry,
Do the windows and doors need headers and cripples and jack or trimmer studs?

- Brian
  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.3 In reply to 10907.2 
Hi Brian,

> Do the windows and doors need headers and cripples and jack or trimmer studs?

No I don't think so. On the other hand, as I was pondering how to approach the script it seemed logical that additional construction or trim details could be future modifications to the script. For now though, the simple openings I illustrated would be sufficient to my needs.

That there is an intersect factory mentioned in the new API documentation makes me wonder if this might be part of what I'm seeking to find the layers of the wall to be cut.

--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.4 In reply to 10907.1 
Hi Larry, it might be simpler if you could work just with solids. Then a boolean difference should automatically do some of the things you're trying to do manually like determine extrusion distance.

If you want to limit the cut to one wall then you could use subset booleans. That's when you have faces selected on the object to be cut in boolean difference. It will only intersect with those faces.

So for example if you have a face sub-selection on a solid like this:



Then when you do a boolean difference you'll get a result like this:


- 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:  pressure (PEER)
10907.5 In reply to 10907.1 
Hi Larry,

Here’s how I’d try to attack the problems of determining wall thickness and selecting the wall components for boolean:

1. Generate line along normal that’s longer than wall is thick
2. Run intersection factory on line and all wall components. See http://moi3d.com/forum/index.php?webtag=MOI&msg=10807.1
3. Use distance function on all pairs of points generated by intersection. Largest value is wall thickness
4. For each point and each wall component do dropPoint and then find distance between original point and dropped point. The pair that is separated by approx 0 distance is associated with the wall component that the original point is on
5. Get face object from dropPoint output
6. Add parent BRep of face object to list of stuff that needs to get booleaned

This might not work for the 2 surfaces case unless the surfaces are joined. It won’t work for the solids cases unless they are separated by a little empty space.

Another route might be the labeling technique that Michael used in selectIntersected http://moi3d.com/forum/index.php?webtag=MOI&msg=8088.5

- 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.6 In reply to 10907.5 
Thanks Michael and Peer,

I wasn't aware of the subset capability in booleans, that does simplify the job indeed. Simply selecting the two surfaces (in the first example case), or the layers of the walls (case 2 & 3), then doing boolean difference with only the curve as the cutting object does produce the cutouts nicely. I was hoping to also get the rudimentary frame (simple surfaces) but maybe I don't really need that.

I am going to continue pondering this script idea though and appreciate Peer’s ideas and pointers…will need some time to digest and experiment though!! The subset boolean has met the initial need on the model I’m currently working on.

—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.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
 

Reply to All Reply to All

 

 
Show messages:  1-20  21-29