⚠️ Update | Sketchucation Tools 5.0.8 released with licensing improvements and bugfixes Download

Alkategóriák

  • No decscription available

    20 Témakörök
    462 Hozzászólások
    HornOxxH
    @pilou said: More appetizing in chocolate! Eggs are good as well - but only very fragile when falling down in SketchyPhysics
  • Toolbar problem in SU 8 on Windows

    27
    0 Szavazatok
    27 Hozzászólások
    3k Megtekintések
    Al HartA
    We are still struggling with Toolbars in SU8. Our biggest remaining problem, is that that when we load a plugin by hand, rather than having it loaded automatically as SketchUp loads - (we offer both options to users - always load the app, or manually load it from the Plugins menu) - the toolbar appears - but is not docked. I looked at your code snippet in the other thread, but it is hard to figure out how to put everything together. Can you, (or someone), provide a .RB which I can execute manually, (not placing it in the plugins folder - but loading the .RB from the ruby console - or later from the Plugins menu), which creates a new toolbar, and docks it properly? Then I can grab from it what I need, etc. to get it to work with our app.
  • How to use the toolbar.show method

    6
    0 Szavazatok
    6 Hozzászólások
    932 Megtekintések
    Dan RathbunD
    I recommend the following snippet: (Assume a boolean constant PC is set (see 2nd snippet.) <span class="syntaxdefault">    </span><span class="syntaxcomment"># show the toolbar<br /></span><span class="syntaxdefault">    delay </span><span class="syntaxkeyword">=(</span><span class="syntaxdefault"> Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">version</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_i </span><span class="syntaxkeyword">>=</span><span class="syntaxdefault"> 8 </span><span class="syntaxkeyword">?</span><span class="syntaxdefault"> 0.3 </span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> 1.0 </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    state </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">get_last_state <br />    if </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">state </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> TB_VISIBLE</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">restore<br />      </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment"># Per bug 2902434; resize regression on PC<br /></span><span class="syntaxdefault">      UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_timer</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">delay</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> false</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">restore </span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> if PC<br />      </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault">    elsif </span><span class="syntaxkeyword">(</span><span class="syntaxdefault">state </span><span class="syntaxkeyword">==</span><span class="syntaxdefault"> TB_NEVER_SHOWN</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">&&</span><span class="syntaxdefault"> PC<br />      </span><span class="syntaxcomment"># We DONT want to show them until the user wants them,<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment"># but we cannot leave the state as TB_NEVER_SHOWN, as<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment"># there is a PC bug that inserts phantom empty toolbar<br /></span><span class="syntaxdefault">      </span><span class="syntaxcomment"># windows up near the menubar, if state is -1.<br /></span><span class="syntaxdefault">      if Sketchup</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">version</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">to_i </span><span class="syntaxkeyword">>=</span><span class="syntaxdefault"> 8<br />        </span><span class="syntaxcomment"># We show it, then hide it so it will float later.<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">show<br />        UI</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">start_timer</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">delay</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> false</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">hide </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">      else </span><span class="syntaxcomment"># vers 6 & 7<br /></span><span class="syntaxdefault">        </span><span class="syntaxkeyword">@@</span><span class="syntaxdefault">toolbar</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">hide  </span><span class="syntaxcomment"># Sets last_state to TB_HIDDEN initially.<br /></span><span class="syntaxdefault">        </span><span class="syntaxcomment"># Users may still contend with "toolbar shuffle" later.<br /></span><span class="syntaxdefault">      end<br />    end<br /></span> If there are any LoadErrors in any startup script.. the toolbars will not resize unless the user closes the LoadError dialog before the delay fires the UI.start_timer block. Setting platform constants: MAC, OSX, PC, and WIN (This snippet can be inside your module or class, making them local constants, or you can paste them into the 'Tools/sketchup.rb' file so they get defined as global constants.) <span class="syntaxdefault">  unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">MAC</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br />    Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">MAC </span><span class="syntaxkeyword">=(</span><span class="syntaxdefault"> Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">RUBY_PLATFORM </span><span class="syntaxkeyword">=~</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">/</span><span class="syntaxdefault">darwin</span><span class="syntaxkeyword">/</span><span class="syntaxdefault">i </span><span class="syntaxkeyword">?</span><span class="syntaxdefault"> true </span><span class="syntaxkeyword">;</span><span class="syntaxdefault"> false </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  end<br />  unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">WIN</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br />    Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">WIN  </span><span class="syntaxkeyword">=(</span><span class="syntaxdefault"> not Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">MAC </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  end<br />  Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">OSX </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">MAC unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">OSX</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">PC  </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">WIN unless defined</span><span class="syntaxkeyword">?(</span><span class="syntaxdefault">Object</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">PC</span><span class="syntaxkeyword">)</span><span class="syntaxdefault">  </span>
  • Transformation Troubles

    6
    0 Szavazatok
    6 Hozzászólások
    565 Megtekintések
    Dan RathbunD
    @kdasilva said: From what I read I am guessing this has something to do with the transformation matrix ...but I can't seem to figure out how to navigate it. Martin Rinehart wrote a Tutorial that has a lesson on transformations and an explanation of the Matrix. See this post for links: http://forums.sketchucation.com/viewtopic.php?f=180&t=27182#p235251 ( ...follow the white rabbit. )
  • An U bolt

    7
    0 Szavazatok
    7 Hozzászólások
    933 Megtekintések
    S
    I read your PipeAlongPath code. I'm not using pre-selected path, instead generating by add_line+add_circle+add_line for U. add_circle return an array of edge, I need to include them into the path array. it works now (attached). Thanks draw a u-bolt
  • Observers. Can we use them!

    3
    0 Szavazatok
    3 Hozzászólások
    382 Megtekintések
    thomthomT
    Observers are troublesome. They have different bugs in different SketchUp versions. In general - only use observers when you really need to. And beware that modifying the model in events might very likely cause crashes. I've been trying to map out the state of observers in SU. If you have additional info or thing you found issues not documented, please post back with a reproducible case. http://forums.sketchucation.com/viewtopic.php?f=180&t=30793
  • Dim_angle.rb problem

    4
    0 Szavazatok
    4 Hozzászólások
    1k Megtekintések
    A
    does it work in Sketchup 8, the plugin? cuz in don;t seem to find it anyware in the SU interface
  • [solved] Scale to length

    5
    0 Szavazatok
    5 Hozzászólások
    496 Megtekintések
    K
    Ah i see the to_f worked perfectly, for some reason I was trying to convert it into feet with decimal places last night, not sure why....my brain was not quite as sharp after about 15 hours of coding/writing last night~ cheers Korbin
  • Automaticaly try to import files that aren't .sku

    33
    0 Szavazatok
    33 Hozzászólások
    38k Megtekintések
    TIGT
    @dan rathbun said: @gruff said: Can Ruby Scripts Accept a command line parameter on load? Nope @gruff said: Does Sketchup have command line parameters itself that can load a Ruby Script? sketchup.exe -RubyStartup script.rb You many need paths: Try adding the Sketchup program path to the %PATH% var, then change working dir to the plugins folder where the script is located. Not as they 'load' up but as an instance of them is started 'yes' - if you mean like MyTool.new(1,2,3) it's 'yes' just set the initialize method in the class to def initialize(arg0=0,arg1=,arg2=0) etc the =0 sets a default value for the arguments if they are not given. Obviously methods take accept arguments a lot of the API does that... point.offset(vector, distance) where the Point3d method accepts one or two arguments... If you want some code to run at startup of Sketchup then place it in a .rb script in Plugins that is auto-loaded and it will run - e.g. startupwithrubyconsole.rb containing the line require 'sketchup.rb';Sketchup.send_action("showRubyPanel:") will open the Ruby Console whenever Sketchup starts - pretty useless but just an example... or Sketchup.send_action("selectSelectionTool:") to change the default initial tool from the draw-line-tool to the select-tool...
  • Menu, require and .rb files

    5
    0 Szavazatok
    5 Hozzászólások
    546 Megtekintések
    B
    Thanks guys, I'll try Ruby modules SérgioBizello
  • [solved] taking points at intervals from a line

    16
    0 Szavazatok
    16 Hozzászólások
    2k Megtekintések
    K
    Ah, thanks for all the tips, guys! The line[1] vector will be useful, as long you are after the forward edge direction. I tried to use it yesterday, but couldn't because the polyline direction did matter in my case. And the second argument in .offset(). I didn't realize there was a second argument and was scaling my vector, instead. Actually, I only recently realized you could scale a vector by vector.length= and had been doing it a harder way, before. -Kwok
  • [Solved] Uploading not obviously related to Sketchup

    15
    0 Szavazatok
    15 Hozzászólások
    1k Megtekintések
    chrisglasierC
    Yes it works just fine. Soon people who visit my site will be able to make and save an "ownerfile". When they return they can upload the file to work with all the named links, keys, functions, value options and config settings previously set. This will also be extended to upload shared project or activity files (later including Sketchup of course). This is why the uploading business is so important in this context and why your pointer was much appreciated. Many thanks, Chris
  • Collision Code Optimization

    5
    0 Szavazatok
    5 Hozzászólások
    748 Megtekintések
    Dan RathbunD
    @adamb said: Dan: Its the other [way] around surely. The add_line is superfluous and added just to confirm the lines are sane. He wants to test the performance of the raytest you commented out.. Okie.. dokie. I didn't understand what he was trying for (it was late.) That was why I just commented out the lines and did not remove them. The gist of what I meant was to init references (vars,) outside the loop, and limit creation of new ones inside the loop unless they are actaully necessary (ie, to be used in some way.) Ruby takes time to create references.
  • Call align view

    4
    0 Szavazatok
    4 Hozzászólások
    383 Megtekintések
    TIGT
    @bluetale said: thx But I receive an error if the faces normal is parallel to Z_AXIS. I have added the following lines and it seems to work, but is it the correct solution? if !vector.parallel?(Z_AXIS) then > up = Z_AXIS > else > up = Y_AXIS > end It's a good trap! PS you don't need the 'then' and perhaps more 'simply' put if vector.parallel?(Z_AXIS) up = Y_AXIS else up = Z_AXIS end
  • Ruby access to styles.

    8
    0 Szavazatok
    8 Hozzászólások
    622 Megtekintések
    thomthomT
    @dan rathbun said: @al hart said: We want to write a routine to take a 360 degree spherical panoramic HDRi image ... These HDRi images are spherical? or cylindrical? Environment maps can be in many shapes - even cubical. HDRI image aren't always environment images.
  • Execute_script trouble

    6
    0 Szavazatok
    6 Hozzászólások
    489 Megtekintések
    thomthomT
    @kdasilva said: So do those escapes keep the quotations around the word so JS knows its a string and not some undeclared variable? Yes. The string you send to execute_script is processed by JS eval() in the webdialog. So remember that all strings you send to execute_script is processed and evaluated twice, once in Ruby and once in JS. Though, the code will be easier to re4ad and understand if you avoid escaping quotes. js_update_command = "UpDateVisionList('#{updated_visions_div}')"
  • [code] Split a long pathstring ~in half at the nearest '/'

    10
    0 Szavazatok
    10 Hozzászólások
    2k Megtekintések
    Dan RathbunD
    Ok here's my current version: <span class="syntaxdefault">def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">path_knife</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">,</span><span class="syntaxdefault">max</span><span class="syntaxkeyword">=</span><span class="syntaxdefault">60</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment"># make sure it's a Ruby path using '/'.<br /></span><span class="syntaxdefault">  path </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">expand_path</span><span class="syntaxkeyword">(</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">  if path</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length </span><span class="syntaxkeyword">></span><span class="syntaxdefault"> max<br />    </span><span class="syntaxcomment"># cut the file path into 2 lines<br /></span><span class="syntaxdefault">    ok </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">((</span><span class="syntaxdefault">path</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">length</span><span class="syntaxkeyword">-</span><span class="syntaxdefault">1</span><span class="syntaxkeyword">)*</span><span class="syntaxdefault">0.45</span><span class="syntaxkeyword">).</span><span class="syntaxdefault">to_i<br />    cut </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> path</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">split</span><span class="syntaxkeyword">(</span><span class="syntaxcomment">//).each_with_index { |e,i|<br /></span><span class="syntaxdefault">      break i if</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> e</span><span class="syntaxkeyword">==</span><span class="syntaxstring">'/'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">&&</span><span class="syntaxdefault"> i</span><span class="syntaxkeyword">>=</span><span class="syntaxdefault">ok </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">    cut </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 0 unless cut</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">is_a</span><span class="syntaxkeyword">?(Integer)<br /></span><span class="syntaxdefault">    return </span><span class="syntaxstring">"  #{path[0..cut]}   \n  #{path[(cut+1)..-1]}   "</span><span class="syntaxdefault"> if cut</span><span class="syntaxkeyword">></span><span class="syntaxdefault">0<br />  end<br />  </span><span class="syntaxcomment"># otherwise, leave it as one line<br /></span><span class="syntaxdefault">  return </span><span class="syntaxstring">"  #{path}   "<br /></span><span class="syntaxdefault">  </span><span class="syntaxcomment">#<br /></span><span class="syntaxdefault">end </span><span class="syntaxcomment"># def<br /></span><span class="syntaxdefault"> </span> **EDIT: Added test after iterator, to set cut to 0, if a string had no '/' characters (in which case each_with_index just returns the array characters.) Also removed frivolous line before iterator: cut = 0 EDIT 2:(2011-02-19) Simplified path substring references (line 11.) Removed frivolous else clause (were lines 12 and 13.)**
  • Webdialog Question on .show

    5
    0 Szavazatok
    5 Hozzászólások
    912 Megtekintések
    Dan RathbunD
    Make sure to read WebDialogs - The Lost Manual (by ThomThom) The webdialog is an instance of your custom WebDialog class. When you .close() the window, the instance object still exists, and when you .show() it your only opening up the window again. On PC you can use the block argument to do something in the javascript. (It is bugged on the Mac.) <span class="syntaxdefault">webwin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">show </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">  webwin</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">execute_script</span><span class="syntaxkeyword">(</span><span class="syntaxstring">"window.location='startpage.html';"</span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> <br /></span><span class="syntaxkeyword">}</span><span class="syntaxdefault"> </span>
  • Edges, angles on rectangle triangle

    8
    0 Szavazatok
    8 Hozzászólások
    1k Megtekintések
    C
    Angles are only defined between two vectors, so finding the angle between a vector and a plane can vary depending on which vector in the plane you're interested in. Most of the time, the vector you're interested in is the angle between the vector and it's projection into the plane which can be calculated using the face.plane method and the Array.project_to_plane method. The only trick here is that vectors are not points, so you would have to either pick a point in the plane, then transform it by your vector or translating the plane to the origin and simply calling the vector3d.to_a method. As it turns out, the second method is much simpler since given a plane of of the form [x,y,z,c] then translating it to the origin is as easy as changing it to [x,y,z,0]. Here is the code def angle_between_vector_and_projection(vector,face) plane = face.plane plane[3] = 0 projection = Geom;;Vector3d.new(vector.to_a.project_to_plane(plane)) return vector.angle_between(projection) end
  • Commit working like undo command

    4
    0 Szavazatok
    4 Hozzászólások
    408 Megtekintések
    thomthomT
    Note that start_operation cannot be nested. Doing a new start_operation after another will commit the first.
  • Get mouse x,y,z location other an with an Inputpoint?

    20
    0 Szavazatok
    20 Hozzászólások
    2k Megtekintések
    Dan RathbunD
    @chris fullmer said: Well there you have it! Glad you can test if they have Hide Rest of Model on or off. Just be aware that Scene (Pages) can also have their own RendingOptions hash instance.

Advertisement