⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
  • How can a dialog be made modal on Mac

    16
    0 Szavazatok
    16 Hozzászólások
    2k Megtekintések
    thomthomT
    Ah, as it turns out - I made the modal feature only for TT::GUI::Inputbox. (What I use with CleanUp) My approach to "modal" was to push a Tool to the tool stack which will draw the dimming screen. It also detect if the user activates another tool which it takes as a cancel action to close the dialog. There is much to be improved with this method. (For instance, I think you can block the Orbit tool from activating) https://bitbucket.org/thomthom/tt-library-2/src/7462992bf4f3/TT_Lib2/modal_wrapper.rb In either case, my TT:GUI::Window class is something you can't easily swap in for UI::WebDialog. I have a set of Ruby classes for Button, Checkbox etc which generates the HTML and JS for you. As well as pre-defined styling. To add custom behaviour you must attach JS scripts. It's far from complete and likely to change. But for the sake of it - Hello World example of my TT:GUI::Window class: <span class="syntaxdefault"><br />module TT_Test<br /><br />  def self</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">create_window<br />    options </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{<br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword">;</span><span class="syntaxdefault">title </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> </span><span class="syntaxstring">'Hello Window'</span><span class="syntaxkeyword">,<br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword">;</span><span class="syntaxdefault">resizable </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> false</span><span class="syntaxkeyword">,<br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword">;</span><span class="syntaxdefault">width </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> 300</span><span class="syntaxkeyword">,<br /></span><span class="syntaxdefault">      </span><span class="syntaxkeyword">;</span><span class="syntaxdefault">height </span><span class="syntaxkeyword">=></span><span class="syntaxdefault"> 200<br />    </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">    window </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> TT</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">GUI</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Window</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> options </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    window</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">theme </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> TT</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">GUI</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Window</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">THEME_GRAPHITE<br />    <br />    button </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> TT</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">GUI</span><span class="syntaxkeyword">;;</span><span class="syntaxdefault">Button</span><span class="syntaxkeyword">.new(</span><span class="syntaxdefault"> </span><span class="syntaxstring">'Close'</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">)</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">{</span><span class="syntaxdefault"> </span><span class="syntaxkeyword">|</span><span class="syntaxdefault">control</span><span class="syntaxkeyword">|<br /></span><span class="syntaxdefault">      control</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">window</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">close<br />    </span><span class="syntaxkeyword">}<br /></span><span class="syntaxdefault">    button</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">size</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> 75</span><span class="syntaxkeyword">,</span><span class="syntaxdefault"> 28 </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    button</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">right </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 5<br />    button</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">bottom </span><span class="syntaxkeyword">=</span><span class="syntaxdefault"> 5<br />    window</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">add_control</span><span class="syntaxkeyword">(</span><span class="syntaxdefault"> button </span><span class="syntaxkeyword">)<br /></span><span class="syntaxdefault">    <br />    window</span><span class="syntaxkeyword">.</span><span class="syntaxdefault">show_window<br />    <br />    window<br />  end<br /><br />end </span><span class="syntaxcomment"># module<br />&nbsp;</span><span class="syntaxdefault"></span> I've found that instead of fighting against this problem I change the code flow to not require modal windows. Often it can be done - just needs a different thinking. Which is why I haven't worked further on the issue.
  • Save coordinates in an array

    17
    0 Szavazatok
    17 Hozzászólások
    782 Megtekintések
    M
    Thank you so much, Dan. Your tips solved the problem. Now, I have the program running, but I don't get the correct coordinates. I was expecting to get some positive and some negative, according to where I am from the axes. I clicked the 4 corners of the screen and I got the following, which doesn't look right: @unknownuser said: x: 46 y: 48 z: 48 x: 53 y: 52 z: 46 x: 54 y: 57 z: 46 x: 52 y: 46 z: 56
  • Trimble??? - the beginning og the end!?

    5
    0 Szavazatok
    5 Hozzászólások
    267 Megtekintések
    R
    I think Im calmed a little down for now...
  • Count Certain Shapes

    8
    0 Szavazatok
    8 Hozzászólások
    298 Megtekintések
    TIGT
    @michaelazer said: Thanks, TIG. I think I mixed up with the logic of Sketchup. (1) Does count=faces.length count all faces on the screen OR in the array I made? It's 'faces' in the array you have made - so it counts just the faces that match your pattern. (2) If a user deletes a face manually, will it be removed from the array? OR only from the screen? When a users erases a face it vanishes from the model's entities collection. If you have made the array of faces before the deletion then the now deleted face is still counted - because the array is a list of faces that matched the pattern at the moment the list was made... You can check for each face's 'validity' before 'counting' thus: count=0; faces.each{|face|count+=1 if face.valid?} Now 'count' only includes 'valid' [i.e. NOT-deleted faces. Again this is dependent on the moment you make the count. The array 'faces' includes all matching faces at the moment the list is made. The 'count' is now the number of valid faces within that array [they were check to be 'matching']. If the user erases another face after the count is made you are again 'out of step'. Similarly if additional matching faces are added after the matching 'faces' array is compiled the list is incomplete. It's easy enough to have some code to compile a list of matching faces and count valid ones at various stages of your tool's use, just remember to do it at the appropriate moment to avoid having out of date information in the array or count...] (3) If the answer to (2) is "only from the screen" does this mean that if I re-draw the array, will the shape that the user deleted get re-drawn? Thanks, again.The array is only a list of faces that match your pattern. You can't 'redraw the array' as it's a list of references to faces only. If a face is deleted from the model you can no longer access its information as it no longer exists. If you mean 'remake' the array you can just rerun the code (remembering to empty the array first with faces=[]), and the new list will no longer include the face that was erased. If you want to remember faces even if they are gone you can make an array of say 'face_points' and later use those to recreate a missing face... this is porbably more complex than you want... for each face face_points=[]; face.vertices.each{|v|face_points<<v.position}
  • Followme - hang

    10
    0 Szavazatok
    10 Hozzászólások
    335 Megtekintések
    W
    Hi , Dan unfortunately , i've removed all the ".mm" in your code , if the diamter of the circle is 50 mm , this will hang , but it's fine if the diameter is 20mm , this is the reason why i said it seem to be related to the diameter of the circle instead of decimal place or array type.
  • Geometry, Transformation, and Scaling

    5
    0 Szavazatok
    5 Hozzászólások
    576 Megtekintések
    A
    Tnks! All logical and useful
  • BitBucket Basics / Git Tips

    6
    0 Szavazatok
    6 Hozzászólások
    618 Megtekintések
    Dan RathbunD
    Great Idea, I was wondering how to do that. Done.
  • How to rotate an object in ruby?

    2
    0 Szavazatok
    2 Hozzászólások
    132 Megtekintések
    thomthomT
    Geom::Transformation.new( origin, zaxis ) <- that isn't a rotation transformation. To rotate you must use one of these formats. Geom::Transformation.new( pt, axis, angle ) Geom::Transformation.rotation( point, vector, angle ) https://developers.google.com/sketchup/docs/ourdoc/transformation#rotation But what is not clear is this: "how to rotate an object in the direction of the cursor" What do you mean by this?
  • Can Sketchup receive Window message?

    7
    0 Szavazatok
    7 Hozzászólások
    239 Megtekintések
    thomthomT
    @debbie said: @thomthom said: Maybe you can make a Ruby C Extension work for you? Ruby C extension? seems useful! thanks. I made a Hello World project for getting Ruby C Extensions to work under SketchUp: https://bitbucket.org/thomthom/sketchup-ruby-c-extension
  • Complete Crash?

    4
    0 Szavazatok
    4 Hozzászólások
    150 Megtekintések
    A
    OK...it doesn't crash if just before showing the savepanel I put a line of code to show a simple messagebox: then the savepanel shows. Although the messagebox is nowhere to be seen. Then I tried this code: if UI.messagebox("Save results to file?", MB_YESNO) == 6 savePath = UI.savepanel("Save results file",model.path,"Sunlight analysis.csv") # If the user doesn't press cancel; if savePath outfile = File.new(savePath, "w") outfile.write(allResults) outfile.close() end end Now when the execution reaches this point SU suddenly switches program, i.e. as if someone had pressed Alt+Tab. It's still there, but I have to reopen it. And the messagebox still isn't anywhere, hence neither is the savepanel. I just seem to have gotten the UI very confused in general.
  • Overflow bug?

    2
    0 Szavazatok
    2 Hozzászólások
    136 Megtekintések
    daikuD
    Probably the result of dividing by "almost zero". Which in turn could result from a floating point roundoff error.
  • Intersect_with problems

    3
    0 Szavazatok
    3 Hozzászólások
    848 Megtekintések
    sdmitchS
    Weird indeed but moving the prism up 1mm solves the problem.
  • .edges returns a face

    9
    0 Szavazatok
    9 Hozzászólások
    373 Megtekintések
    K
    Dan - the bug came immediately after: if e.is_a? Sketchup::Edge ... it was very strange, and as I said, happened once in a great while - I couldn't figure out how to make it happen on command.
  • Basics - creating components and pushpull direction

    8
    0 Szavazatok
    8 Hozzászólások
    421 Megtekintések
    TIGT
    Getting there... When you make a new definition add geometry to it immediately. Empty definitions/groups don't survive in code... Try something like: unless unit_block=def_list["unit_block"] unit_block=def_list.add("unit_block") ### add geometry to unit_block.entities ### add description to unit_block.description ### etc end ### now add instance, knowing the definition exists and has geometry which might be clearer? You don't need to add geometry to the component if it already exists ! Another tip - use Timber.new(bPD,bPW,bPL) not Timber.new (bPD,bPW,bPL) don't leaves a space in front of the arguments' ()
  • Puzzling position of axes when inserting a component

    9
    0 Szavazatok
    9 Hozzászólások
    384 Megtekintések
    Dan RathbunD
    @tim said: ..., for this case as an example, one could actually create a blank page and set it up as needed rather than having a rather cockeyed 'new' message that actually creates, does setup that isn't wanted and then leaves one to work out how much to undo… right now it isn't 'new' but 'copy'. Well we are supposed to be able to do this with the flags argument in the add() method. see page.update() for an explanation of the flags. What it is missing, is a camera argument. It assumes you wish to copy the current view.camera So you have to modify the new page's view / camera after it is created. (It gets set to the current selected page, whether you want this or not.)
  • Curved surfaces with Ruby

    8
    0 Szavazatok
    8 Hozzászólások
    1k Megtekintések
    thomthomT
    @alexmojaki said: Also glad to understand what soft and smooth edges are. For a detailed breakdown of what each property does (soft and smooth has very distinct functions) check out this article: http://www.thomthom.net/thoughts/2012/06/soft-vs-smooth-vs-hidden-edges/
  • Multiple attribute dictionaries created

    6
    0 Szavazatok
    6 Hozzászólások
    720 Megtekintések
    Dan RathbunD
    @archidave said: ... Since I was thinking along these lines, I was expecting the attribute dictionaries to behave in a similar way to creating instance variables; ... Nothing is stopping you from doing so. You can create a custom class (within your plugin namespace module,) for a Wall, that has instance variables, that are loaded from an entity's attribute dictionary. If you just save the values as an array, into a single attribute, you can use Ruby's iterator loops or methods, to load the values into instance variables. So the names of instance variables, are defined by a literal array inside your class, an the initialize method iterates this array, matching it's indexes, with the indexed values in the dictionary array. module ACME module BIMinator DictName = 'ACME_BIMinator' class Wall Atts = [;area,;thickness,;paint] attr_accessor( *Atts ) # expand array Atts to parameter list def initialize(entity) @prop = entity.get_attribute(ACME;;BIMinator;;DictName, 'properties') Atts.each_with_index {|att,i| method("#{att.to_s}=").call(@prop[i]) } end end # class end # BIMinator end SO.. the actual attribute names are defined in ONE place, your custom class.
  • Vertical anchoring of 3D text

    6
    0 Szavazatok
    6 Hozzászólások
    3k Megtekintések
    A
    @tig said: The text-string affects the result. "V\nE\nR\nT\nI\nC\nA\nL" V E R T I C A L That did it! thank you so much!
  • How to get entities from selection?

    11
    0 Szavazatok
    11 Hozzászólások
    811 Megtekintések
    thomthomT
    Sample test model?
  • Get Current Axes Position/Orientation

    10
    0 Szavazatok
    10 Hozzászólások
    3k Megtekintések
    thomthomT
    @dan rathbun said: Just a note, that in playing around (I did not realize this before,) that custom "User" Axes can be saved within a ScenePage. Yea, I often set up Scenes that adjust just the axis. All though, with SU8 now automatically adjusting the model axis to match component axis there's less need of it for my use. Works well when you have a building with axis in various directions.

Advertisement