⚠️ Important | Libfredo 15.6b introduces important bugfixes for Fredo's Extensions Update
  • Zoom in on object

    7
    0 評價
    7 貼文
    3k 瀏覽
    Al HartA
    Here is the code which makes this work. If points to the center of the first item in the selection set, then uses SketchUp zoom to selection to do the zoom. It zooms to the third, desired, image in the post previous to this one. def zoom_selection # zoom to selection by rotating camera first model = Sketchup.active_model entity = model.selection[0] if (!entity) do_error("Nothing selected") return end#if view = model.active_view camera = view.camera eye = camera.eye target = camera.target up = camera.up target = entity.bounds.center camera.set(eye, target, up) # point to selection view.zoom(model.selection) # then zoom end#def
  • Cleanup on SketchUp close problem

    2
    0 評價
    2 貼文
    245 瀏覽
    thomthomT
    Yea, onQuit() has problems under SketchUp. Under OSX it isn't called at all. If you search the forum for onQuit you'll find a couple of threads on the topic. (Sorry, don't have the links at hand.)
  • [Tutorial] uvq coordinates, or: The Magic Q

    5
    0 評價
    5 貼文
    3k 瀏覽
    A
    I've read UVW somewhere as well. We have to find out more. For UVW mapping Wikipedia says no more than: "the third dimension allows texture maps to wrap in complex ways onto irregular surfaces" A Google search shows UVQ is mostly related with SketchUp, and that the names of these coordinates are not very standardized (just letters in the alphabet before x,y,z), for example there are also Q,R,S,T. There's an interesting explanation on gamedev.stackexchange, that the W allows to optionally apply a transformation matrix before rendering a texture to screen (for example for animating textures without expensive moving of the texture on every entity).
  • Review of Plugin/NameSpace/Extension Format

    5
    0 評價
    5 貼文
    272 瀏覽
    K
    Thanks Dan for the review and changes. I have adjusted my files to include your suggestions and when I have a how to vidio completed I will post in the plugin section. Also I expect to be back for help on putting my Joint Tools under the namespace umbrella as I have just started that process. Keith
  • Create Text-object

    3
    0 評價
    3 貼文
    500 瀏覽
    T
    Of course you´re right, I only browsed the Entity-Classes, not the Collection-classes, although I already created some faces using add_face...shame on me. thx for your quick response!
  • Nested classes and scope - a puzzle

    12
    0 評價
    12 貼文
    1k 瀏覽
    Dan RathbunD
    Another solution, IF the outer module does not contain instance methods, is to include it into the inner module: module TT_Test module Foo;;Biz include Foo def self.prod puts CHEESE end def self.q p Module.nesting end def self.other p Bar end end # Biz end # TT_Test I've seen weirder stuff in the standard Ruby Lib extensions, than that.
  • PLUGIN CONFERENCE IN MADRID. SEPT 2012

    2
    0 評價
    2 貼文
    174 瀏覽
    Rich O BrienR
    Hi Alex, Your first few posts here are moderated so try not to post consecutively as there is a delay from posting to approval. Hope the conference is fun! Rich
  • Draw shapes in a shape

    4
    0 評價
    4 貼文
    168 瀏覽
    TIGT
    Sorry we muddle you with using edge/line - I always meant 'edge' - never 'line' as in "[point,vector]". Can you at least work out the bounds of what's been made ? Then add some grouped faces with it... Then we can talk again about trimming/not-overlapping them with your edges collection
  • Drop object with centre of gravity?

    10
    0 評價
    10 貼文
    484 瀏覽
    TIGT
    I wrote a tool that using 'slices' to find an object's [approx] center-of-gravity... You could project every vertex.position in the object down to the surface below as a raytest using Z_AXIS.reverse. The one with the shortest distance to raytest[1] gives the vector to move it down vertically, so it touches the surface as if it were dropped vertically. You really ought to make points along all edges in the object at minuscule centers and test these as a surface might well have a 'bump' that avoids vertices but which would affect the object. BUY another alternative might be to do the nearest vertex drop and do a temp grouped intersect between the two objects, if there's a result then there's a 'bump' that the object should have caught on and you can shunt the object up to suit that,,, Now you have an 'anchor' point of sorts. You know the vector from that 'first point of contact' and the CoG. If it's parallel with the Z_AXIS it's balancing on a pinpoint - but chances are it's not ! So... Rotate the object around the cross of Z-AXIS and that vector by small incrementing angles. Each time do a temp intersect with the surface. If there's a result back up in 1/10 increments until there's virtually none. The object is now on the surface and tilted downwards towards it CoG until it rests on the surface. If the CoG is not vertically on the vector from the 'first point of contact' to this 'second point of contact' then the object needs to rotate yet again - around this vector - again testing for intersections until a 'third point of contact is found'. Now the object is resting on the surface with three points of contact and the CoG is somewhere within that triangle of points - it is stable. If in any of the two points of contact steps the CoG of a vertically aligned with the vector you can choose for a 'dangerous stability' - balanced on a 'knife-edge' - or choose to tilt randomly in either direction until a 'hit' with an intersect give another point that is stable... It's actually very complex as the initial anchor might no longer be on the surface after the second or third tilt !
  • How to reset an incremental value used in an if statement?

    7
    0 評價
    7 貼文
    1k 瀏覽
    Dan RathbunD
    My solution is more readable. Let me rewrite it, thus: #default intermediate column placement resetfix =( @fix ? @fix ; @flenx/2-@fcol ) if ... # @fix gets changed here end @fix = resetfix # a new if statement; if ... # @fix gets changed again ... end @fix = resetfix # ANOTHER if statement that may change @fix;
  • Model attributes and importing

    7
    0 評價
    7 貼文
    240 瀏覽
    thomthomT
    @joshb said: Thanks thomthom! That is exactly what I needed to know! Right now users are just going through the SketchUp GUI File, Import to do their work. I'm going to look at the observers, perhaps DefinitionsObserver.onComponentAdded to see if I can do my merging there. Thanks again! Josh Beware! UI import is not the only thing that might import a model. If you react to an observer event you can crash SketchUp. You may also interfere with some other operation. Setting attributes is something that can be undone. And starting an operation in the middle of another one will interfer and break the first one. So if you react to an observer event and modify anything - you might break the undo-stack, you might break an operation of another plugin or native function - or you might even crash SketchUp. My recommendation for observers is to only read data. If you need to react with model changes, cache it for a later time when you know it's safe to modify your model. For instance, you detect a model import, you cache what definition that was and wait with the merge until your plugin need to access any of your data. Another thing: be very careful what your observers do. Make them do as little as possible. Events can trigger in the thousands in some scenarios and then it doesn't take much to bog down a model. Refer to this list of observer issues which I've been trying to chart: http://www.thomthom.net/software/sketchup/observers/
  • Storing Data

    3
    0 評價
    3 貼文
    156 瀏覽
    TIGT
    Let's assume your 'box' is a component. Let's assume there is a value 'x' thet you want it to 'remember' for another time... You have a reference to the definition - let's say it's ' defn'... Then this code remembers it: defn.set_attribute("Cheez_Data","x",x) Provided that you save the model the next time you want to access the SKP and that definition - perhaps via a selected instance... like defn=model.selection[0].definition - after you test for it being a suitable instance etc... You could use: x=defn.get_attribute("Cheez_Data","x",0) Here it's set to return 0 if it's not been set before - otherwise it's 'nil'. You can store loads of different data in an object's attribute-dictionary. The data types can be integer, float, string, boolean, array... A hash has to be stored as an array for the 'set'... and reconstructed into a hash after the 'get'. You could attach data to the the model itself, BUT since you are going to change a specific definition you might be best storing it there... You can attached attribute data to most 'types', but some like geometry are more 'transient'...
  • Array woes

    4
    0 評價
    4 貼文
    127 瀏覽
    TIGT
    Yes, it'd return an error or if @ip1 is nil then it might be seen as equal to an empty @pts[] ? If you are testing something that might be nil it's a good idea to check it exists first...
  • Ruby api - Get the thickness of component

    4
    0 評價
    4 貼文
    252 瀏覽
    N
    @TIG Thanks for the great long and damn useful answer. I will try it today
  • Forcing Sketchup to use IE8 and other Web Dialog problems

    24
    0 評價
    24 貼文
    1k 瀏覽
    Dan RathbunD
    Well.. it returns white on Win7 because that IS the system dialog background color "out of the box". (One reason I hate Windows 6+ is they try to make dialogs look like webpages!) Anyway.. a user can set their own theme, or download a premade theme from the Web, in which the dialog background may not be white at all. The other day, on XP, as a test I changed my system dialog color to Purple, just to test that method, and it worked, it returned the purple color that I had set. And SketchUp also used that color for background of it's dialogs and toolbars, etc.
  • [Webdialog] Javascript lerts with object bypass

    6
    0 評價
    6 貼文
    403 瀏覽
    Dan RathbunD
    @chrisglasier said: Did not mean to offend! Ya' did not... It was a half-tease... ... and a half devil's advocate, asking the obvious question (that a novice might ask.).
  • [Code] WebDialog communication

    35
    0 評價
    35 貼文
    5k 瀏覽
    alexschreyerA
    Great idea to clean up the web-dialog interfacing! Let me throw one more idea in there: Apparently post_url does not accept any returned data (it just opens it in the embedded browser window). Might be nice to have get_url and post_url functions that at least return the data. That could even be expanded into get_json and post_json . Of course, jQuery will do that but a native way might be neater. It's definitely on my feature request list for SU... Cheers, Alex
  • SU SDK and geometry creation

    11
    0 評價
    11 貼文
    350 瀏覽
    Dan RathbunD
    I could see doing that, so as to work with skp files in a normal Ruby session (outside of embedded SketchUp Ruby.) But D.M. says that his goal is to work inside SketchUp embedded Ruby. What's the point ?? The SDK is a subset of the Sketchup engine. Inside SU it is already loaded into memory, so you do not need reader and writer DLLs at all. Just use IT. There IS an example in the SDK that shows how to.. and the first step is to always get a handle on the Sketchup application.
  • EntitiesObserver and Attributes - work around

    21
    0 評價
    21 貼文
    3k 瀏覽
    R
    Ok. hopefully there is a solution. If I find one I will return...
  • State of Observers Redux — 18 August 2011

    30
    0 評價
    30 貼文
    6k 瀏覽
    thomthomT
    Added public bug tracker to the BitBucket repo: https://bitbucket.org/thomthom/sketchup-observers/issues?status=new&status=open People can add reports of broken observer events there.

Advertisement