🔌 Smart Spline | Fluid way to handle splines for furniture design and complex structures. Download
  • Returning a value from a Class method

    17
    0 Votes
    17 Posts
    1k Views
    Dan RathbunD
    @johnwmcc said: If you are storing Point3d objects, would you need @contents.to_a first, before .max.y or min.y? The min and max methods come from the Enumerable mixin module. Enumerable is mixed into Array, but not Geom::Point3d, nor Geom::Vector3d. To see what modules may be mixed into a class, use *Classname*.ancestors So to answer the question, yes, or if using your own collection class, you might mix in the Enumerable module into it. @johnwmcc said: It does, for me. It was intended to select out the y coordinate (a scalar) from the point coordinates. ary = [pt1, pt2, pt3, pt4, ... ] To select the point which has the minimum y value, from an array of points, do this: miny_pt = ary.min {|a,b| a.y <=> b.y } To select the point which has the maximum y value, from an array of points, do this: maxy_pt = ary.max {|a,b| a.y <=> b.y } ... then get your thickness: thickness = maxy_pt.y - miny_pt.y To translate: [ruby:247d5h9w]ary.max {|a,b| a.y <=> b.y }[/ruby:247d5h9w], into plain English: "iterate [ruby:247d5h9w]ary[/ruby:247d5h9w], each loop compare the current member ([ruby:247d5h9w]a[/ruby:247d5h9w])'s y value, against the next member ([ruby:247d5h9w]b[/ruby:247d5h9w])'s y value, and return the member that resolves to the maximum." The comparison is defined using Ruby's comparison operator, [ruby:247d5h9w]<=>[/ruby:247d5h9w]. Remember that the entire member is returned, so later you still need to ask for just the y value. @johnwmcc said: I wasn't sure if the [ruby:247d5h9w].x[/ruby:247d5h9w] and [ruby:247d5h9w].y[/ruby:247d5h9w] methods would work on arrays, but they seem to in my example code. Because the SketchUp API adds those methods to the Ruby Array class. (It is part of making Ruby arrays compatible with API points and vectors.) @johnwmcc said: I'm unclear about the near-but-not-complete equivalence between SU [ruby:247d5h9w]Point3d(x, y, z)[/ruby:247d5h9w] and [ruby:247d5h9w]Array[x, y, z][/ruby:247d5h9w]- it seems I can use either a lot of the time, but not quite always! Read the API regarding how it adds to Array class: http://www.sketchup.com/intl/en/developer/docs/ourdoc/array
  • &lt;canvas&gt;

    19
    0 Votes
    19 Posts
    1k Views
    D
    @Greg updated script runs from the top... @TT please right up the debug info... The biggest hassle I find is injecting Web Inspector on jQ UI's [especially from .rbs files]... john
  • Problem installing joint push pull

    6
    0 Votes
    6 Posts
    4k Views
    K
    thanks for (jointpushpull) cause i have the this problem....but i want a resolve for( tools on surface) as fast as you can ....pleassssssssssse cause i have Graduation project and i use sketchup to do it cause sketchup is wonderfull....thanks
  • SketchUp and Rubies on Linux (yes, it works)

    71
    0 Votes
    71 Posts
    42k Views
    bomastudioB
    @aerilius said: In the meantime Wine has reached a state where SketchUp can be used without Microsoft's Internet Explorer, but with Wine's own opensource Internet Explorer replacement that is based on Firefox/Gecko. This means we can have all the goodness of Gecko in WebDialogs! [attachment=0:3k7jewnp]<!-- ia0 -->wine-explorer.png<!-- ia0 -->[/attachment:3k7jewnp] How to force to use Gecko instead of IE?
  • Firing Button with Modifier Key

    11
    0 Votes
    11 Posts
    913 Views
    CadFatherC
    didn't notice the thread had progressed... @tig said: You could probably also write an AutoHotKeys snippet [PC only!] which would spot a click in SketchUp with a key etc, BUT it'd be mucho complicado... ahk is quite good, i can see it possible but not too good for public consumption - with compatibility etc.. @driven said: if the button you click is a tool, you can watch for modifier keys? I assume [due to lack of use case] that you want one button for 3 tools [as example]... create a simple tool with one button... on click, [activating your tool] start a timer and watch for modifier keys... if key = a activate x if key = b activate y if you run out of time if activate z is that the sort of thing your after? or have I completely misunderstood yet again... john yes, exactly that. @jim said: There's this, but Windows only and not up-to-date and needs compiled, etc. https://code.google.com/p/eventrelay/ will have a look, thanks Jim @anton_s said: There is a way, thought it will require that your extension to require AMS Library. Easy to implement. Here is a snippet: very interesting Anton, will look into it (where's a Christmas holiday when you need it?!)
  • Catch Load Errors

    5
    0 Votes
    5 Posts
    362 Views
    tt_suT
    One thing to beware of is that Sketchup::require/load annoyingly doesn't raise ruby errors - but instead just output the error text. So you might want to hook into $stdout and $strerr to catch that as well. (This is something I suggest only because you mention it was for a personal tool.)
  • Where to find developers?

    7
    0 Votes
    7 Posts
    589 Views
    B
    Hello again. Just to let you guys know, I have posted a forum topic called "I wish to hire a developer" with a very brief description of my plugin. If any of you are interested, I can send you a more detailed description.
  • Check for existing material

    3
    0 Votes
    3 Posts
    366 Views
    PixeroP
    Thanks. Its working now.
  • [code] Win32 Moving/Showing/Hiding Toolbars and Dialogs

    91
    0 Votes
    91 Posts
    18k Views
    D
    @pcarret said: ...Is it possible to do hide minimize, maximize andclose buttonon Mac OS ? possibly, but not easily. I'm not entirely sure what your wanting to achieve... What exactly do you want to minimise/maximise? is it purely for yourself or do you want to use it in a Plugin? Some things can be done from Rudy, others by using AppleScript or by modifying the nib files... Outline what you want to do and I'll try and help... john
  • Plugin Developer Wanted ASAP

    5
    0 Votes
    5 Posts
    465 Views
    D
    hi jimmy, most people are enjoying xmas with family... you may snag someones interest on a visit if you supplied a working example... it wouldn't need to be your clients product, but a skp with representative scenes and a similar DC, either from scratch or from 3d Warehouse... I'm not one of the "great Ruby Developers in the forum" and work on mac, but I would have had a play with some ideas if it was easy to hide from the family... john
  • Sketchup Crash Webdialog

    17
    0 Votes
    17 Posts
    1k Views
    L
    the crash does exist. what is the solution?
  • File.writable? false for DOCUMENTS folder

    6
    0 Votes
    6 Posts
    532 Views
    thomthomT
    Ruby's file handling under Windows is frustratingly flaky. We have reported a number of issues to the Ruby developers and I'd encourage people to file whatever you find. I usually wrap file handling in a begin, rescue block instead of testing if a while is writable - simply because Windows file handling is unpredictable.
  • Arrange component names

    13
    0 Votes
    13 Posts
    1k Views
    M
    SDMitch (Mitch?), @sdmitch said: Tried your code and found two problems. if(reInc.match(cd)) needs to be if(reInc.match(cd.name)) Thanks for the catches. I edited & corrected the second post. I tested mine with a string array, not an array of cd's. Hence, no name prop. @sdmitch said: the prefix of the new name entered gets incremented as well. That's why you had the new cd name assign at the end of the loop. That's why I shouldn't change code after I've tested it... Thanks, Greg
  • Add column in SU file name

    8
    0 Votes
    8 Posts
    738 Views
    D
    @dan rathbun said: ...But how to do that for both OSX and Windows in the same format ? on a mac you can add tags to any file, but for the OP's request, why not just append the filename with a serial number? john
  • Reading out origins of nested components

    3
    0 Votes
    3 Posts
    452 Views
    X
    I was wondering if there was a way to do it without going through all parent origins as I feared that might become very complicated, I didn't think about doing it like that (recurse) though. Your solution is right on the spot! Also I didn't knew about the grep method yet, so thanks for that as well.
  • Extension rbz maker

    38
    0 Votes
    38 Posts
    5k Views
    TNTDAVIDT
    Problem solved thank you for your help
  • Glue a text to a face in ruby

    2
    0 Votes
    2 Posts
    474 Views
    TIGT
    You cannot 'associate' text with geometry at its insertion point, through the API. It has long been asked for... There are a couple of workarounds... Make it as 'flat' 3d-text [or normal Text] - make it inside a component definition, which has is2d gluing behavior, add_instance of it at the face.bounds.center point, then use instance.glued_to=face so it moves with the face...
  • Dynamic components double action

    16
    0 Votes
    16 Posts
    1k Views
    G
    I have now coded the dynamic attributes into my plugin for bifold doors. There was a gotcha that I wasn't expecting. It took me a lot longer to understand what was going on. I started out just calling the script over and over to create up to 4 doors which handles a double bifold. Three problems, code was starting to get messy, execution was starting to take more time and memory and storage was increasing too much. So I now create 1 door create a second instance then flip it. Then take the bifold (2 doors) and instance it and flip them. This caused havoc. As soon as I tried (in code) to change the axes of the second door the door no longer behaved as expected. Turns out that Rotz on the flipped door changed from 0 to -180 and all I did was flip the door. Of course if you flip the door in the editor the rotz stays at 0. flip the sibling tr = Geom::Transformation.scaling(sibling.bounds.center, -1, 1, 1) sibling.transform!(tr) If I change axes after flipping door then the door moved to an unexpected place. If I change the axes before flipping the door the axes gets flipped as well causing the door to move over. The solution I came up with was to create a parent container to hold the door. Flip the door. Since the parent's rotz stays at 0 I could reference the grand parents angle. Creating another level of nested containers effectively insulates the animate coding from the effects of flipping the door.
  • How should i use s and t scale factor from SUTexture ?

    2
    0 Votes
    2 Posts
    364 Views
    tt_suT
    For the record, ongoing conversation at: http://forums.sketchup.com/t/how-should-i-use-s-and-t-scale-factor-from-sutexture/4589/6
  • Material observer behaviour on OS X

    4
    0 Votes
    4 Posts
    405 Views
    tt_suT
    @eneroth3 said: <offtopic> There's a Materials.current method ?? For my latest project I created a materials observer listening to active material change just so it could be assigned to a variable so I later could know what material is active. How could I have missed this? cleaning up some code </offtopic> Beware that the material might not be in the model yet - in older version of SketchUp it can cause crashes if you try to apply the material to entities.

Advertisement