ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info
  • A ruby for a text list of materials for OSX users wanted

    36
    0 Votes
    36 Posts
    2k Views
    romboutR
    Its been a while since this video, but how did you switched the color picker?
  • List of entities and organisation ?

    4
    0 Votes
    4 Posts
    855 Views
    Dan RathbunD
    And this diagram is a bit out of date. (There are some missing classes, and perhaps changes since it was drawn back in the v7 and v8 days.) http://www.sketchup.com/intl/en/developer/docs/diagram.php Also,... @iltis said: For example : ArcCurve (arcs and circles) is a subclass of the Curve class, and an edge is a part of a random curve ... Implies an incorrect assumption. The SKP document object hierarchy (ie, the model database tree) is a wholly separate construct than the Ruby class hierarchy and relationships. For example, the Sketchup::Edge class is not a sub-class of the Sketchup::Curve class. Both, are descendants of the Sketchup::Entity class. Sketchup::Curve and Sketchup::ArcCurve objects are special collection classes that connect edges together, but are not themselves an actual "model element". Sketchup::Edge objects are an actual model element, and so are a sub-class of Sketchup::Drawingelement.
  • How to apply material to a "surface"

    3
    0 Votes
    3 Posts
    705 Views
    PixeroP
    Thanks Thomthom. I already found it.
  • Pairing face problem

    9
    0 Votes
    9 Posts
    752 Views
    hsmyersH
    @sdmitch said: What defines a good or bad pairing? No overlap when moved center to center. Where 'center' is center of paired face.
  • Problems with PickHelper

    14
    0 Votes
    14 Posts
    1k Views
    thomthomT
    No worries - we all learn. Thanks for posting back your solution.
  • Starting a process in background using Ruby system()

    8
    0 Votes
    8 Posts
    2k Views
    sdmitchS
    @driven said: some zip program require the .zip extension john Not a problem with 7-Zip. The -tzip sets the output format.
  • Rescue issue

    8
    0 Votes
    8 Posts
    670 Views
    P
    It isn't that I wanted that "puts" to run immediately after the dialog is up. I put it after the show_modal to determine whether I reach that statement after the dialog is up or if I reach that statement after the dialog closes. I believe that I determined that I reached there only after the dialog closes. Therefore, an error raised in my callbacks should be caught by my rescue and it is not. I am currently working on a solution, suggested by you, to "Try putting another begin... rescue inside the callback block itself..." that is likely to solve my problem. I just wanted to understand why this didn't work and I haven't reached this understanding yet. Edit - that worked fine. My real problem is simply solved. I still don't understand why the original didn't work, but not worth any more of my time or your time. Thanks.
  • Closest face problem

    5
    0 Votes
    5 Posts
    592 Views
    hsmyersH
    @sdmitch said: @hsmyers said: how about closest pair of points? Since you are only dealing with two objects, it shouldn't matter which is sel[0] or sel[1] To find the closest corners of two objects mod = Sketchup.active_model > . > . > . > UI.messagebox "Obj0 Cor#{m} to Obj1 Cor#{n} is #{Sketchup.format_length(md)}" > Thank you for the snippet! You are correct excepting that the tool in question will move one of the two objects such that the opposing face centers are touching plus or minus an offset. Sorry for the grossly incomplete spec My plan (very fluid and quite murky ) is take the first selection as the moving object and the second as the fixed object. I've some notion about non-parallel faces requiring ( optionally ) an rotational adjustment. However it's my goal to keep things as simple as possible. My usage is to stack components together to assemble the model much like one would in actuality. Hex nuts, lock washer on threaded rod etc. Additionally, there is the self-educational aspect of solving the which selection is on first This tool already has four options and looks to acquire one or more in the future. So it seems prudent to solve this now to make ready for the unforeseen. 'Sides any excuse to cut code!!
  • Save and restore cursor?

    3
    0 Votes
    3 Posts
    506 Views
    hsmyersH
    @thomthom said: model.tools.push_tool(tool) model.tools.pop_tool http://www.sketchup.com/intl/en/developer/docs/ourdoc/tools#push_tool My thanks...and off to read the fine manual (err...what manual?) again
  • Load errors for several rubys

    9
    0 Votes
    9 Posts
    2k Views
    fredo6F
    @dermotmoconnor You were having a very old version of LibFredo6 (version 3.7, whereas current version is 6.9) and also RoundCorner. I don't know where, in 2016, you got them, if these are new installation. Anyway, that's why it did not work. Fredo
  • Attributes (auto updating)

    5
    0 Votes
    5 Posts
    990 Views
    Dan RathbunD
    @thomthom said: @medeek said: Howevever, I can't seem to figure out how this attribute is automatically updating. I came across some code not too long ago that could explain this - but there is no documentation for this. SketchUp seem to apply transformations to Geom::Point3d and Geom::Vector3d object stored in attributes. This might be what you want some times - other times if you don't want it, store them as arrays. Which is basically what I said in the duplicate thread in the SketchUp forum, ... http://forums.sketchup.com/t/attributes-that-auto-update/27840 ... which has gone beyond the original questions.
  • Staircase builder - strange scaling behaviour - Help!

    4
    0 Votes
    4 Posts
    1k Views
    D
    Staircase builder fixed! Fixed!
  • Architectural plugins

    17
    0 Votes
    17 Posts
    4k Views
    D
    Staircase builder has been revised and some bugs fixed. Try it out! db1stairbuilder.rb
  • Getting entity information in onEraseEntity observer

    2
    0 Votes
    2 Posts
    571 Views
    Dan RathbunD
    @smeyers said: I am trying to use the onEraseEntity observer, ... To be precise, this is a callback method name, of the Sketchup::EntityObserver class (and subclasses.) @smeyers said: ... which I have placed on the component, to look at the location of the entity being erased ... Okay then, it follows that at the time you've attached the observer, you should have a reference to the component instance, ... which means you can get a reference to the instance's transformation, and store it as an instance attribute of YOUR observer instance (assuming each component instance you attach a separate new observer instance to.) And then, also add an onChangeEntity callback method, that compares the current instance's transformation with the one that was stored in the observer, and if they are different, then the instance was moved, rotated, etc., so update the stored transformation in observer instance. THEN,... later when the onEraseEntity callback is fired, you'll have a copy of the deleted instance's transform stored right there in the observer instance (that is being called.) You do this by passing the component instance's transform into your observer subclass' new() constructor, which passes it into the new instance's initialize() method, (after the object has been created,) where you assign it to an instance variable. module Author;;SomePlugin class NiftyEntitySpy < Sketchup;;EntityObserver attr_accessor(;transform) def initialize(trans_arg) @transform = trans_arg end def onChangeEntity(obj) return unless obj.respond_to?(;transformation) if obj.transformation.to_a != @transform.to_a transform=(obj.transformation) end end def onEraseEntity(obj) # obj is invalid here ! # # Use transform() method or @transform reference directly, BUT # beware of making model changes inside observer callbacks !!! # end end # class # Somewhere in the code, attach a new observer instance, # to each component instance to be watched; inst.add_observer( NiftyEntitySpy;;new(inst.transformation) ) end
  • SketchUpAPI.dll - 32 and 64 bit

    4
    0 Votes
    4 Posts
    1k Views
    TIGT
    Why not separate the 'bitness' at the download-installer level, i.e. offer 32/64 bit installers ? Then what the client downlands is what they expect ? If you want to remain 'clever'... then check the bitness when the exe runs [installer-level check] and have two separate installer exe's running from those...
  • Applying Material or Color to Group

    3
    0 Votes
    3 Posts
    731 Views
    TIGT
    group.material=material Where the given material is a reference to a material already available in the model, or perhaps it's the name of an existing material, or the name of one of the standard 'color' - that might be not yet loaded: So e.g. material=Sketchup.active_model.materials['truss_wood']Where material returns 'nil' if it's not found, or a reference to that named material otherwise. Or alternatively: material='truss_wood' which will work if you know that the material named 'truss_wood' is already in the model, or perhaps... material='brown' Which uses the material named 'brown', or it makes the new material then uses it otherwise. There is a preset list of 'colors' [à la html]: http://www.sketchup.com/intl/en/developer/docs/ourdoc/color If you want a material with another color or transparent, or a texture, then you must add it to the model.materials before referencing it. http://www.sketchup.com/intl/en/developer/docs/ourdoc/materials#add You then create a new color and apply it to that new material, which by default would be black with no transparency [0,0,0,0] http://www.sketchup.com/intl/en/developer/docs/ourdoc/material#color= If you also want to add a texture to the material, use http://www.sketchup.com/intl/en/developer/docs/ourdoc/material#texture= Which specifies the image file to use, then you can edit the texture's details with texture=material.texture Using:http://www.sketchup.com/intl/en/developer/docs/ourdoc/texture#size= etc...
  • Selection error?? with Ruby API

    7
    0 Votes
    7 Posts
    989 Views
    Dan RathbunD
    No pattern. The various ways that the user can manipulate the selection set makes any order meaningless. Ie: single pick, single pick + CTRL, single pick + SHIFT, Window Right-to-Left pick, Window Right-to-Left pick + CTRL, Window Right-to-Left pick + SHIFT, Window Left-to-Right pick, Window Left-to-Right pick + CTRL, and Window Left-to-Right pick + SHIFT. Any of these, followed by any other number of them, in whatever order the user may use them, creates a selection set in which the pick order has no importance. That said, ... You question indicates you are perhaps trying to program a workflow that would better be implemented as a Ruby Tool, using a Sketchup::PickHelper. Another alternative might be a Sketchup::SelectionObserver subclass.
  • Quad chamfer corner question

    10
    0 Votes
    10 Posts
    2k Views
    thomthomT
    I guess Fredo is occupied with Animator these days. It would be great if more extensions could be made available on GitHub, BitBucket with open source licenses - allowing people to add to existing extensions instead of re-implementing similar functions.
  • Auto close UI.messagebox (Bug or feature?)

    8
    0 Votes
    8 Posts
    1k Views
    D
    @thomthom said: What would the use case for that be? If you know in advance that there will be long operation, you can prepare a message box which will come after e.g. 5-10 min. " It seems to much time to process, do you want to abort or go ahead?" The UI:messagebox is suspending the operation and the code is continuing if it is closed. (At least in windows...) But if the user is not responding for e.g. 30-60sec the message box will close automaticly and the code is continuing to process. You can't use webdialog, because in long operation SU (including WD) is not responding at all. For sure there is other workaround, or possible to do your code on other way, but this could be an "easy" solution... (I'm just an amateur engineer, not a programmer ... )
  • Minimum dimension of a component

    4
    0 Votes
    4 Posts
    662 Views
    Dan RathbunD
    My solution: def thickness(obj) ents =( obj.definition.entities rescue obj.entities ) tran =( obj.transformation rescue IDENTITY ) edges = ents.grep(Sketchup;;Edge).find_all {|e| e.start.position == ORIGIN || e.end.position == ORIGIN } if edges.size < 3 return 0.to_l # not a 3D object or edges array empty end shortest = edges.min_by {|e| e.length } shortest.start.position.transform(tran).distance( shortest.end.position.transform(tran) ) end This should work with an argument that is a definition, group or component instance. If a ComponentDefinition is passed, the transform will be the IDENTITY transform, otherwise an instance or group will be it's transform (which also might be == IDENTITY.) Within the entities the local origin is == ORIGIN, so there is no need to create any temporary point object for comparison, just to select the 3 edges. Once we have the shortest (untransformed) edge, we apply the transformation to both it's vertex positions, to account for any rotation and scaling (either uniform or not.) Now, this assumes that the shortest definition edge is always to be considered the thickness, even in the instances. But what if someone does non-uniform scaling and makes one of the longer edges shorter than the one that is supposed to be the shortest ? I suppose, if you control the definitions, you could attach an attribute to the "thickness" edge, and find it by attribute.

Advertisement