Cutbox.rb
-
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 5Draw 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
-
I tried your code several times with 5 and -5 and it never failed.
-
Hmmmm. So, something wrong with this SketchUp installation, not with the script. Strange days indeed.
Thanks for checking it.
-
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.
-
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... -
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?
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement