Page 4 of 6

Re: Components and instancing in 1.025

PostPosted: Sat Aug 04, 2012 11:01 am
by smicha
smicha wrote:
Code: Select all
SU:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16


Sorry,
It is obviously
Code: Select all
SU:
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
.....

Re: Components and instancing in 1.025

PostPosted: Sat Aug 04, 2012 2:02 pm
by smicha
TIG,
I DID IT !!! BUT your further help is needed :)

Look at screenshots.

Before running the script I moved one of the copy of components into the project origin, to make its axes overlapping axes of the project. Then selected it and type command for running the script.


The last (I hope) thing to input into your code is to make set axes of selected component equal to [0,0,0]. Is it possible?

Thank you again! So much!!!

Re: Components and instancing in 1.025

PostPosted: Sat Aug 04, 2012 3:36 pm
by rappet
smicha wrote:TIG,
I DID IT !!! BUT your further help is needed :)

Look at screenshots.

Before running the script I moved one of the copy of components into the project origin, to make its axes overlapping axes of the project. Then selected it and type command for running the script.


The last (I hope) thing to input into your code is to make set axes of selected component equal to [0,0,0]. Is it possible?

Thank you again! So much!!!


Hi Smicha, congrats in reaching your goal.
Can you explain now what exactly you can do fromout Sketchup?
greetings

Re: Components and instancing in 1.025

PostPosted: Sat Aug 04, 2012 3:39 pm
by smicha
rappet wrote:Can you explain now what exactly you can do fromout Sketchup?
greetings


Yes,
I am just preparing short tutorial.
Let you know soon.

Re: Components and instancing in 1.025

PostPosted: Sat Aug 04, 2012 5:06 pm
by smicha
TUTORIAL - COMPONENTS TO OCTANE INSTANCES
First beta version of Sketchup plugin (ruby file) exporting components as instances to Octane
The code of instances.rb is written by TIG, I added some changes to rotation matrix. TIG - thank you so so so much!


1. Download instances.rb file into C:\Program Files (x86)\Google\Google SketchUp 8\Plugins
2. Follow steps from pdf - screenshots.

Re: Components and instancing in 1.025

PostPosted: Sat Aug 04, 2012 7:25 pm
by rappet
smicha wrote:TUTORIAL - COMPONENTS TO OCTANE INSTANCES
First beta version of Sketchup plugin (ruby file) exporting components as instances to Octane
The code of instances.rb is written by TIG, I added some changes to rotation matrix. TIG - thank you so so so much!


1. Download instances.rb file into C:\Program Files (x86)\Google\Google SketchUp 8\Plugins
2. Follow steps from pdf - screenshots.


I tried it and it works perfectly. This is great stuff !!!!
Thanx TIG, thanx Smicha.

I am perfecting an excel for making csv-files for general rows, matrices and scattered matrices.
I'll let know when I think it's usable for others when I have it working even betetr and tested for different things I am making it for. Dspite this fantatistic plugin I will finish the excel matrix, because I think it can be very helpfull for making general cvs and scattered matrices as a stand alone. i.e. to add trees to the ocs-scene.. or birds in the sky...

But this SU-plugin is great for stuff for what is very hard to make with only numbers in excell.. I can think of lot of things to do with it.... thanks so much for this.

Re: Components and instancing in 1.025

PostPosted: Sun Aug 05, 2012 9:12 am
by TIG
Well done !
I knew you could do it.
Sorry I was too busy not to be of more help...

A couple of things. ;)

If the .rb file is already in the Plugins folder when you startup Sketchup you can skip the load "instances.rb" step as it will have auto-loaded itself anyway.

Can I suggest you wrap the working code in a 'module' and run it thus:
SMICHA.instances
The module version becomes:
Code: Select all
module SMICHA
def SMICHA.instances()
  ### REST of method code goes here ###
end#method
end#module
Adjust the module name to your own taste...
That way it should never clash with anything else - after all a raw 'instances[_test]' is a pretty common name otherwise...

Re: Components and instancing in 1.025

PostPosted: Sun Aug 05, 2012 9:20 am
by smicha
TIG,
Is it possible to set selected component's axes to [0,0,0] in the code ?

Re: Components and instancing in 1.025

PostPosted: Sun Aug 05, 2012 11:22 am
by smicha
TIG wrote:Can I suggest you wrap the working code in a 'module' and run it thus:
SMICHA.instances
The module version becomes:
Code: Select all
module SMICHA
def SMICHA.instances()
  ### REST of method code goes here ###
end#method
end#module



TIG,

1. What I am doing wrong:


Code: Select all

module SMICHA
def SMICHA.instances()

require 'sketchup.rb'

   def octane_scatter_data()
      model=Sketchup.active_model
      instances=model.selection[0].definition.instances
      txt=""
      instances.each{|instance|
        tr=instance.transformation.to_a
        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)]
        str=""
        tt.each{|e| str<<sprintf("%.4f ",e) }
        txt<<str+"\n"
      }
      path=File.dirname(model.path)
      file=File.join(path, model.title+"_"+instances[0].definition.name+".TXT").tr("\\","/")
      f=File.new(file, "w")
      f.puts(txt)
      f.close
   end

end#method
end#module



2. I also would like it to run it from a pull down menu in plugins:

Code: Select all
UI.menu("PlugIns").add_item("OCTANE scatter data from components") {
  UI.messagebox("......")
}


How to add it into the code?

3. And what about my previous post and the question about setting axes of selected component into origin?

Re: Components and instancing in 1.025

PostPosted: Sun Aug 05, 2012 5:03 pm
by smicha
Rotation along red axes problem

The script works properly only for rotated along green or blue axes (and should work properly for joint rotation along vector in "green-blue space" - I didn't test it yet). I'll try to fix it.