[Plugin] Reglue
-
I also feel the need to have multiple components reglued. I'm used to using Superglue for that but Tig's Reglue works much better.
So, Tig, are you thinking of adapting your own script to any of the above methods?
If not, I think I'll use Tommy's from now on...
Thank you guys!
-
TIG, Is it possible to enable multiple components (implemented above by TommyK) re-glueing to multiple faces please?
-
An instance can only glue to one face.
It's a limitation within SketchUp, not the API. -
Does this API the Great and Powerful, allows to select all the components glued to a preselected face? If yes, maybe the script could take one face, select all the glued and reglue; then go to another face, repeat reglueing, and so on?
-
Maybe Fredotools Move along could be helpful?
-
@rv1974 said:
Does this API the Great and Powerful, allows to select all the components glued to a preselected face? If yes, maybe the script could take one face, select all the glued and reglue; then go to another face, repeat reglueing, and so on?
ToomyK's version a few posts back does that.
Just replace the text in the RB file with his alternative and save it.
Use a plain-text editor like Notepad++ to do the editing. -
How is the code to determine which of the selected components gets glued to which selected face ?
Please outline the 'logic'... -
@tig said:
@rv1974 said:
Does this API the Great and Powerful, allows to select all the components glued to a preselected face? If yes, maybe the script could take one face, select all the glued and reglue; then go to another face, repeat reglueing, and so on?
ToomyK's version a few posts back does that.
Just replace the text in the RB file with his alternative and save it.
Use a plain-text editor like Notepad++ to do the editing.No, TommyK's code works only with one face.
@Pixero, the connection between MoveAlong and reglueing slips away from me. -
@tig said:
How is the code to determine which of the selected components gets glued to which selected face ?
Please outline the 'logic'...Thats what I tried to ask you earlier- Whether API allows to detect the components glued to a preselected face. IF the answer is YES, then MAYBE the script could(?) progressevly take face by face and reglue corresponding components.
-
@rv1974
I did this but it’s small script. Select face and components for 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
Advertisement