MoI discussion forum
MoI discussion forum

Full Version: Boolean stencil?

Show messages: All  1-20

From: Przemas
22 Jul 2019   [#1]
So thx to workaround for Linux users with Nvidia cards last week I've been able to play with MoI... and enjoying it.
I'm especially impressed by Extrude tool. The ability to push/pull patches is awesome. Also it allows to make insets for buttons / various grooves etc easily. But...
Well, you need to slice the geometry beforehand. So to achieve something like this:


I need to create a couple of boxes first, then use those as trim object with keep option turned on, then select and delete them, then join those cutout patches and use Extrude on them. Not difficult , but a bit clunky.











So I've been wondering - can it be scripted/macroed somehow? Or maybe we could get (or is there) boolean stencil tool that would achieve such result?
With it making such insets would be a breeze.

Image Attachments:
booleanstencil_1.jpg  booleanstencil_2.jpg  booleanstencil_3.jpg  booleanstencil_4.jpg 


From: Frenchy Pilou (PILOU)
22 Jul 2019   [#2] In reply to [#1]
You can take a look to my page (sorry in French but...)

http://moiscript.weebly.com/kitbash.html


From: Przemas
22 Jul 2019   [#3] In reply to [#2]
Thx Pilou, but I don't think it's what I've been looking for. It's awesome, but it seems it is a bunch of ready objects that can be used for kitbashing.
What I'm searching is a way to "stencil" intersection of the objects onto one of them. In many apps (Modo for example) it is called "boolean stencil". It is much more general type of tool, allows you to add extra edges / patches onto the object and you can use those for creating insets etc. Another benefit it allows you to work within single solid, you don't get several touching or intersecting ones. If my intention is not clear let me know - I'll try to work out a video.
From: Michael Gibson
22 Jul 2019   [#4] In reply to [#1]
Hi Przemas, so is everything working ok under Wine now with MoI v4 and setting that __GL_MaxFramesAllowed=1 environment variable? Or are there some remaining problems?

re:
> So I've been wondering - can it be scripted/macroed somehow?

It's certainly possible but it can take quite a bit of work to make things like that which have quite a bit of interaction in it.

Maybe an easier workflow would be instead of using trim you could form the needed cutting objects using a boolean with a shrunken base box.

That would go something like this - start with your base shape and intersecting objects:



Shrink down the sides of the base shape using extrude:



Now do a boolean difference with the small boxes as the base and the adjusted base shape as the cutting object. This will form the cutting objects you need like this:



These can now be booleaned against the original base shape:




Or maybe a little simpler would be to draw a rectangle curve and use that as the cutting object to cut the small boxes:



That's probably the fewest steps - one step to draw the rectangle, then second step boolean difference the small boxes with the rectangle, then third step boolean the main box with those.

- Michael

Image Attachments:
Przemas_boolean1.jpg  Przemas_boolean2.jpg  Przemas_boolean3.jpg  Przemas_boolean4.jpg  Przemas_boolean5.jpg 


Message 9436.5 was deleted


From: Michael Gibson
22 Jul 2019   [#6] In reply to [#3]
Hi Przemas,

re:
> What I'm searching is a way to "stencil" intersection of the objects onto one of them.
> In many apps (Modo for example) it is called "boolean stencil". It is much more
> general type of tool, allows you to add extra edges / patches onto the object and you
> can use those for creating insets etc.

In MoI you can use the Trim command to do this, but I thought you already described doing that?

The Trim command cuts the surfaces of an object by an intersecting object, adding extra edges/patches just like you're asking for.

- Michael
From: Przemas
22 Jul 2019   [#7] In reply to [#6]
yeah, but it does not remove the cutout objects automatically and also does not join the cut patches with the source model. I guess it might be scriptable, but I don't know howto achieve it, how can we specify which objects are "source" (the one you cut from) and which are trim objects (the ones that "stencil" on source and which should get deleted after the operation), then finally howto join. Is it doable?
As written above, I know the manual way, but I'd love to streamline things and make workflow smoother :) .
From: Michael Gibson
22 Jul 2019   [#8] In reply to [#7]
Hi Przemas, I'll take a look at adding options for those in the regular Trim command.

But usually NURBS modeling is at its best when you are doing things with profile curves and booleans rather than trying to directly manipulate faces like you would in a polygon modeling program.


> I guess it might be scriptable, but I don't know howto achieve it, how can we specify which
> objects are "source" (the one you cut from) and which are trim objects (the ones that "stencil"
> on source and which should get deleted after the operation), then finally howto join. Is it doable?

Usually these different object categories like "source" vs "stenciil" are specified by separate uses of an object picker. You can see how it's done in the current Trim.js file.


> then finally howto join.

There's an example in the Join.js command.

- Michael
From: Frenchy Pilou (PILOU)
22 Jul 2019   [#9]
Seems this workflow must work: very speedy & simple

A = Big Box
B = Little Boxes

A Boolean Diff by B (Keep objects)
B Boolean Diff by A (Keep objects )

Move A or B as you want as following result wished
A Boolean Diff by B (Don't Keep objects) Of course you can save the Cutting objects inside a library if wanted before last Diff...

A & B are stay "solids" along the process!

And no need to script ;)


From: Przemas
22 Jul 2019   [#10]
I get the manual way Pilou :) . But your input is greatly appreciated.

Check this video - I think it shows how much smoother the workflow is when you have stencil/drill operation. Less clicks, less juggling with geo and so on.

https://vimeo.com/349533300

So I'm not saying achieving similar looking object is not possible, I'm just suggesting what can be done to make the workflow nicer :) .

@Michael: yeah, I totally understand that with NURBS creating your geo with profile curves is usually better way to go. But one thing I've noticed while teaching Rhino is that most folks struggle at first when it comes to thinking about shapes in cross sections and so on.
With MoI you've lowered a barier of entry when it comes to NURBS modeling quite a bit - and it is one of the reasons I often recommend MoI as an alternative :) .
And also the reason I'm thinking about parts of MoI that could be streamlined even further :D (so yeah, expect more ideas - but I'm checking whether someone posted similar ones first :D) . In this case the geo is so simple that IMO there's no need to build profiles, do a multi step booleans etc.

I'll look in to js files - hopefully will be able to figure something out (not a programmer sadly, rather a code tinkerer :D ).
From: Michael Gibson
22 Jul 2019   [#11] In reply to [#7]
Hi Przemas, so for doing a script right now it's easiest to modify the current Trim command script to delete cutting objects and do a join at the end. I've attached a version that does this.

The delete part is from this added line:

code:
	moi.geometryDatabase.removeObjects( cutters );


and the join is from this added part:

code:
	var join_factory = moi.command.createFactory( 'join' );
	join_factory.setInput( 0, newobjs );
	join_factory.commit();



Does that then do the boolean stencil function you want?

- Michael

Attachments:
TrimStencil.zip


From: Frenchy Pilou (PILOU)
22 Jul 2019   [#12] In reply to [#11]
How to use it ? Pess Tab then write TrimStencil makes nothing?...

Must to edit the trim command also ? Or it's 2 different things ?
From: Michael Gibson
22 Jul 2019   [#13] In reply to [#12]
Hi Pilou, the one above is a separate command, I'll see about modifying the regular built in Trim command in a bit.

> Pess Tab then write TrimStencil makes nothing?...

Did you download it, unzip it, and copy it into a commands folder?

- Michael
From: Frenchy Pilou (PILOU)
22 Jul 2019   [#14] In reply to [#13]
< Did you download it, unzip it, and copy it into a commands folder?

Of course yes! :)

Edit : That works now for any reason!
That works as aspected but I don't see difference with my method above / final result...:)

Even it's perturbating if you select the cutting object and ask remove (after the mutual "OK" triming) you stay with just the intersection ! :)

So you must deplace it after the mutual triming!



TrimStencil here with 2 another volumes


It's not evident to have the remove of the cutting object!
We must make a Right Click and not Click on the "OK" button!
(here the extrude function after the TrimStencil)


From: Przemas
23 Jul 2019   [#15]
Thank you Michael, that's it! Is there a guide for scripting / macroing MoI? I'd like to modify it even further to automatically pick remove mode so I wouldn't have to do additional click.
Also when it comes to guides - is there a one that would show how do you add custom buttons? I've done mods for my Rhino and Modo installs and would like to see what can be done with MoI :) .

@Pilou: the result is identical in both cases , both manual and with trimstencil. The difference is in workflow - less clicks and that's what I'm looking for :) .

I'm liking what I see so far. Next time I'd probably try doing a sample project first in Rhino / Modo then in MoI so I could make more educated comparisons.
From: Frenchy Pilou (PILOU)
23 Jul 2019   [#16] In reply to [#15]
The manual method is 9 Clicks include Selection(s) of objects, call function(s), Parameter(s), final result! ;)
From: Michael Gibson
23 Jul 2019   [#17] In reply to [#15]
Hi Przemas,

re:
> Is there a guide for scripting / macroing MoI?

Not really, it unfortunately takes quite a bit of work to do a good job documenting and just generally supporting such things. That's why it hasn't been a big focus area so far.

There is some information here though:
http://moi3d.com/wiki/Scripting


> Also when it comes to guides - is there a one that would show how do you add custom buttons?

Not really, but if you're familiar at all with HTML it's pretty straightforward. You can see how the current UI is set up by opening up files like CommandBar.htm and SidePane.htm inside MoI's ui subfolder. You'll then see how buttons are set up as <moi:CommandButton> tags and you can add new ones in.

Is everything working ok under Wine now for you with __GL_MaxFramesAllowed=1 or are there still any problems when changing window size?

- Michael
From: Przemas
23 Jul 2019   [#18]
@Pilou: trimstencil is 5, so less -> that's a win :P . It get's even better in more complex situations (more objects for example). And note I'm not trying to force anyone to use a given method - quite the contrary, I fully understand often there are multiple ways to reach the solution. I simply tend to look for one that requires least amount of steps :) .

@Michael: thank you for the links. For sure will start tinkering in the weekend :) . Html should make it easy to do customization - glad to hear it works this way.

As for __GL_MaxFramesAllowed=1 - so far I haven't encountered any issues with the trial version. Tried in KDE and Gnome. No issues at all (fingers crossed) - really feels like a native app.
Atm I have some hope to try packaging the prepped version into Appimage. Should work a treat.
With MoI V4 and DXVK it should be even better :) (once it is released).
From: Frenchy Pilou (PILOU)
23 Jul 2019   [#19] In reply to [#18]
So you win... and we have won also a new command! ;) Thx to Michael for that!

And put it on my French site! ;) http://moiscript.weebly.com/trimstencil.html
(curiously i don't need to make a French translation...


From: TOM (SIRTOM)
29 Jul 2019   [#20]
Wow, thats a great new tool - thank you also from my side, Michael !

Show messages: All  1-20