[Plugin] Reglue

[Plugin] Reglue

Postby TIG » Sun Aug 21, 2011 3:43 pm

There are several 'reglue' plugins around [there's even one within my HolePunch tool menu!]
However, I wrote this one a couple of years back and Jim spotted it wasn't 'indexed' - so here it is...

Download

3
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Reglue

Postby utiler » Mon Aug 22, 2011 12:20 am

80 views and no thanks.....mmmm. :oops:

Thanks TIG for all you do. :thumb:
1
purpose/expression/purpose/....
User avatar
utiler 
Top SketchUcator
 

Re: [Plugin] Reglue

Postby Edson » Mon Aug 22, 2011 9:25 pm

tig,

I apologize for the dumb question, but what exactly does it do?
1
edson mahfuz, architect | porto alegre • brasil
http://www.mahfuz.arq.br
User avatar
Edson 
Global Moderator
 

Re: [Plugin] Reglue

Postby TIG » Mon Aug 22, 2011 10:18 pm

:?
If you have a face with some components glued onto it that are cutting holes, and you accidentally erase that face, then the face is easily replaced by over-drawing an edge etc... BUT the components will still remember that they were glued to the earlier face - and because that's now been erased they'll no longer cut openings at all.
You need to place all new versions of the components, which can be a pain in the butt
OR you can use a re-glue tool, which lets you select the face and one or more components that should be glued onto it. The selected components are then re-glued to that face, and once again they will cut openings as they used to...
:enlight:
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Reglue

Postby Edson » Tue Aug 23, 2011 11:54 am

thanks for taking the time to answer me, tig. it is understood now. one more useful plugin from you.
1
edson mahfuz, architect | porto alegre • brasil
http://www.mahfuz.arq.br
User avatar
Edson 
Global Moderator
 

Re: [Plugin] Reglue

Postby archman212 » Wed Oct 12, 2011 3:34 am

thank you for sharing this plugin..very useful.
0
User avatar
archman212 
 

Re: [Plugin] Reglue

Postby TIG » Thu Dec 12, 2013 10:34 pm

Here's a new future-proofed update.
viewtopic.php?p=349699#p349699
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Reglue

Postby TommyK » Thu Jan 16, 2014 8:03 pm

There are times when I would like to select several components and reglue them to a face with one "ReGlue" operation. I have modified TIG's code a little to allow multiple selections of components. Hope you don't mind, TIG. The code is below, and not tested that much....

Code: Select all
#-----------------------------------------------------------------------
# Copyright 2006-2013, TIG
# Permission to use, copy, modify, and distribute this software for
# any purpose and without fee is hereby granted, provided the above
# copyright notice appear in all copies.
# THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
# IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#-----------------------------------------------------------------------
# Name: ReGlue
# Description: A Tool to ReGlue a Component to a [recreated] Face.         
# Menu Item: Plugins -> ReGlue
# Author: TIG
# Usage: Select ONE Face and ONE [or MORE] UnGlued Component[s].
# Use with care - because by picking a Component and an
# unconnected Face you can 'UnGlue' it and 'ReGlue' it
# onto this new Face even if it's not actually on the same
# plane or at the same rotation !
# Version:   1.0   27/12/06   First issue.
# 1.1 20131210 Future-proofed
#-----------------------------------------------------------------------
require('sketchup.rb')
module TIG
module TIG::ReGlue

def self.do()
 
  model=Sketchup.active_model
  model.start_operation("ReGlue")
  ss=model.selection
 
 def self.status(txt)
  Sketchup::set_status_text(txt, SB_PROMPT)
  Sketchup::set_status_text(" ", SB_VCB_LABEL)
  Sketchup::set_status_text(" ", SB_VCB_VALUE)
 end#def status
 
 def self.error(txt)
  self.status("REGLUE: ERROR...")
  UI.messagebox(txt)
  return nil
 end#def error
 
   return self.error("ReGlue:\nNO Selection !") if ss.empty?

   faces=ss.grep(Sketchup::Face)
   comps=ss.grep(Sketchup::ComponentInstance)

   return self.error("ReGlue:\nSelection MUST contain ONE Face !") if faces.length==0 || faces[1]
   return self.error("ReGlue:\nSelection MUST contain ONE Component !") if comps.length==0
   
   
   face=faces[0]
   
   #Do for each component
   i = 0
   while defined? comps[i] do
     comp=comps[i]
     return nil unless comp && face

     comp.glued_to = face
     i = i + 1
   end#while
   model.commit_operation
 
end#def

#-----------------------------------------------------------------------
unless file_loaded?(__FILE__)###
  UI.menu("Plugins").add_item("ReGlue"){self.do()}
end
file_loaded(__FILE__)###
#-----------------------------------------------------------------------

end#module
end#TIG
0
User avatar
TommyK 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Reglue

Postby kaas » Fri Oct 14, 2016 10:56 am

nice little gem TIG. Saves a lot of repetitive stupid work. :thumb:

Just as TommyK I changed it to a multiple reglue by
comps.each{|c|c.glued_to = face}
and uncommenting the
#return self.error("ReGlue:\nSelection MUST contain ONE Component !") if comps.length==0 || comps[1]
#comp=comps[0]
#comp.glued_to = face
0

kaas 
 

Re: [Plugin] Reglue

Postby JQL » Fri Oct 14, 2016 3:54 pm

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!
0
User avatar
JQL 
Premium Member
Premium Member
 

Re: [Plugin] Reglue

Postby rv1974 » Wed Mar 13, 2019 9:59 am

TIG, Is it possible to enable multiple components (implemented above by TommyK) re-glueing to multiple faces please?
0

rv1974 
 

Re: [Plugin] Reglue

Postby TIG » Wed Mar 13, 2019 12:26 pm

An instance can only glue to one face.
It's a limitation within SketchUp, not the API.
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Reglue

Postby rv1974 » Wed Mar 13, 2019 1:10 pm

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?
0

rv1974 
 

Re: [Plugin] Reglue

Postby Pixero » Wed Mar 13, 2019 2:04 pm

Maybe Fredotools Move along could be helpful?
0
User avatar
Pixero 
 

Re: [Plugin] Reglue

Postby TIG » Wed Mar 13, 2019 2:08 pm

rv1974 wrote: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.
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Reglue

Postby rv1974 » Wed Mar 13, 2019 2:30 pm

TIG wrote:
rv1974 wrote: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.
0
Last edited by rv1974 on Wed Mar 13, 2019 2:37 pm, edited 1 time in total.

rv1974 
 

Re: [Plugin] Reglue

Postby TIG » Wed Mar 13, 2019 2:32 pm

How is the code to determine which of the selected components gets glued to which selected face ?
Please outline the 'logic'...
0
TIG
User avatar
TIG 
Global Moderator
 

Re: [Plugin] Reglue

Postby rv1974 » Wed Mar 13, 2019 2:43 pm

TIG wrote: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.
0

rv1974 
 

Re: [Plugin] Reglue

Postby hdpv » Wed Mar 13, 2019 4:05 pm

@rv1974
I did this but it’s small script. Select face and components for reglue.
0
User avatar
hdpv 
PluginStore Author
PluginStore Author
 

Re: [Plugin] Reglue

Postby rv1974 » Wed Mar 13, 2019 4:21 pm

hdpv wrote:@rv1974
I did this but it’s small script. Select face and components for reglue.

and components? or face only?
0

rv1974 
 

Re: [Plugin] Reglue

Postby TIG » Wed Mar 13, 2019 5:39 pm

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...
Code: Select all
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
1
TIG
User avatar
TIG 
Global Moderator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 



 

Return to Plugins

Who is online

Users browsing this forum: johnmoon and 10 guests

Visit our sponsors: