sketchucation logo sketchucation
    • Login
    ℹ️ Licensed Extensions | FredoBatch, ElevationProfile, FredoSketch, LayOps, MatSim and Pic2Shape will require license from Sept 1st More Info

    New API doc - typos and questions

    Scheduled Pinned Locked Moved Developers' Forum
    370 Posts 35 Posters 256.4k Views 35 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • renderizaR Offline
      renderiza
      last edited by

      @thomthom said:

      Animation
      http://code.google.com/intl/nb/apis/sketchup/docs/ourdoc/animation.html

      The first example on that page:

      
      >      # This is an example of a simple animation that floats the camera up to
      >      # a z position of 200". The only required method for an animation is
      >      # nextFrame. It is called whenever you need to show the next frame of
      >      # the animation. If nextFrame returns false, the animation will stop.
      >      class FloatUpAnimation
      >        def nextFrame(view)
      >          new_eye = view.camera.eye
      >          new_eye.z = new_eye.z + 1.0
      >          view.camera.set(new_eye, view.camera.target, view.camera.up)
      >          view.show_frame
      >          return new_eye.z < 500.0
      >        end
      >      end
      > 
      >      # This adds an item to the Camera menu to activate our custom animation.
      >      UI.menu("Camera").add_item("Run Float Up Animation") {
      >        Sketchup.active_model.active_view.animation = FloatUpAnimation.new
      >      } 
      > 
      

      It makes a class named FloatUpAnimation, but no mention of Animation. A bit confusing.
      Is it like the Observers?
      Should it say class FloatUpAnimation < Animation

      Hi,

      Can someone post an example of using the "nextFrame(view)" definition for moving an entity object instead of a camara?

      My objective is to create a game in SketchUp similar to the one I am making with ruby and gosu named "Resballiza" ... Here is a link for more info;

      Link Preview Image
      Resballiza vBeta 1.0

      favicon

      (www.libgosu.org)

      So far I have studied JS Move Tool by Jan Sandstrom and changed the Keys for my game style but the "Typematic effects" bug in windows is giving me a hard time.
      I have also tried to understand the scrip in the "Prince of IO" game but get lost with anything that has to do with Webdialog related scripts. Please any help in demonstrating a simple object animation that is as simple as the FloatUpAnimation scrip for the camera let me know.

      Thanks

      [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

      1 Reply Last reply Reply Quote 0
      • TIGT Offline
        TIG Moderator
        last edited by

        The menu item's code
        Sketchup.active_model.active_view.animation = FloatUpAnimation.new
        runs that class, making a new animation associated with the 'view', the class calls the lone special method nextFrame(view) - which affects the view's camera when it resets it with a new_eye position and uses show_frame to update the view...
        The ' .animation' is a method applied to a view, no a 'separate' class in it's own right...
        Your own class that you pass to the view.animation can do various things inside the nextFrame(view) method - changing the camera's eye position is just one example...

        It is an awkwardly set up method/class - but it will work as the example...

        TIG

        1 Reply Last reply Reply Quote 0
        • renderizaR Offline
          renderiza
          last edited by

          Hi,

          Thanks TIG for explaining that

          I found this topic and it solves animating an object like I wanted to but I can't make a file.rb for leading in the plugins menu. It shows me this error;

          Load Errors
          Undefined method ‘transform!’ for nil:NilClassError Loading File
          jumper.rb
          undefined method ‘transform!’ for nil: NilClass

          If anyone nows how to solve this let me know

          Thanks

          [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

          1 Reply Last reply Reply Quote 0
          • Dan RathbunD Offline
            Dan Rathbun
            last edited by

            @burkhard said:

            I could not find a send_action value for Display or toggle the Measurement Toolbar. Just VCB hide / unhide with Statusbar.

            The VCB ("Measurements") toolbar is special. (It's really a ControlBar.) There are many native tools, and Ruby Tools that rely upon it. Therefore it cannot be hidden like other toolbars. (This is by design.)

            However when you "toggle" it, instead of it being a hide/show toggle, it is actually a StatusBar dock/undock toggle.

            @burkhard said:

            Is there an undocumented Value?

            Yes the dock/undock toggle is Sketchup.send_action(24157), but on PC only.

            When you undock it from the StatusBar, it will take on the user's undocked setting, which is either floating (the default,) or docked to one of the Toolbar Containers (top, left, right or bottom.)

            Be aware that the location of the VCB is a user preference. I myself have it undocked from the StatusBar, and docked in the top toolbar container, 2nd row, 2nd position (following the Layer ControlBar.)
            If your plugin was to call Sketchup.send_action(24157), the VCB would be moved back onto the StatusBar (where I hate it.) So you risk upsetting users if you move the VCB somewhere the user does not want it.

            💭

            I'm not here much anymore.

            1 Reply Last reply Reply Quote 0
            • Dan RathbunD Offline
              Dan Rathbun
              last edited by

              @unknownuser said:

              If anyone nows how to solve this let me know

              You really should have started a new topic for your issue. (This topic about errors in the online API Dictionary.)

              You need to learn to read Exception messages. The full message will have a line number in your file where the error happen.
              You are calling the instance method transform! upon an object that you think is a Sketchup::Group instance (guessing,) ... but something had gone wrong in a previous statement when you assigned the ref to the object identifier, and some other method returned nil (the singleton instance of the NilClass.)

              It is standard in Ruby to first check for success, before continuing.

              obj = ents.add_edge( pt1, p2 )
              if obj # evals true if not false or nil
                obj.transform!(tr)
              else
                UI.messagebox("Error created the Edge object!")
              end
              
              

              I'm not here much anymore.

              1 Reply Last reply Reply Quote 0
              • Dan RathbunD Offline
                Dan Rathbun
                last edited by

                @dan rathbun said:

                @unknownuser said:

                If anyone nows how to solve this let me know

                You really should have started a new topic for your issue. (This topic about errors in the online API Dictionary.)

                Don't worry about that now (this topic is so long and cluttered it does not matter much. And likely will be locked when the next version of the online API Dictionary is updated.)

                @dan rathbun said:

                You need to learn to read Exception messages. The full message will have a line number in your file where the error happen.

                Move your file (and all your authored scripts,) into a "Renderiza" subdir of the Plugins dir.

                When debugging.. start Sketchup, then open the Ruby Console.

                Enter load("Renderiza/myfile.rb")

                You'll see a more complete Exception message output to the console.

                I'm not here much anymore.

                1 Reply Last reply Reply Quote 0
                • renderizaR Offline
                  renderiza
                  last edited by

                  Thanks Dan Rathbun for teaching me how to debug inside Ruby Console.
                  I forgor to post the topic link I was referring to…
                  http://forums.sketchucation.com/viewtopic.php?f=180&t=25498

                  I still can’t find a way to load the jumper.rb and animate the object when active but I will sonn figure it out. And I promise that for next time I will make a new topic for my issues. 👍

                  Thanks

                  [url=https://www.sketchupcode.com/:z3kqsidd]My Extensions ...[/url:z3kqsidd]

                  1 Reply Last reply Reply Quote 0
                  • W Offline
                    wood_galaxy
                    last edited by

                    Hi !
                    I haven't seen if it had benn reported but :
                    In Attribute reporting Tutorial in the function :

                    def clean_for_xml(value)
                        value = value.to_s
                        value = value.gsub(/\</,'<')
                        value = value.gsub(/\>/,'>')
                        value = value.gsub(/\"/,'"')
                        value = value.gsub(/\'/,''')
                        return value
                      end
                    

                    The last gsub make that the rest of code is a comment...

                    1 Reply Last reply Reply Quote 0
                    • TIGT Offline
                      TIG Moderator
                      last edited by

                      @wood_galaxy

                      ???
                      .gsub(/\'/,''')
                      should be
                      .gsub(/\'/,"'")
                      to 'wrap' the lone ' properly...

                      I'm unclear what you put in and what you expect to come out here 😕
                      The
                      value = value.gsub(/\</,'<')
                      could be made as
                      value.gsub**!**(/\</,'<')
                      changing 'value' rather than reassigning it to a modified version of itself.
                      You could also 'string' the gsub changes into one line...
                      return value.to_s.gsub(/\</,'<').gsub(/\>/,'>').gsub(/\"/,'"').gsub(/\'/,"'")
                      Although it's easier to read what you are doing your way.
                      It'd probably be slightly faster - but relatively unnoticeable if only a few values are processed...
                      Can you clarify?

                      TIG

                      1 Reply Last reply Reply Quote 0
                      • W Offline
                        wood_galaxy
                        last edited by

                        I thought this topic was used to identify inconsistencies in the API doc.
                        I had just noticed that the code of the tutorial was a mistake.
                        I started in ruby but I think the line "value = value.gsub(/'/,''')" contains an error.
                        Maybe I'm wrong and that it is normal that the two following functions can be found commented.
                        So TIG you say it should be .gsub(/'/,"'"). That's what I wanted to know and get noticed.
                        Sorry for the inconvenience.

                        1 Reply Last reply Reply Quote 0
                        • TIGT Offline
                          TIG Moderator
                          last edited by

                          @wood_galaxy

                          Now I understand you. 😒
                          It is indeed a typo in that example code and it should be "'" NOT ''' - the first two '' are taken as an empty string and the third one as a start of a new string - so it's not really a 'rem' - a # or =begin...=end does that in Ruby - it's simply made all of the following code into a string until it reaches the next ' which happens to be inside a comment "can**'**t", thereafter the code resumes again, but of course at that point it's garbled and will return errors and not work...
                          This type of error is sometimes hard to find but if you are using Notepad++ it'd be obvious, as the syntax highlighting would should a massive block of 'string' text where it shouldn't be, so looking at it's start/end delimiters ['] tells us what's up and what needs fixing...
                          See the original and the correction [the rest of the code - with the exception of the unnecessary $ variable in the menu setup seems OK]Capture.PNGCapture1.PNG
                          I thought you were using some of it for your own ends and having problems...
                          There are MANY errors in the API examples - it's been discussed, and indeed the main API docs used to have a user comments section at the end of each page where we pointed out the mistakes.
                          When Google moved the content these were 'lost'.
                          SketchUp still have the text but it's the way of including it that is lacking.
                          Various ways of introducing a 'wiki-like' system have been mooted, but nothing to date...

                          TIG

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            honkinberry
                            last edited by

                            I finally tracked down a bug that popped up with 7.1, but not sure if this is the best place to note it.

                            But for Transformation.scaling, both (scale) and (pt, scale) have a bug.
                            One instead needs to use (xscale, yscale, zscale), even though all 3 parameters will be the same.

                            1 Reply Last reply Reply Quote 0
                            • thomthomT Offline
                              thomthom
                              last edited by

                              Yea, that's a nasty one. It used to be in the comments of the API docs, but it disappeared some time ago.

                              Thomas Thomassen — SketchUp Monkey & Coding addict
                              List of my plugins and link to the CookieWare fund

                              1 Reply Last reply Reply Quote 0
                              • M Offline
                                mptak
                                last edited by

                                Is anyone else having a hard time accessing the Sketchup Ruby API today?

                                1 Reply Last reply Reply Quote 0
                                • thomthomT Offline
                                  thomthom
                                  last edited by

                                  Yeah, the URLs got messed up when they launched the new site. Hope the fix the forwarding soon. You find working links at the bottom of sketchup.com

                                  Sent from my LT25i using Tapatalk 2

                                  Thomas Thomassen — SketchUp Monkey & Coding addict
                                  List of my plugins and link to the CookieWare fund

                                  1 Reply Last reply Reply Quote 0
                                  • A Offline
                                    Aerilius
                                    last edited by

                                    For now, you can add ".php" in the address bar.

                                    1 Reply Last reply Reply Quote 0
                                    • thomthomT Offline
                                      thomthom
                                      last edited by

                                      index.jpg

                                      Thomas Thomassen — SketchUp Monkey & Coding addict
                                      List of my plugins and link to the CookieWare fund

                                      1 Reply Last reply Reply Quote 0
                                      • X Offline
                                        XorUnison
                                        last edited by

                                        I would assume typos can still be posted here? If so, here's one:
                                        http://www.sketchup.com/intl/en/developer/docs/ourdoc/tool#onKeyDown

                                        Tool.onKeyDown SketchUp 6.0+

                                        The onKeyDown method is called by SketchUp when the user presses a key on the keyboard. If you want to get input from the VCB, you should implement onUserText rather than this method.

                                        This method is can be used for special keys such as the Shift key

                                        1 Reply Last reply Reply Quote 0
                                        • TommyKT Offline
                                          TommyK
                                          last edited by

                                          Model Observer:
                                          onAfterComponentSaveAs(model)
                                          and
                                          onBeforeComponentSaveAs(model)

                                          The "model" parameter is actually a ComponentInstance object - the one currently selected. This is the case at least in Sketchup 2015.

                                          1 Reply Last reply Reply Quote 0
                                          • T Offline
                                            Talha222 Newcomers
                                            last edited by

                                            Yeah! really great information about documentation about API .
                                            Thank You so much i will be helpful for me

                                            1 Reply Last reply Reply Quote 0
                                            • 1
                                            • 2
                                            • 15
                                            • 16
                                            • 17
                                            • 18
                                            • 19
                                            • 18 / 19
                                            • First post
                                              Last post
                                            Buy SketchPlus
                                            Buy SUbD
                                            Buy WrapR
                                            Buy eBook
                                            Buy Modelur
                                            Buy Vertex Tools
                                            Buy SketchCuisine
                                            Buy FormFonts

                                            Advertisement