yes, i did that, it worked until i got stuck trying to dig through groups and components...

Posts
-
RE: Delete all layers via ruby
-
Delete all layers via ruby
does anyone know if this is possible: delete ALL existing model layers and put all geometry on layer 0?
i looked around in the forum and in the api, but only found a way to remove a layer by name or index (only for 2015).
i'm trying to integrate it in a batch process
-
RE: Drawing with GL
thanks John, already did that though (screenshot above is a watermark).
the problem with this system is that you are forcing a new style on the user: if the user has a sketchy style on, you cannot have the bars and keep the sketchy style. (in other words we cannot load watermarks without loading a style as well).
that's why i mentioned about another route: find user current style > save it as variable > load the 'grid' style > restore user style from variable when finished.
alas, no way to get the previous style back in. whether from the 'in model' style, or trying to save it to a temp directory and loading it back from there. (at least i found no info at all anywhere).
PS least of all the api docs!
-
RE: Drawing with GL
..was trying to fit a 'rule of thirds' on the screen, but trying to avoid using styles.
this is what i'm aiming at:
as plan B, i tried saving the current style as a variable, load my 'ratio style with the grid', and reload the previous style upon exit of the tool.
Incidentally, i found no way to add a style that's already 'in model' - has to be from a saved file. (also no way to save a style to disk from ruby it seems).
-
RE: Drawing with GL
ok, i came to the conclusion that this is impossible. the orbit tool does not allow for anything else to be active. (and the draw method can't be called outside of a 'tool').
-
RE: Drawing with GL
that's the thing, often i try things out from the api docs and when it doesn't work, i'm not sure if it's me (my preferred choice) or the doc itself (...)!
John, i hadn't even notice it was relevant... will look it up.
JJB, the aspect ratio bars seem to be governed differently, when you try with lines it doesn't stay on screen (on orbit)
going to 'try' and take a break this evening... my skull hurts!
-
RE: Drawing with GL
John...looking at that code looks like you do need the rest!
is that a taster of what's inside the book? i'll check it out.
-
RE: [Plugin] Component Libraries Loader
yes, i posted the code so you'd be sure of the one i used.
notice i took out the '../' from the 2 folders paths (start of script) - which made the script look in the directory above to the comps folder. (so it only works on su8)
if you put the folders in the same directory as the script it works. at least it does for me (check the case matches too)
need to look more into to see why it doesn't when you change the path to full (ie. "c/Program Files/SketchUp...etc etc)
-
RE: Drawing with GL
well, first of all i'm trying to avoid going to bed!
i wanted to make a plugin that would show aspect ratio bars and even a grid system, it's almost there, but for the orbit bit(!)
this is the beast i'm working with:
class Gridz def activate @width3 = Sketchup.active_model.active_view.vpwidth/3 @height3 = Sketchup.active_model.active_view.vpheight/3 @p1 = @width3, 0, 0 @p6 = @width3, @height3*3, 0 @p2 = @width3*2, 0, 0 @p5 = @width3*2, @height3*3, 0 @p8 = 0, @height3, 0 @p3 = @width3*3, @height3, 0 @p7 = 0, @height3*2, 0 @p4 = @width3*3, @height3*2, 0 end def onMouseMove(flags, x, y, view) view.invalidate end def resume(view) view.invalidate end def suspend(view) view.invalidate end def draw(view) model = Sketchup.active_model view = model.active_view view.line_width = 1 view.drawing_color = "red" view.draw2d GL_LINES, [@p1, @p6] view.draw2d GL_LINES, [@p2, @p5] view.draw2d GL_LINES, [@p8, @p3] view.draw2d GL_LINES, [@p7, @p4] end #def def deactivate(view) view.invalidate end end # class if !file_loaded?(File.basename(__FILE__)) UI.menu("Plugins").add_item('Grid'){ Sketchup.active_model.select_tool Gridz.new } end file_loaded(File.basename(__FILE__))
-
RE: Drawing with GL
not sure, even with the invalidate on resume, no joy. though i could be doing it wrong.
def resume(view)
view.invalidate
end -
RE: [Plugin] Component Libraries Loader
it kind of does,
the code looks for the comps in two folders but they must be where the plugin itself is (plugins folder usually).
require 'sketchup.rb' #order = ["Components", "MyLibrary"] librariesNames = ["MyLibrary", "Components"] librariesFolders = { "Components" => "Components", "MyLibrary" => "MyLibrary"} module Sm4rt_CL class List_Menu_Load def initialize(rep=nil, menu=nil) return nil if not rep or not menu or not File.exist?(rep) or not File.ftype(rep)=='directory' skps=[]; folders=[] Dir.entries(rep).each{|f| next if f=='.' or f=='..' path=File.join(rep, f) skps << f if File.ftype(path)!='directory' and File.extname(f).downcase=='.skp' folders << f if File.ftype(path)=='directory' } folders.each{|folder| path=File.join(rep, folder); smenu=menu.add_submenu(folder) Sm4rt_CL;;List_Menu_Load.new(path, smenu) if smenu } skps.each{|skp| skpc=File.basename(skp, ".*"); path=File.join(rep, skp) menu.add_item(skpc){Sm4rt_CL;;List_Menu_Load;;component_loader(path)} } end#initialize def List_Menu_Load;;component_loader(path=nil) Sketchup.active_model.import(path, true) if path end#component_loader def List_Menu_Load;;menu_maker(folder=nil, name=nil) return nil if not folder or not name Sm4rt_CL;;List_Menu_Load.new(File.join(File.dirname(__FILE__), folder), menu=UI.menu("Plugins").add_submenu(name)) end#menu_maker end#class end#module ### auto-run at startup librariesNames.each {|value| Sm4rt_CL;;List_Menu_Load;;menu_maker(librariesFolders[value], value)} ###
-
RE: Drawing with GL
mmm maybe so, advanced camera tools is a ruby script though.
unfortunately it's flipping scrambled
-
RE: Drawing with GL
..makes sense, though when i look at those aspect ratio bars on the sides (like advanced camera tools), they do stay on screen.
-
RE: Drawing with GL
that was good (if only from a neurological perspective), seems like what i missed was 'onMouseMove invalidate' (thanks to the Chris F example you linked). however the line disappears when orbiting - even if i use the invalidate on onMButtonDown.
require 'sketchup.rb' class Layz def activate @p1=200,200,0 @p2=600,600,0 end def onMouseMove(flags, x, y, view) view.invalidate end def draw(view) model = Sketchup.active_model view = model.active_view view.line_width = 10 view.drawing_color = "red" view.draw2d GL_LINES, [@p1, @p2] end #def end # class if !file_loaded?(File.basename(__FILE__)) UI.menu("Plugins").add_item('Layz'){ Sketchup.active_model.select_tool Layz.new } end
-
RE: Drawing with GL
John, Thanks for this.
i actually did try it wrapped up in a class method, and called it from the
Sketchup.active_model.select_tool Gridz.newstill had no result. at least i now know where not to look!
-
Drawing with GL
isn't this supposed to work? ( knowing my coding genius probably not..
)
i thought i cracked it but i get: #Sketchup::View:0x00000007665b00 and nothing drawn
@p1=200,200,0 @p2=600,600,0 model=Sketchup.active_model view=model.active_view view.line_width=10 view.draw2d GL_LINES, [@p1, @p2]
Thanks
-
RE: Power Toolbar (2.5) - fix for 2019
Bob, are you sure you have no file or folder named jhs anywhere? never happened before.
Pherim, strange sounding - the new fix sets the window at 650 vertical, so that should not occur.
it should look like above image: first icon on second column being 'center to red'.
-
RE: Power Toolbar (2.5) - fix for 2019
Bob, fairly sure you haven't really uninstalled it somehow. try it manually, there are only 2 files: _jhs01_powerbar.rb and the jhs folder. delete them and reinstall
Anton, it was titanic (in the greek sense of the word). for the main part i didn't go out of the house for 8 solid days, or talk to anyone for that matter
. in fact there's a big chunk of my own coding on this one, (by grace of all the pastas i was being nurtured with).
Pherim, check the fix on first post, should be good with 1366x768.
Thanks all, good to hear you like it.
-
RE: Power Toolbar (2.5) - fix for 2019
Really Pilou, the icons were easy... dreaming code at night was something though!