Page 5 of 6

Re: Components and instancing in 1.025

PostPosted: Sun Aug 05, 2012 6:33 pm
by smicha
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).

Re: Components and instancing in 1.025

PostPosted: Sun Aug 05, 2012 10:30 pm
by TIG
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...

Re: Components and instancing in 1.025

PostPosted: Mon Aug 06, 2012 7:02 am
by smicha
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.

Re: Components and instancing in 1.025

PostPosted: Mon Aug 06, 2012 11:18 am
by TIG
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
  ###...
}

Re: Components and instancing in 1.025

PostPosted: Tue Aug 07, 2012 5:31 pm
by archigrafix
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 !

Re: Components and instancing in 1.025

PostPosted: Sun Aug 12, 2012 4:21 pm
by ppoublan
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

Re: Components and instancing in 1.025

PostPosted: Mon Sep 24, 2012 10:33 pm
by Phantom107
Thanks a ton for the plugin. I tried it and it works great! I'll be using this a lot.

Re: Components and instancing in 1.025

PostPosted: Mon Dec 10, 2012 9:10 am
by ssokol
thanks, it`s working fine.
great
cheers

Re: Components and instancing in 1.025

PostPosted: Thu Jan 31, 2013 9:37 am
by bignatov
This plugin rocks! Great idea and execution, thank you guys!

Re: Components and instancing in 1.025

PostPosted: Tue Feb 05, 2013 1:23 pm
by grusgrus
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