Full Version: Planar Holes Finder : a script for 2D workflows!

From: mkdm [#2]
 24 Oct
To: ALL

Hi everyone!

...last demo video for Non-planar curves !

Watch it at : http://take.ms/6HpTD

This is the 3dm file : http://take.ms/piqKM

This is the screenshot :





Ciao!

Reply


From: Karsten (KMRQUS) [#3]
 25 Oct
To: ALL

Hello Marco,

very interesting script. Maybe it can be pimped to a lasso selection.

Have a nice day
Karsten

Reply


From: mkdm [#4]
 25 Oct
To: ALL

Hi Kartseen.

@You "...very interesting script. Maybe it can be pimped to a lasso selection..."

Yes! While writing this script I thought so too :)

Lasso selection...the "missed" thing! LOL :)

As I said this is the very first 0.1 version of the script but if you want to share your skill with me and us,
please feel free to get this script and improve it with your experimentation and ideas !

I'm not "jealous" about my scripts/commands :)

I have in mind some optimization and or improvements for this script but it could be very interesting
if you want to share what you are thinking about this script.

As a final note I can tell you that "PlanarHolesFinder" will be also very very useful in bundle with the other script that I hope to complete soon,
that is "FilterCurveByLenght".

You will see.

It's another very interesting commands very useful for 2D workflows.

Stay tuned.

We'll catch up.

Ciao!

Reply


From: mkdm [#5]
 25 Oct
To: ALL

Hi everyone.

P.S LOL! LOL!

I think I made a big "mathematical" error in my very first post :)

I have reported a wrong number of total control points.

This is the correct values :

In both files I replicated a "block" composed of 9 planar curves for a total of 179 control points.

1) Scene 1
400 "blocks" for a total of 3600 planar curves and an total of 71600 control points (NOT 286400)

Total elaboration time : about 6 secs THIS WAS ALREADY CORRECT

2) Scene 2
1600 "blocks" for a total of 14400 planar curves and an total of 286400 control points (NOT 2577600)

Total elaboration time : about 23 secs THIS WAS ALREADY CORRECT

Ciao!

Reply


From: mkdm [#6]
 25 Oct
To: ALL

Hi!

Hmm...I think I should rename this script.

...maybe "PlanarHolesFinder" is not the correct name...

Reply


From: mkdm [#7]
 25 Oct
To: ALL

Hi Michael.

WOW!!

I've just found out that my knowledge of Moi is very weak! LOL LOL :)

I discovered that this sentence was totally wrong :

"THE SCRIPT IS A LITTLE BIT LIMITED FOR THE MOMENT BECAUSE ONLY THE PROJECTION ON THE TOP PLANE IS TAKEN INTO ACCOUNT."

Please watch this video : http://take.ms/AF6Rq

IT WORKS ALSO FROM THE OTHER VIEWS!!!

But...if I rotate the "container" curve to a given angle, one of the possible "holes" is not taken into account...

This it the 3dm file : http://take.ms/3Ryb1



Evidently I don't know very well the internal mechanism of "Project" command :)

Could you help me about this point ?

Thanks a lot.

I repeat...I think I should rename the script :)

Ciao!

Reply


From: Michael Gibson [#8]
 25 Oct
To: ALL

Hi Marco, did you say you were using "closest point" mode for the projection? That mode works by calculating the closest point from a location on the curve to the surface and so it's not dependent on a single direction. It doesn't work too well with curvy surfaces when the curve isn't right near the surface though.

- Michael

Reply


From: mkdm [#9]
 25 Oct
To: ALL

Yes Michael!

I'm using "closest point" method because I thought it was the easiest one.

For this very first version of the script I wanted to minimize the "inputs" so I've used the most simplified version of "Project" :

code:
		factory = moi.command.createFactory('project');
		factory.setInput(0, projectInput);
		factory.setInput(1, projectTarget);
		factory.setInput(2, 'closestpt');
		
		projectResult = factory.calculate();


But...I didn't understand very well this part of the sentence :

@You : "It doesn't work too well with curvy surfaces when the curve isn't right near the surface though."

Thanks.

Reply


From: mkdm [#10]
 25 Oct
To: ALL

Hi everyone.

I'm working on a tweaked version of the script to make it more friendly for a strict "Lasso" selection...

It will be sufficient to draw the "Lasso" and select it. Then fire the script.

And...voilá!

I have to add the code that should automatically remove the "lasso" at the end of execution if something has been found.

N.B. Keep in mind the same considerations of my previous posts. It uses the "project" command with "closes pt".
Then all the previous considerations can be applied also to this "modified" implementation I'm working on for the "Lasso"

For the moment this is a demo video : http://take.ms/9x0Yx

This is a screenshot :




Ciao!

Reply


From: Mik (MIKULAS) [#11]
 25 Oct
To: ALL

Excellent script Marco!
Lasso selection for closed curves is perfetto!

Thanks a lot, I missed this command quite often. Maybe it would useful to combine this script with "SelectInetrescted" script which works as a lasso selection for solids, then "Lasso selection" script could be universal.

Ciao
Mik

Attachments:
SelectIntersected.zip

Reply


From: mkdm [#12]
 25 Oct
To: ALL

Ciao Mik!

Thanks a lot for your appreciation! Thanks!

Your idea to combine this script with your "SelectInetrescted" it's a great idea!

I hope soon, maybe tonight, to release the 0.2 version of "PlanarHolesFinder" and also the special modified version "LassoSelCurves"
and the in the next days I will study "SelectInetrescted" to see what can I do to combine both!

It could be a great thing having these kind of scripts combined, but also in the case it will be too complex,
with the very fast workflow of Moi's shortcut we can always fire commands/scripts at the speed of light :)

My intention is to create a little set of very specialized script especially dedicated to 2D Workflows,
and "PlanarHolesFinder"/"LassoSelCurves" are just the first,
but...at the moment it's best for me not make too many plans :)

Stay tuned!


Ciao!

Marco (mkdm)

Reply


From: Michael Gibson [#13]
 25 Oct
To: ALL

Hi Marco,

> But...I didn't understand very well this part of the sentence :
>
> @You : "It doesn't work too well with curvy surfaces when the curve isn't right near the surface though."

If you have a curvy surface instead of a flat surface, this type of projection down by surface normal will make the projected result squish together or expand and the Solids++ routine for this function doesn't deal very well with that, it tends to produce a curve with little zig-zags in it. If the curve is pretty close to a wavy surface it can work ok though.

But I need to make a new implementation for it at some point here since it can give bad results.

- Michael

Reply


From: mkdm [#14]
 26 Oct
To: ALL

Hi Michael.

Ok. Understood.

@You : "...If you have a curvy surface instead of a flat surface..."
But...the problem is that I never have Non-flat surface.
The surface that I use with as the target for "Project" is always flat, but there are some situation where it fails anyway.

Strange thing...

You can watch again my previous post and the video posted at (http://moi3d.com/forum/index.php?webtag=MOI&msg=8646.7)

This is the video : http://take.ms/AF6Rq

As you can see at position 01:58 I use the Circle as reference to find holes in it.
The circle if is simply rotated but is FLAT.
And as you can see the blue curve is not considered "hole". Is not "captured" by the "Project" command.


I stay tuned.

Thanks.

Reply


From: mkdm [#15]
 26 Oct
To: ALL

...maybe I should switch to "Direction" mode for the "Project" command.

But I wanted to use "ClosestPt" because it's more easy and requires less interaction with the user, less inputs from him.

I think if I switch to "Direction" for "Project", if I want to keep the code simple at least for this first upcoming official release of the script,
my command will work only for Top Plane.

Instead using "ClosestPt" I've seen that it works also for all standard planes (right, left....)

I don't know.

Also I'm writing this script to be placed in "Scripts" folder, non in "Commands" because I don't want for it any UI.
Just fire a shortcut and run it, both Lasso and "FindHoles" variants.

What do you think ?

Thanks.

Reply


From: Michael Gibson [#16]
 26 Oct
To: ALL

Hi Marco, yes it sounds like the "closest point" mode for project isn't reliable enough for you, the direction mode should work better. Or another possibility could be the steps that I mentioned earlier - determine if any curves intersect the outer boundary (use the "intersect" factory from the Construct > Curve > Isect command and see if it generates any result), remove those then send the rest to planarsrf to generate loops. Use the hole loops to identify the curves they came from by seeing if any start/end points match between the curve segments and the hole edges.

- Michael

Reply


From: mkdm [#17]
 26 Oct
To: ALL

Hi Michael.

Thanks a lot for the suggestion.

But...I think that the method you mentioned is not right for me.

Because this part of the sentence " if any start/end points match between the curve segments and the hole edges" it's too restrictive.
I could have more than one curve that shares the same start/end point but with different shapes.

For example :



Furthermore also this part of the sentence is not what I want to do : "...remove those then send the rest to planarsrf to generate loops."

Because I want to use my script to find not only "totally enclosed curves" but also "partially enclosed", that is the curves that intersect the boundary of
the "container".


I really don't know.

Maybe for the moment I can continue to use "Project" with "ClosestPt" and for the moment not to take into account the rare cases where it fails .

Or I can decide to witch to "Direction" mode and for the moment restrict the scope of my scripts to "TOP plane only", that also was the original idea.

I don't know.

Have you got a final suggestion to give me about these considerations ?

Thanks a lot :)

Marco (mkdm)

Reply


From: Michael Gibson [#18]
 26 Oct
To: ALL

Hi Marco, my suggestion for the shared point case you show there would be to not consider that to be a hole, that will be malformed geometry if you try to actually create a hole like that where a hole boundary intersects with the outer boundary. Boundaries should not be self intersecting and outer/inner boundaries should not intersect with each other. If they do then there become areas of a trimmed surface where the inside and outside regions of the surface are not well defined.

For the other part you mention:

> Furthermore also this part of the sentence is not what I want to do : "...remove those then send the rest to planarsrf to generate loops."
>
> Because I want to use my script to find not only "totally enclosed curves" but also "partially enclosed", that is the curves
> that intersect the boundary of the "container".

Ok, then instead of removing the intersected curves from consideration just put them also into the "captured" list but don't send them over to planarsrf.

But another problem is it sounds like you're not just looking for "holes" anymore, to make a "hole" it has to be a closed curve.

- Michael

Reply


From: Michael Gibson [#19]
 26 Oct
To: ALL

Hi Marco, also for direction I think you should be able to automatically figure out a projection direction by getting the bounding box of your containment curve and then seeing which direction has a zero extent.

- Michael

Reply


From: mkdm [#20]
 26 Oct
To: ALL

@You : "...But another problem is it sounds like you're not just looking for "holes" anymore, to make a "hole" it has to be a closed curve..."

You're right Michael :)

The fact is that I wanted initially to start a script for "2D workflows" not for "solids" or "solids boolean" stuff.

My script does this main things :

1) Capture all curves that can be considered "holes" of another flat curve.
I know that this part of the sentence was not very clear.
When Is said "Hole" I wanted to say : closed curves that, when projected, are totally enclosed into the "planar surface" created using the"container" curve.

2) During my coding I also wanted to add capabilities to capture also other situations.
So, now I'm coding my script to be fired in 3 different ways :

A) Capture all "totally enclosed" in "container curve"
B) Capture all "partially enclosed" in "container curve", that is the curves that when projected they intersect the boundary of the "container"
3) Capture both of them

But...during the coding and also during the various experiments and tests popped into my mind that the scripts also could works with
other planes, not only TOP plane, and I started to face with the problem of "Direction" vs "ClosestPt."


Now I try to switch to "Direction" mode and leave the script with the minimum interaction with the user,
assuming that the direction in forced to TOP plane.

Later, when the first official version of the script will be tested by other users, I will try to make it more complex.


I'm also writing the variant for a quick "Lasso" selection !

Thanks for all your help :)

I think I need some suggestion for using the "Project" factory with "Direction", but I want first to try.

We'll catch up!

Ciao!

Marco (mkdm)

Reply


From: Michael Gibson [#21]
 26 Oct
To: ALL

Hi Marco, we might have been writing posts at the same time so make sure not to miss my additional message above about how to automatically determine the projection direction.

Also another thing you might be able to use for containment detection is Construct > Curve > Isect - if you build a planarsrf with your main boundary you could then run intersect on other curves and it will return points if the curve is on the face.

- Michael

Reply


Show messages:  1  2-21  22-27

Reply to All

Back to thread list | Login

© 2017 Project Beehive Forum