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