Move groups with different measures?

Re: Move groups with different measures?

Postby pilou » Wed Jul 15, 2009 7:06 pm

Funny thing :D
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: Move groups with different measures?

Postby pilou » Thu Jul 16, 2009 10:15 am

Some tests :mrgreen: Put the code inside the WebConsole by Jim Foltz
Press "Eval" button and have fun :D
Veyron model is from 3Dwarehouse!
Code: Select all
model = Sketchup.active_model
entities = model.entities
selection = model.selection

xp=100  # Pivot Point (as you want)
yp=100
zp=100

q=50 # Measure of translation (as you want)

selection.each do |e| # update!
  # Skip all entities that aren't groups or components (replace follow "ComponentInstance" by "Group" if you have groups
  next unless e.is_a? Sketchup::ComponentInstance  # Now we process the component or group
 center = e.bounds.center #Center Point of the grouped object
   xc= center.x
   yc= center.y
   zc= center.z
   
xe=xc #End Point of the grouped object
ye=yc
ze=zc

if xc<xp
 xe =xc - q
end

if xc>xp
 xe =xc + q
end

if yc<yp
 ye =yc - q
end

if yc>yp
 ye =yc + q
end

if zc<zp
 ze =zc - q
end

if zc>zp
 ze =zc + q
end

  point = Geom::Point3d.new xe,ye,ze
  t = Geom::Transformation.new point
  # Apply the transformation
  e.transform!(t)
end
1
Last edited by pilou on Fri Jul 17, 2009 9:08 am, edited 5 times in total.
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: Move groups with different measures?

Postby thomthom » Thu Jul 16, 2009 10:22 am

Looking good Pilou!
Instant assembly drawings! :D This should come in handy.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Move groups with different measures?

Postby pilou » Thu Jul 16, 2009 10:27 am

Instant assembly

Alas for the inverse, that must be more tricky! :?
Better is use the Undo :mrgreen:
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: Move groups with different measures?

Postby thomthom » Thu Jul 16, 2009 10:43 am

hm... You could store the relative position you move the entities by in and attribute dictionary. Then perform the opposite when you want to reassemble.

though, that will fail if the user moves anything...
Maybe, you could store the original absolute position before you move stuff. Then you can reassemble back to that original position. That would allow the user to move things around as they please.
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Move groups with different measures?

Postby pilou » Thu Jul 16, 2009 10:52 am

In theory that must be more easy ;)
Just select that you want and apply a "negative" translation : a deflation ;)
Maybe my next :)
And the above is not yet perfect! The Pivot Point seems not have the wished result wanted :roll:
be continued...

Ps When Groups or Components are nested how to process automatically?
A plug for make each components individual is maybe existing?
Edit
one exist for group by TIG Explode2groups

miss now somethings transform Transform2goups or Explode2Components :)
0
Last edited by pilou on Thu Jul 16, 2009 10:24 pm, edited 1 time in total.
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: Move groups with different measures?

Postby Chris Fullmer » Thu Jul 16, 2009 10:14 pm

Store the original transformation in a dictionary attached to the group/component. Then to unexplode, just re-apply that transformation onto the group. It will go right back where it belongs.

I wrote that crazy scrambler script a while ago that does this and it worked very well.

Chris
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: Move groups with different measures?

Postby pilou » Thu Jul 16, 2009 10:25 pm

@Chris Any chance to see it somewhere? :)

PS
A plug for make each components individual is maybe existing?
Edit
one exist for group by TIG Explode2groups

miss now somethings for components Transform2goups or Explode2Components
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

Re: Move groups with different measures?

Postby Chris Fullmer » Thu Jul 16, 2009 10:38 pm

take the componentInstance, add it to a group, then explode the component instance.

And I posted my scrambler script here. I'll see if I can find the thread.

Chris
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: Move groups with different measures?

Postby pilou » Fri Jul 17, 2009 8:59 am

@Chris thx for the Info :enlight:
Fredo6 has inside the FredoScale something who transform any selection of groups or Components in "Unique" groups or componants! (each become individual)
(last icon)
0
Frenchy Pilou
Is beautiful that please without concept!
Speedy Galerie
User avatar
pilou 
Top SketchUcator
 

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago



Ad Machine 
Robot
 

Previous


 

Return to Developers' Forum

Who is online

Users browsing this forum: No registered users and 12 guests