Grasshopper

algorithmic modeling for Rhino

For Python's unique node in code feature, so many components now have little banners at the bottom that allow right-click options to be set. For instance, CullDuplicates (CullPt):

CullDuplicates works in Python:

...and if I print ghc.CullDuplicates(curve_points) I see the actual names of the outputs in the Python editor:

...so I can either do:

a,b,c = ghc.CullDuplicates(curve_points)

...or:

a = ghc.CullDuplicates(curve_points)[0]

b = ghc.CullDuplicates(curve_points)[1]

c = ghc.CullDuplicates(curve_points)[2]

...or even:

a = ghc.CullDuplicates(curve_points).points

b = ghc.CullDuplicates(curve_points).indices

c = ghc.CullDuplicates(curve_points).valence

And multiple inputs are just separated by commas within the parenthesis.

But the component is defaulting to Average instead of Leave One, which doesn't give me much useful. I'm trying to remove duplicate lines quickly, of 25K lines, and this is the fastest component in Grasshopper I've found to do that, by finding the line midpoint then getting the indices output from CullDuplicates to find out which are keepers.

There's no documentation about what Average even means, and it spits out a bunch of -1s, with the resulting lines culled by index of the good numbers being rather odd compared to Leave One, which just works naturally, like a human being would want it to.

Is it possible to change the component mode from Average to Leave One from Python?

Rhinocommon seems to lack a cull duplicate lines/curves command, so I'm hoping Grasshopper components will be faster than raw interpreted (uncompiled) Python.

Views: 1482

Replies to This Discussion

Well ... this is a "bit" off-topic (C#) but give the good old HashSet a spin.

How it works:

1. Creates some random duplicate Lines (Tree).

2. Makes a chaos List out of 1.

3. Does the unique thingy.

Attachments:

Exactly on topic, given the bad node-in-code Python news.

I'll have to study it in detail. Great big clue for a good strategy.

Alas, it is only partially effective, leaving thousands of duplicates still that the Rhino Select Duplicate Objects (SelDup) command finds just fine, as does a little Grasshopper script, possibly due to line direction?:

Can you add the reverse lines too, to the unique line table?

That the very basic removal of duplicate lines isn't in Rhinocommon is just ridiculous. I can hack together a script but must study for days to get one that isn't ruinously slow.

I had thought of hash use, of converting objects to a single value, but forgot the term "hash," only remembering "checksum," and hadn't pursued it.

Attachments:

Hmm ... reversed Lines eh?

You are a tough client > therefor > I'll charge you extra for that: more sardine(*) cans, what else?

(*) Da Morgada, what else?

PS: If the sardines arrive in good shape >  V3 MAY do some business via parallel stuff using the HocusPocusParallelus (TM)(C) method.

Attachments:

Not there yet. Rhino and Grasshopper find thousands more duplicates:



Ah, let me feed your test lines into my Grasshopper cluster. They now give the same result, for *your* line collection. There's something odd about my specific groups of lines that Rhino or Grasshopper (via midpoints) can handle but your script ignores? I did internalize the data. I'd appreciate if you can spot the difference that eludes me.

Attachments:

I'll investigate that one ASAP (but since // stuff is Très à la mode > in the meantime prepare the sardines (in pure mineral oil)).

NOTE: the only case where the V2 fails is when it deals with max chord Lines in a sphere and the likes ... but who on Earth could think of that? (you I suspect). But ... wait a minute: what about @#%$@ tolerance matters? (when a mid point ... er ... is "not" the same midpoint).

Moral: life sucks.

more soon

Other than that "minor" tolerance thingy ... did the hashset way improved the processing time? If yes how much?

Obviously I could do it the "orthodox" way (I have a variety of C# for that) ... but the effort here is for something fast and furious.

OK, I have good and bad news:

Good:

Bad:

This V2A required several lines of code more (about 3) and thus due to the tremendous effort ... blah, blah ... I consider raising my fee by a margin of 666% (give or take a few hundreds ).

I hear you: but you've just added 3 f#%#$g lines: Yes but it's the quality that matters (and greed).

Send the Da Morgada hot stuff ASAP to: The Lord, District 9, North Pole.

Attachments:

Thanks! A rounding factor to the rescue. I had figured that out last night too and am glad it's acceptable practice.

Isn't mineral oil a laxative bug instead of a luxury feature?

"In the Dominican collection, was there not to be found a certain Doctor of Theology, Révérend Père Rouard de Card, a Preaching Brother, who in a brochure entitled:-”Of the Falsification of the Sacramental Substances,” has demonstrated beyond a doubt that the major part of Masses were null and void, by reason of the fact that the materials used in the rite were sophisticated by dealers? For years, the holy oil had been adulterated with goose-grease; the taper-wax with burnt bones; the incense with common resin and old benzoin. But worse than all, the substances indispensable for the holy sacrifice, the two things without which no oblation was possible, had likewise been falsified, – the wine by repeated dilutings and the illicit addition of Pernambuco barc, elder-berries, alcohol, alum, salicylate, litharge; the bread, that bread of the Eucarist that must be kneaded of the fine flour of wheat, by ground haricot-beans, potash and pipeclay! Nay, now they had gone further yet; they had dared to suppress the wheat altogether and shameless dealers manufactured out of potato meal nearly all the hosts! Now God declined to come down and be made flesh in potato flour." – J. K. Huysmans (“Against the Grain” 1883)

Well ... I confess that I seriously consider quitting Architecture and do some proper goat business.

Therefor it's possible (and maybe desirable) to swap sardines with goats.

Here's me -unmasked- BETA testing (better safe than sorry) the whole concept.

Oops forgot to change the name (2d C# if you need to shuffle stuff for some other case of yours).

If I manually create all lines with their own reverse, even twice, to feed in real duplicates of each line to work with, no dice, the C# is now doubly unhappy rather than fulfilled:

Attachments:

Hi Nik,

Currently all node in code python functions only work in its default mode (so right-click-on-component-modes can not be changed).
I think Giulio might be able to answer whether or not this will change once public version of Rhino 6 gets released.

RSS

About

Translate

Search

Photos

  • Add Photos
  • View All

Videos

  • Add Videos
  • View All

© 2024   Created by Scott Davidson.   Powered by

Badges  |  Report an Issue  |  Terms of Service