• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Cutbox.rb

Scheduled Pinned Locked Moved Plugins
6 Posts 3 Posters 332 Views 3 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.
  • W Offline
    WEB
    last edited by 5 Nov 2012, 23:36

    Here is cutbox.rb, an example from Automatic SketchUp:

    Create the box

    ent = Sketchup.active_model.entities
    main_face = ent.add_face [0,0,0], [6,0,0], [6,8,0], [0,8,0]
    main_face.reverse!
    main_face.pushpull 5

    Draw a line across the upper-right corner

    cut = ent.add_line [6,6,5], [4,8,5]

    Remove the new face

    cut.faces[1].pushpull -5

    Seems like it should work, but it crashes SketchUp every time. Remove the minus sign, and it acts as expected, but reverse the face and it crashes.

    Is it a bug, or is there something wrong with the code?

    SketchUp 8.0.15158; Windows 7, 64-bit

    1 Reply Last reply Reply Quote 0
    • S Offline
      sdmitch
      last edited by 6 Nov 2012, 02:15

      I tried your code several times with 5 and -5 and it never failed.

      Nothing is worthless, it can always be used as a bad example.

      http://sdmitch.blogspot.com/

      1 Reply Last reply Reply Quote 0
      • W Offline
        WEB
        last edited by 6 Nov 2012, 16:36

        Hmmmm. So, something wrong with this SketchUp installation, not with the script. Strange days indeed.

        Thanks for checking it.

        1 Reply Last reply Reply Quote 0
        • W Offline
          WEB
          last edited by 6 Nov 2012, 16:55

          Ah, ha!

          If the file is located in the plugins folder, it executes immediately upon startup, and SketchUp crashes. If it is located elsewhere and loaded via the Ruby Console, it works as expected. Good to know.

          1 Reply Last reply Reply Quote 0
          • T Offline
            TIG Moderator
            last edited by 6 Nov 2012, 17:00

            You shouldn't have a script auto-loading/executing "raw code".
            It is unlikely to do what you expect as it runs before everything is loaded/settled...

            Wrap the code inside a method, wrap that inside a module or a module/class...
            Then you can 'run' that from the Console to test, or from a menu item, toolbar etc when it's more refined...

            TIG

            1 Reply Last reply Reply Quote 0
            • W Offline
              WEB
              last edited by 7 Nov 2012, 02:32

              If I ever do anything meant to be useful, but this is an example from the book and is intended to be run in the raw.

              Back in the day, Cadence and Cadalyst had columns in each issue wherein the author presented a small-but-useful AutoLisp routine with explanations of what and why. A lot of people got the hang of AutoLisp from those columns. I don't suppose there is something similar for Ruby?

              1 Reply Last reply Reply Quote 0
              • 1 / 1
              1 / 1
              • First post
                1/6
                Last post
              Buy SketchPlus
              Buy SUbD
              Buy WrapR
              Buy eBook
              Buy Modelur
              Buy Vertex Tools
              Buy SketchCuisine
              Buy FormFonts

              Advertisement