Advanced polar array
-
ok! ive had another go at this (selecting all objects at once) and got it to work. this is amazing! thank you so much!
The problem here is that i dont want this all to happen at once. for the purpose of my presentation id like to be able to join all to one on one layer, then all to another on the other so i can take it into flash for instance and make a time lapse of the lines slowly building up until they look like the product of the code you gave me. is it possible to do this?
again, thank you so much for your help!
-
Work on a saved SKP [v8].
Choose your desired image-view and Select the components to be processed.
Copy+paste this new one-liner in the Ruby Console +<enter> and a set of Images is made in an 'Images' folder with the SKP.require('sketchup.rb');m=Sketchup.active_model;a=m.selection.to_a;m.selection.clear;v=m.active_view;w=v.vpwidth;h=v.vpheight;t=m.title;f=File.dirname(m.path);f=File.join(f,"Images");Dir.mkdir(d)unless(File.exist?(f));m.start_operation('x');j='000';a.dup.each{|o|;j.next!;g=m.active_entities.add_group();e=g.entities;(a-[o]).each{|i|;e.add_line(o.bounds.center, i.bounds.center);};x=File.join(f,t+"_Image_"+j+'.png');Sketchup.status_text=x;v.refresh;v.write_image(x,w,h,true);g.erase!;};UI.openURL('file;///'+f);m.commit_operation
It makes no changes to the model, but exports a set of images, then opens the folder 'Images'.
-
that is amazing. thank you so much! however, i am working on version 7 im afraid so its not working
thanks anyway!
-
hey again,
I was wondering if there's any way to make the code that exports the images one by one(as well taking out the background so only the lines remained)into a desired folder for version sketchup version7? just that ive also just worked out that ill have 61009 images.
I know this is a lot to ask but if its possible or there's maybe some other way to do it any help would be of great importance!
ninehundred
-
Let me get this right...
You want only the 'ray' lines in the images ?
Everything else is to be 'hidden'... -
Yes, just the ray lines. the idea basically is that ill take these lines later and overlay them onto a map so i can create a sort of time lapse of the lines building up until i have such a crowd of lines that the image area appears black. thing is though that if they all have a background then you wont see the build-up of the lines but rather a stream of individual images.
another thing is that since there will be a map below which will need to be seen underneath the lines. so in regards to this it would be useful to be able to put the images into a line editor and put them to scale 1:1000 at a size of 0.25. maybe it would be easier to have the images exported at a scale of 1:1000, each of them with the map underneith. i suppose that would mean it would be consistently exporting the map layer along with the lines at 1:1000 (again with no background) -
This images lines only.
require('sketchup.rb');m=Sketchup.active_model;a=m.selection.to_a;p=[];a.each{|e|p<<e.bounds.center};m.selection.clear;v=m.active_view;w=v.vpwidth;h=v.vpheight;t=m.title;f=File.dirname(m.path);f=File.join(f,"Images");Dir.mkdir(f)unless(File.exist?(f));m.start_operation('x');k=m.entities.to_a;m.entities.erase_entities(k);j='000';p.each{|o|; j.next!; g=m.active_entities.add_group(); (p-[o]).each{|i|; g.entities.add_line(o,i); }; x=File.join(f,t+"_Image_"+j+'.png'); Sketchup.status_text=x; v.refresh; v.write_image(x,w,h,true); g.erase!;};m.abort_operation;Sketchup.status_text='';UI.openURL('file;///'+f);
The 'scaling' of the images is another issue entirely - perhaps best left to a batch process in Photoshop or Gimp ? You might be better scaling the map to match the image overlays [they are all the same size] - then that's only one operation...
-
#<NameError: (eval):131: undefined local variable or method `d' for main:Object
this is what came up when i put the code in :S
also, am i to replace "images" with the address to the folder id like them sent to?
-
Sorry!
Stupid typo in the code... corrected now, I have edited my previous post...
Please retry it... -
Error: #<NoMethodError: (eval):131: undefined method `refresh' for #Sketchup::View:0xa4d50c0>
(eval):131Ok, so I put all the ray groups on one layer and basically started again. while a new folder called images was created there was still nothing in it and further to that all of the line groups except one was deleted.
-
IF you completed your user-profile in the control panel I might have realized you weren't using v8! view.refresh was introduced in v8 so v7 will fall over !
This code avoids thatrequire('sketchup.rb');m=Sketchup.active_model;a=m.selection.to_a;p=[];a.each{|e|p<<e.bounds.center};m.selection.clear;v=m.active_view;w=v.vpwidth;h=v.vpheight;t=m.title;f=File.dirname(m.path);f=File.join(f,"Images");Dir.mkdir(f)unless(File.exist?(f));m.start_operation('x');k=m.entities.to_a;m.entities.erase_entities(k);j='000';p.each{|o|; j.next!; g=m.active_entities.add_group(); (p-[o]).each{|i|; g.entities.add_line(o,i); }; x=File.join(f,t+"_Image_"+j+'.png'); Sketchup.status_text=x; v.write_image(x,w,h,true); g.erase!;};m.abort_operation;Sketchup.status_text='';UI.openURL('file;///'+f);
-
thank you so much, this is great!
Advertisement