[Plugin] ReGlue
-
There is a method:
glued = face.get_glued_instances
And it'd be easy to grep then iterate all of the faces and their glued components etc...
BUT there's no API '.could_be_glued_instances
' method...BUT here's some possible [pretty much untested] code which might just do it...
ctr=0 model=Sketchup.active_model faces=model.active_entities.grep(Sketchup;;Face) comps=model.active_entities.grep(Sketchup;;ComponentInstance).find_all{|e| e.definition.behavior.is2d? && ! e.glued_to } ### collect if comp can glue, but not glued ! cct=comps.length faces.each{|f| plane=f.plane norm =f.normal comps.dup.each{|e| pt=e.transformation.origin nm=e.transformation.zaxis if pt.distance_to_plane(plane)==0 && norm==nm ### glue-able cp=f.classify_point(pt) if cp==Sketchup;;Face;;PointInside || cp==Sketchup;;Face;;PointOnEdge || cp==Sketchup;;Face;;PointOnVertex ### on face so can glue e.glued_to=f comps.delete(e) ctr+=1 ### reduce tested comps collection for speed end end } } puts "\n\nReglued #{ctr} of #{cct}" ### print how many reglued
-
@TIG This plugin reglues multiple components in SU 2022. In v2023 and newer it reglues only one component.
What is the reason for this degradation? Thanks
-
This plugin is over a decade old !
As far as I recall, and tell from the code and version, it has always needed a selection of one face and one component to work. for 19 years.
Although I do see from my posts do speaks of one or more components being processed...As far as I can see this old code is very simplistic... e.g.
It does not check for gluing properties, or face-normal, or Z-axis, or position on the face.plane, or transformation.origin point on the face at all.
If it checked for several components being on the face and sharing the face.normal as their Z-axis etc, then it would be possible the get it to process several gluing components. However, this would require a complete rewrite...
I'll back check...
-
Here's v2.0 in the PluginStore...
https://sketchucation.com/pluginstore?pln=Re_Glue
It now allows multiple pre selected component-instances, but still only one preselected face.
These are glued to the face [is possible], any errors or unsuitable instances are reported in the Ruby Console... -
@TIG Many thanks!
Advertisement