MOving objects and sticky connections between them-can it be done with Ruby?

Okay, you’re a programmer with OOP experience, so you should pick up Ruby quite quickly, as long long as you don’t expect Ruby to share some of Python’s quirks, … (ie, forced indentation blocks, … no end keywords, automatic modules having the filename’s name, etc.)

Okay then … but … keep in mind …

SketchUp does not have true geometric layers (so deal with that.)
Does not have “lines”, it has 0 width edges (so you’d need to use edge style likely to give substance to the “connectors”.)
Does not have “sticky” connections (you’d have to fake it by assigning an attribute to an edge object that holds the persistent id of a component instance that it terminates to.)

It can be reactionary using observer(s). It is likely that moving any component instance will trigger the #onChangeEntity observer callback. In this, you can start a timer (allowing the current callback queue to finish,) then popup a messagebox asking to redraw the “connections”.

Doesn’t matter much as the “redraw” code would be in a common method called in both scenarios.
The drawing will need to leverage some factory methods of the Sketchup::Entities class.
To find objects you’ll need to learn to iterate this collection class using it’s iterator methods, and/or those mixed in from Ruby core’s Enumerable module (most especially the grep method.)
Also have posted examples here …

To get center points you’ll need to use the Geom::BoundingBox class, returned by Drawingelement#bounds.

To move things around geometrically you’ll need to understand transformations.

To “tag” objects with data, you’ll attach and use an AttributeDictionary. Dictionaries are shared space objects, so they need to be uniquely named. I suggest the same qualification as the extension’s module nesting, but with the :: scope operator replaced with underscore …

dictname = Module::nesting[0].name.gsub(/(::)/,'_')

From within a module nested as … CompanyX::NiftyWidget
the dictionary name string would be "CompanyX_NiftyWidget"


There is no magic wand I can wave and grant you the knowledge and ability.
You’ll just have to spend a week or two reading and studying extension examples.

I compiled a list of Ruby Learning links here in this forum …

There are several examples of tools by the SketchUp Team in the Extension Warehouse.

This one is a must read:

There are also others … Window Maker, Bezier Curve Tool, Rotate Rectangle Tool, etc.

Check out their extensions listing: Page Not Found | SketchUp Extension Warehouse