ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • Make SU heal faces and edges?

    8
    0 Votes
    8 Posts
    3k Views
    thomthomT
    @gulcanocali said: @thomthom said: Don't think you can create zero length edges via Ruby. model.active_entities.add_line( ORIGIN, ORIGIN ) <- returns nil The first step in my note should have been "move the vertex on top of the other vertex you want to merge with" (then there may be an edge with zero length). After that follow the next two steps. That seem to have worked. Though temp groups and edges feels a big hacky - I wonder if there's a cleaner way. Would be interesting to get some insight to how SU does this internally. But thank you very much for this working method!
  • .execute_script interesting quirk

    7
    0 Votes
    7 Posts
    265 Views
    thomthomT
    @dan rathbun said: I think there is a whole topic on this concerning "Javascript:void(0);" vs "Javascript:return;" one of which needs to be in the HREF tag, the Ruby callback needs to be in the onClick call. To avoid triggering an A HREF link, and instead execute some other JS code, you return false to the onclick event.
  • Edge color by material

    5
    0 Votes
    5 Posts
    494 Views
    TIGT
    I was still editing my post when you replied... There are lots of ways of modifying your rendering appearance...
  • Creating a 3D wall from 2Dpoints(line),Width and Height

    2
    0 Votes
    2 Posts
    284 Views
    TIGT
    I assume that you have successfully applied xyz values to these points needed to make these lines; and put then into an array called 'pts'. You could use... lines=entities.add_edges(pts) where 'lines' is an array of the lines made. now to make the wall - I think the easiest in this case is to make a rectangular vertical face, the width [8"/20cm] and height [12'/3.6m] and then use 'followme' on that face with the lines as the path. So make the face at the origin.... face_pts=[[0,0,0],[8,0,0],[8,0,144],[0,0,144]] face=entities.add_face(face_pts) Transform the face's vertices so it is perpendicular to the vector of the first line in 'lines' vector=pts[0].vector_to(pts[1]) angle=face.normal.angle_between(vector) transformation=Geom::Transformation.rotation(ORIGIN, Z_AXIS, angle) entities.transform_entities(transformation, face.vertices) face.reverse! Move the face to the start of the first line in 'lines' transformation=Geom::Transformation.translation(ORIGIN.vector_to(pts[0])) entities.transform_entities(transformation, face.vertices) Now do the followme face.followme(lines) Done...
  • MAC-SU utility tool needs some testers

    3
    0 Votes
    3 Posts
    736 Views
    D
    @tfdesign said: John, would you be so kind as to explain what a "Mac editing Bridge" actually is? I'm sure if you explained what you are trying to achieve in a clearer, more 'laymans terms' kind of way, there would be far more interest. Tom Hi Tom, If you have an interest in how to make or fix rubies to use on a PC there are a couple of 'Bridges' that you can use between SketchUp and a more familiar or powerful script editor that you fancy. Their called bridges because they allow two way communication with SU to varying degrees. That means your not guessing as much, because you can check more often in a given time frame. No such 'Bridge' exists for Mac-SU, so you do a lot of copy/pasting between the external editor and Ruby Console. A second issue then arises is that SU has some limits to how many 'lines' you can copy/paste in before it 'bogs-down' and you need to 'purge' Ruby Console. Of course there's no Mac equivilent of the PC purge ruby, so you need to quit, restart, close the buggy start page, open a new page, open Ruby Console and then start copy/pasting again until it's slow or 'bug-splat's'. In a single session, you might this 100's of times, and it's a pain. So, I started playing around with Applescript to ease some of my pain, and found I can get it to do quite a bit in SU through UI [user imput] manipulation. That means, if there's a Menu Item, a Window Button, a Shortcut Key, etc... you can click it with applescript. (I highlight can because the how can be tricky) SU also uses a self preservation ruby, so some thing's can't be done from inside (an example is that a plugin in SU can't tell SU to quit, unless it does it through a separate external process) So, while I've been improving on these scripts/apps for my own use, I just thought there may be others interested. The 'new with my toolbars' and the 'kill button' alone would make life easier if you open SU more than twice a day and use 'beta' plugins. The next step is to get applescript to switch out the plugins before starting SU, so you have a button for drawing tools, one for advanced editing, one for prepping renders, or whatever. Applescript is brilliant at moving files around for processing in the background, so there's a lot of potential once we have a library of what works. Personally I've spent a great deal of time looking for 'cross platform' solutions when there may actually be very good built in tools for many of the problems. Every Mac owner has the very powerful 'Script Editor' and 'Automator' as standard and can upgrade to 'Xcode' from their instal disc's if they wish, so I think it's worth a look... cheers for your interest, I'll post the update for the app on the other 'Mac' thread for now. john
  • Toolbar problem in SU 8 on Windows

    27
    0 Votes
    27 Posts
    2k Views
    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 Votes
    6 Posts
    683 Views
    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 Votes
    6 Posts
    307 Views
    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 Votes
    7 Posts
    595 Views
    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 Votes
    3 Posts
    234 Views
    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 Votes
    4 Posts
    1k Views
    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 Votes
    5 Posts
    231 Views
    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 Votes
    33 Posts
    32k Views
    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 Votes
    5 Posts
    310 Views
    B
    Thanks guys, I'll try Ruby modules SérgioBizello
  • [solved] taking points at intervals from a line

    16
    0 Votes
    16 Posts
    884 Views
    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 Votes
    15 Posts
    568 Views
    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 Votes
    5 Posts
    521 Views
    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 Votes
    4 Posts
    194 Views
    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 Votes
    8 Posts
    367 Views
    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 Votes
    6 Posts
    246 Views
    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}')"

Advertisement