Components and instancing in 1.025

Forums: Components and instancing in 1.025
SketchUp Integrated Plugin (Integrated Plugin maintained by OTOY)

Re: Components and instancing in 1.025

Postby smicha » Sun Aug 05, 2012 6:33 pm

smicha Sun Aug 05, 2012 6:33 pm
Rotation along red axis problem - solved!

The problem with rotation along red axis is solved. Two elements of a rotation matrix were corrected (negative sign in tr[6], tr[9])

Code: Select all
tt=[tr[0],tr[8],-(tr[4]),tr[12].to_m, tr[2],tr[10],-(tr[6]),tr[14].to_m, -(tr[1]),-(tr[9]),tr[5],-(tr[13].to_m)]


Latest version of .rb file is attached. I changed the name of it to "octane_scatter.rb".

I also added some code to run the script from a pull down plugin menu in Sketchup - requires further work (I've never done ruby coding before :))

Go to plugins - Octane scatter data from components (remember to select a component before running it).
Attachments
plugin.jpg
octane_scatter.rar
(524 Bytes) Downloaded 190 times
RGBrotation2.jpg
Win7, Modo 10.1, Octane for Modo and Sketchup, nVidia latest, TITAN+3x780 6GB, 2600K, P8P67WS, 32GB, 1350W
SMH10, EK, Airplex_480, SR1_560, 20xNB_PL2, 2xD5, Aquaero 6XT
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3145
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Components and instancing in 1.025

Postby TIG » Sun Aug 05, 2012 10:30 pm

TIG Sun Aug 05, 2012 10:30 pm
Smicha - well fixed!
Here's a module version that works, with a Plugins menu item...
It could do with a lot of 'checking' code BUT it works if the user follows the instructions - if not it breaks !! - e.g. the SKP has been saved AND has a path, the selection IS a component etc...
Attachments
octane_scatter.zip
(592 Bytes) Downloaded 280 times
TIG
User avatar
TIG
Licensed Customer
Licensed Customer
 
Posts: 536
Joined: Wed May 12, 2010 1:25 pm

Re: Components and instancing in 1.025

Postby smicha » Mon Aug 06, 2012 7:02 am

smicha Mon Aug 06, 2012 7:02 am
TIG - your help is invaluable!

Now its time to think about adding some improvements. One of them I mentioned in previous posts. Hence

1. It is painful in some circumstances to set selected component axes into the origin of entire project. This is my idea how to solve this issue:
a. the code creates additional copy of selected component (placed freely in a model, without a need of taking care of its axes) and a let's so called "reference copy" is created with its axes placed exactly at a project origin.
b. now, the code, treats the reference copy as selected one, a then does the rest. The data for reference copy are not exported.

So is it possible to work like this? Or there is a better solution, simpler, to get rid of extra displacement I described in previous posts.

2. I was trying to export only visible copies of a component - I hid some of them on a different layer. But the plugin exports all of them. So it would be great to export only visible copies.
Win7, Modo 10.1, Octane for Modo and Sketchup, nVidia latest, TITAN+3x780 6GB, 2600K, P8P67WS, 32GB, 1350W
SMH10, EK, Airplex_480, SR1_560, 20xNB_PL2, 2xD5, Aquaero 6XT
build-log http://render.otoy.com/forum/viewtopic.php?f=9&t=42540
User avatar
smicha
Licensed Customer
Licensed Customer
 
Posts: 3145
Joined: Wed Sep 21, 2011 4:13 pm
Location: Warsaw, Poland

Re: Components and instancing in 1.025

Postby TIG » Mon Aug 06, 2012 11:18 am

TIG Mon Aug 06, 2012 11:18 am
Your 'definition' instance - the one you export as an OBJ - must be placed with its origin at [0,0,0] in the model.
BUT it doesn't need to be the same model as the multiple-instance versions...
Why not do a manual 'save_as' on any instance [select+context-menu OR Component-Browser>Model-pane context-menu option] and just save it as an external SKP file [it will auto-named after the definition, put it in the main model's folder]. Its origin will then be the model origin anyway, so not thinking necessary.
Then just open that simple SKP and export the OBJ from that.

If you want to make the 'transforms' TXT files for only the 'visible' instances, then include these two lines of 'next unless...' code...
Code: Select all
instances.each{|instance|
  next unless instance.visible?
  next unless instance.layer.visible?
  ### keeping the rest of the code, starting with...
  tr=instance.transformation.to_a
  ###...
}
TIG
User avatar
TIG
Licensed Customer
Licensed Customer
 
Posts: 536
Joined: Wed May 12, 2010 1:25 pm

Re: Components and instancing in 1.025

Postby archigrafix » Tue Aug 07, 2012 5:31 pm

archigrafix Tue Aug 07, 2012 5:31 pm
IT WORKS!!
you guys are fnatastic!

I added your lines TIG and all works nicely... Most of most is we can replace simple SU components by high poly versions in Octane!
I already did a test with 7 nice CGaxis trees and no problems...I will try to push it to the limit of my 470GTX !
archigrafix
Licensed Customer
Licensed Customer
 
Posts: 201
Joined: Tue Jan 26, 2010 5:37 pm
Location: FRANCE

Re: Components and instancing in 1.025

Postby ppoublan » Sun Aug 12, 2012 4:21 pm

ppoublan Sun Aug 12, 2012 4:21 pm
Sorry did not seen last posts before posting it.
Forgot it.
Yours

-------

Dear all,
Yes the idea to create a csv from Sketchup exporter should work.
Here is a little ruby script that output to the su ruby script window positions of selected components with yz reverse and scale.
It Sodoes not work as is if more than one rotation around original axis is made... -> needs to work more on matrix transformation operations
but with it I was able from only one component in SU exported to Octane to create this render with 2 cascaded scatter.
Any volonteer with good knowledge of SU script to improve and debug this in order to use Octane instancing ?



Script :
copy and save it as "expcompoctane.rb" in Sketchup plugin directory and restart sketchup

require 'sketchup.rb'

module Montestamoi

def self.exptrans

puts "new selection"
puts "--------"
model = Sketchup.active_model
selection = model.selection
selection.each { |component|
# puts "component typename " + component.typename.to_s
if component.typename == "ComponentInstance"
# retrieve the transformation of the component instance
transformation = component.transformation

# flip y and z

# reverse y

# puts "component instance transformation"
transarray = transformation.to_a
for i in 0..3
# puts transarray[i*4].to_s + "/" + transarray[(i*4)+1].to_s + "/" + transarray[(i*4)+2].to_s + "/" + transarray[(i*4)+3].to_s
end
transarraytarget=[]
transarraytarget[0] = transarray[0]
transarraytarget[1] = -transarray[2]
transarraytarget[2] = transarray[1]
transarraytarget[3] = transarray[12].to_m
transarraytarget[4] = -transarray[8]
transarraytarget[5] = transarray[10]
transarraytarget[6] = transarray[9]
transarraytarget[7] = transarray[14].to_m
transarraytarget[8] = transarray[4]
transarraytarget[9] = transarray[6]
transarraytarget[10] = transarray[5]
transarraytarget[11] = -transarray[13].to_m
# puts "target"
for i in 0..2
# puts transarraytarget[(i*4)].to_s + "/" + transarraytarget[(i*4)+1].to_s + "/" + transarraytarget[(i*4)+2].to_s + "/" + transarraytarget[(i*4)+3].to_s
end
for i in 0..2
printf "%8.03f %8.03f %8.03f %8.03f ", transarraytarget[(i*4)], transarraytarget[(i*4)+1], transarraytarget[(i*4)+2], transarraytarget[(i*4)+3]
end
printf "\n"

=begin
for i in 0..15
transarraymeter[i] = transarray[i].to_m
puts "trans " + i.to_s + ": " + transarray[i].to_s + " inches"
puts "trans " + i.to_s + ": " + transarraymeter[i].to_s + " meters"
end
for i in 0..15
transarraymeter[i] = transarray[i].to_m
puts "trans " + i.to_s + ": " + transarray[i].to_s + " inches"
puts "trans " + i.to_s + ": " + transarraymeter[i].to_s + " meters"
end
=end

end
}

end

if not (file_loaded? "expcompoctane.rb")
plugins_menu = UI.menu "Plugins"
Sketchup.send_action "showRubyPanel:"
plugins_menu.add_item("Export Component Transformations") { exptrans }
end

end # end of module
Attachments
capture02.JPG
capture01.JPG
ppoublan
Licensed Customer
Licensed Customer
 
Posts: 56
Joined: Fri Nov 18, 2011 8:47 am

Re: Components and instancing in 1.025

Postby Phantom107 » Mon Sep 24, 2012 10:33 pm

Phantom107 Mon Sep 24, 2012 10:33 pm
Thanks a ton for the plugin. I tried it and it works great! I'll be using this a lot.
User avatar
Phantom107
Licensed Customer
Licensed Customer
 
Posts: 686
Joined: Tue Jul 24, 2012 11:31 am
Location: The Netherlands

Re: Components and instancing in 1.025

Postby ssokol » Mon Dec 10, 2012 9:10 am

ssokol Mon Dec 10, 2012 9:10 am
thanks, it`s working fine.
great
cheers
User avatar
ssokol
Licensed Customer
Licensed Customer
 
Posts: 64
Joined: Thu Mar 22, 2012 8:39 pm
Location: Poland

Re: Components and instancing in 1.025

Postby bignatov » Thu Jan 31, 2013 9:37 am

bignatov Thu Jan 31, 2013 9:37 am
This plugin rocks! Great idea and execution, thank you guys!
bignatov
Licensed Customer
Licensed Customer
 
Posts: 4
Joined: Sat Jan 26, 2013 4:23 pm

Re: Components and instancing in 1.025

Postby grusgrus » Tue Feb 05, 2013 1:23 pm

grusgrus Tue Feb 05, 2013 1:23 pm
I would like to make one small comment to your instructions.

The way I work with components in architectural modeling makes it very unpractical to move the component base point to world coordinate 0,0,0.

What i did instead was this;
- place my components as i wanted them
- add one component at world 0,0,0 and export it as "selection only"
- select that component and run instances.rb
- in the text file, delete the first line (which places an instance node at 0,0,0 in Octane)
- insert component as scatter in Octane as instructed

This saved me the bother of having to muck around with my components base points. My collection is growing large, and odd base points would complicate placing them immensely.

With that I would like to thank you for a very nice plugin that will help me get those IES lights oriented properly :D

Regards GG
grusgrus
Licensed Customer
Licensed Customer
 
Posts: 3
Joined: Thu Nov 01, 2012 9:03 pm
Location: Norway
PreviousNext

Return to SketchUp


Who is online

Users browsing this forum: No registered users and 2 guests

Fri Apr 03, 2020 8:17 am [ UTC ]