⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
  • [Code] Open File Browser and Select File

    5
    0 Votes
    5 Posts
    314 Views
    D
    @jim said: This code opens a Windows Exlorer window with the given file selected. Is there a Mac equivalent? [image: dBQr_2012-09-1112.45.06pm.png] Tig's code does open the file in 'Finder' and highlights the file title > file=("/Some/Folder/MyFile.rb") UI.openURL('file:///' + File.dirname(file)) true Like this it 'opens' in the associated program for that type of file. i.e. TextWrangler opens ruby files on my system. > file=("/Some/Folder/MyFile.rb") UI.openURL('file:///' + (file)) true This will also open in 'Finder' > file = './Some/Folder/MyFile.rb' system("open -R #{file}") true note: returns true/false > file = './Some/Folder/MyFile.rb' system %(open -R #{file}) true note: also returns true/false shorthand works as well >open -R './Some/Folder/MyFile.rb'`` note: NO return of true/false Without the -R recursive flag it will 'open' in the associated app Again, it can be with or without the return, dependant on the call syntax. john
  • New to Ruby need some advice

    4
    0 Votes
    4 Posts
    130 Views
    TIGT
    OK FollowMeAndKeep [FAK]... makes a good basis...
  • Is this a ruby bug?

    5
    0 Votes
    5 Posts
    515 Views
    TIGT
    TT you are of course correct. Within '' only \' within a string and any final \\ are needed - for example \n doesn't apply as a newline. I've adjusted the original post to avoid further confusion
  • Adding Flipped Component Instance

    5
    0 Votes
    5 Posts
    225 Views
    TIGT
    He wanted to copy a selected component-instance [that happens to be mirrored] and was trying to get its definition and place an instance etc. Obviously he could reuse the original's transformation...*** I was trying to show him how he might copy "anything" that is selected, by grouping it. The code groups the selection, adds another instance of it and explodes the original. At that point if he knows the selection was the one component-instance then he has the option to explode its group, giving the same result as placing a second instance using the original's transformation, but if the selection is of something different - e.g. groups, geometry, mixed objects etc - he can choose to do other things with them within the safety of his group - e.g. non-merging geometry is preserved... ***For the avoidance of doubt here is how to duplicate an instance with the same matching transformation [i.e. position,rotation,scaling,mirroring etc]... Assuming that 'instance' is what's been selected/found and it has been tested and found to be a ComponentInstance... copy_of_instance = instance.parent.entities.add_instance(instance.definition, instance.transformation)
  • Select faces with back color

    2
    0 Votes
    2 Posts
    116 Views
    TIGT
    How is such a tool going to establish whether a face is 'inside' or 'outside' a form ? It'd be possible with a 'solid', but with loose faces who is to say what is the right way round ? There are several 'face reversing' tools around - open the 'Plugins Index' page and use your browser's search for 'reverse' or 'flip' etc... Find one that suits you... I think Didier's tool reverses all 'backwards' active faces that are looking at the current camera, which might do what you want best...
  • Should we be autoloading?

    4
    0 Votes
    4 Posts
    253 Views
    thomthomT
    @dan rathbun said: I remember trying this a long time ago.. but did not get it working. Maybe I used it wrong? I do have it working for a large project I'm working on. I set up some of the mixing modules and base classes to autoload. <span class="syntaxdefault"><br />&nbsp;&nbsp;</span><span class="syntaxcomment">#&nbsp;Ensure&nbsp;abstract&nbsp;classes&nbsp;are&nbsp;loaded&nbsp;and&nbsp;found&nbsp;when&nbsp;needed.<br />&nbsp;&nbsp;</span><span class="syntaxdefault">autoload</span><span class="syntaxkeyword">(&nbsp;;</span><span class="syntaxdefault">Observable</span><span class="syntaxkeyword">,&nbsp;&nbsp;&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'observable.rb'&nbsp;</span><span class="syntaxkeyword">)&nbsp;)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">autoload</span><span class="syntaxkeyword">(&nbsp;;</span><span class="syntaxdefault">BezierEntity</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'bezier_entity.rb'&nbsp;</span><span class="syntaxkeyword">)&nbsp;)<br />&nbsp;&nbsp;</span><span class="syntaxdefault">autoload</span><span class="syntaxkeyword">(&nbsp;;</span><span class="syntaxdefault">BezierPatch</span><span class="syntaxkeyword">,&nbsp;&nbsp;</span><span class="syntaxdefault">File</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">join</span><span class="syntaxkeyword">(&nbsp;</span><span class="syntaxdefault">PATH</span><span class="syntaxkeyword">,&nbsp;</span><span class="syntaxstring">'bezier_patch.rb'&nbsp;</span><span class="syntaxkeyword">)&nbsp;)<br />&nbsp;</span><span class="syntaxdefault"></span>
  • Wish List - WebDialog communication model

    16
    0 Votes
    16 Posts
    2k Views
    chrisglasierC
    @caseychamberlain said: @richmorin said: As an example of quirky behavior, execute_script() imposes a fairly small (and undocumented) limit on the size of the executed code string. So, although the call can be used to transfer data (eg, as JSON), any significant amount of data will require multiple calls. What is the limit? I was relying on this to push (sizeable) model data into a silverlight plugin in the WebDialog. I had assumed I needed to chunk, but it would really help to know what that limit is, so I can chunk to that size. Thanks! This is the overriding problem: https://developers.google.com/sketchup/docs/ourdoc/webdialog#add_action_callback
  • Intersect two Component Instances

    7
    0 Votes
    7 Posts
    280 Views
    C
    Thank you. That solved the last Problem with the intersect. you guys have been very helpful@TIG,sdmitch Thanks a thousand
  • Auto naming and replacing materials?

    2
    0 Votes
    2 Posts
    200 Views
    TIGT
    The method texturepath = material.texture.filename returns the path/name of the material's texture's image-file. Use something like imagename = nil; imagename = File.basename(material.texture.filename) if material.texture... To change a material's texture you use a new path material.texture="C:/.../mytetxure.png". To get a material's name use matname = material.name. To rename a material use material.name="newname" OR material.name=imagename if imagename - note that the renaming method is unavailable in older versions of Sketchup...
  • Question-How to link model components and generate on edges

    5
    0 Votes
    5 Posts
    197 Views
    pingpinkP
    Hi , I tried to adapt from the comment in my code , but it doesn't work yet for clicking lines then load external reference component (0,0,0) from component's file. I'm still finding how to link between the functions that the model can stretch or scales the component to the length as the edges. Here's my attached ruby , not sure what's error in the code as I'm a new to ruby ! Any suggestion , I would be appreciate!. Thanks
  • Nested Attribute Dictionaries

    18
    0 Votes
    18 Posts
    2k Views
    thomthomT
    @dan rathbun said: @thomthom said: But when I have inspected .skp files I saw no duplicate of any attributes blocks - and the attributes data blocks where in UTF-16. I wonder if we could use Zlib to compress data before writing it to dictionaries ?? I'd love to be able to use zipping in my projects. Think I looked at it some time ago and people had tried to find ways to make it work properyl within SketchUp ruby with mixed results..
  • V3DTools

    3
    0 Votes
    3 Posts
    179 Views
    T
    Thanks, Thomthom . I'll follow your advice.
  • I must be dumb

    3
    0 Votes
    3 Posts
    166 Views
    thomthomT
    @thierry_st_malo said: It works for the red and the green axis, but not for the blue one. Ridiculously, I can't see why. What you explain more what "doesn't work"? Exactly what happens, and what did you expect? Any errors?
  • Model Operation blockform methods.

    24
    0 Votes
    24 Posts
    2k Views
    Dan RathbunD
    Putting this on the back burner until I get some feedback.
  • How to count duplicates hash itens in Ruby

    6
    0 Votes
    6 Posts
    2k Views
    Dan RathbunD
    # EXAMPLE - untested module Romuloigor module Product @@product = { ;count => {}, ;list => [ { "product" => 1, "x" => 200, "y" => 100, "z" => 18}, { "product" => 1, "x" => 200, "y" => 100, "z" => 18}, { "product" => 1, "x" => 300, "y" => 100, "z" => 18}, { "product" => 2, "x" => 300, "y" => 100, "z" => 18}, { "product" => 2, "x" => 100, "y" => 100, "z" => 18}, { "product" => 2, "x" => 100, "y" => 100, "z" => 18}, { "product" => 3, "x" => 100, "y" => 100, "z" => 18} ] } class << self def add(product) # @@product[;list] << product # end # add() def recount() # @@product[;count]= @@product[;list].inject(Hash.new(0)) {|h, e| h[e] += 1; h} # end # recount() def count(product) # total = @@product[;count][product] return ( total ? total ; 0 ) # end # count() def list() # list = "" @@product_list[;count].each {|k,v| list << "#{k.inspect} count = #{v}\n" } return list # end # list() end # proxy class end # module Product end # module Romuloigor
  • New tool's "initialize" starts bf prev tool's "deactivate"

    3
    0 Votes
    3 Posts
    201 Views
    S
    @thomthom said: Do you stuff in the Tool's activate callback. That should trigger after deactivate. Initialize triggers when you create the tool instance - not when it's activated. You can reuse a tool instance - where activate is the one that will trigger when your tool activates. (How do you activate the tools btw? model.select_tool or model.tools.push_tool ?) Hi Thomthom. Man, such a stupid error of me. I did use the initialize method instead of the activate method. Btw, I use select_tool ToolName.new Thanks for the answer, funny I didn't saw the error myself
  • Making changes visible

    7
    0 Votes
    7 Posts
    203 Views
    Dan RathbunD
    You have to save the view's camera properties to a new Sketchup::Camera instance, then restore it. view = Sketchup.active_model.active_view vcam = view.camera props = [vcam.eye,vcam.target,vcam.up,vcam.perspective?] cam = Sketchup;;Camera.new(*props) view.zoom_extents view.camera= cam
  • Creating rbz files on Win7

    11
    0 Votes
    11 Posts
    1k Views
    K
    Mistry with win7 zip files solved!!! Some how my folder option to hide known extensions was selected and this created the problem making a ziped file a ziped folder. I know I had nothing to do with that change as it took me a long time to find Folder Options after I started looking for them. Keith
  • Determine if face is covered by shadow

    2
    0 Votes
    2 Posts
    103 Views
    TIGT
    I wrote this last year http://forums.sketchucation.com/viewtopic.php?p=371243#p371243 'ShadowProjector' If calculates shadows cast on faces and % area etc [image: lCSs_ShadowProjector_Example.PNG]
  • [Info] Free Ruby Book: &quot;I Love Ruby&quot;

    4
    0 Votes
    4 Posts
    378 Views
    daleD
    If that's Ruby, then I love Ruby too! Thanks Dan. I perused the book, and as someone who hasn't a clue it looked to me like it is well written, and should be easy for the beginner to get a grasp.

Advertisement