I asked ChatGPT for a gh component for attractors

It wrote the script for the Python component in 10 seconds. Can be used with several points.

"""
GhPython component: Attractor Points Filter

Inputs:
    Pts      : List of points
    AttrPts  : List of attractor points
    Strength : Maximum distance to keep

Outputs:
    OutPts   : Filtered unique points
    OutDist  : Averaged distances
    OutIdx   : Indices in original list
"""

import Rhino

# Prepare outputs
OutPts = []
OutDist = []
OutIdx = []

# Validate inputs (but no return!)
if not Pts or not AttrPts or Strength is None:
    pass
else:

    # Dictionary mapping:
    # point index => list of distances to attractors (within Strength)
    dist_dict = {}

    for ai, a in enumerate(AttrPts):
        if a is None: 
            continue
        for pi, p in enumerate(Pts):
            if p is None:
                continue

            d = p.DistanceTo(a)

            # Keep only points closer than Strength
            if d <= Strength:
                if pi not in dist_dict:
                    dist_dict[pi] = []
                dist_dict[pi].append(d)

    # If dictionary is non-empty, merge results
    if dist_dict:
        for pi in sorted(dist_dict.keys()):
            d_list = dist_dict[pi]
            avg_d = sum(d_list) / float(len(d_list))

            OutPts.append(Pts[pi])
            OutDist.append(avg_d)
            OutIdx.append(pi)

251120 ChatGPT Attractors.3dm (2.6 MB)
251120 ChatGPT Attractors.gh (19.8 KB)

So you didn’t write anything in 10 seconds? :joy:

2 Likes

This is a slippery slope.

1 Like

3 Likes

To use curves as attractors with the same component, simply divide them into points.

Please be my guest and write it better, thank you!

@TomTom ,
Drop some knowledge just write the code! :laughing:

I think we both are old enough to know that there is no point if I write code here… I’m sorry that I hurt your ego, this was not my intention. I sometimes just wonder what the point is of posting this in the first place, if there no acceptance for critical comments. It was meant to be constructive, but maybe the way I wrote was already insulting. Nevermind

3 Likes

I find the chatgpts are much better at explaining things than actually automatically generating the code. Then using the knowledge gained to progressively build your idea and skill sets. Great learning tools, not so great at generating the proper workflow in a complex environment.

2 Likes

Here’s another usecase using the same custom component and Replace Items.

@Japhy Grasshopper always has been good for fast prototyping. Quickly generating code with ChatGPT follows the same principle. Do something fast, see if it works, then optimize if necessary.


1 Like

Apologies for earlier meme ambiguity.

As the author of a topic, I’d be curious to find out why my post wasn’t immediately well received when the intention is to share knowledge?

Play/talk with caution?

You’re in a forum inhabited by seasoned folks who have built legitimate knowledge/methodology. Several of them might have been stewards of the ‘computational design education’ movement prior to AI use.

Their solid foundation allows them to distinguish when/why an add-on or other helps are needed.

I was told by some ‘code gurus’ before:

“Never present the tool as the accomplishment”

“Don’t show a masterpiece undone”

Computers are wild! The moment a critic asks to demonstrate knowledge ‘live and from scratch’, the built illusion can fall apart rapidly.

Inset has been recently exposed as a Rhino.Geometry.Brep method.
Here’s another attractor recipe using it:

The code for Py3 InsetBrep is here:

Inset is most often used in architecture for fast drawing window frames and curtain walls, so I really like this update. Thanks McNeel devs!