Coding with Ruby
-
Hi, I am new to SketchyPhysics. I have seen several topics on this board that have bits of ruby code in them. I was wondering, is there a tutorial for using code in SketchyPhysics somewhere? I have taken a few programming classes, and am pretty good at figuring things out, but none of the examples I've seen make sense to me yet. Thanks!
-
I don't know anything about ruby but maybe you're looking for this; press Window then Ruby Console.
-
Open the SP UI, select a group in your model. The ontick and ontouch fields appear at the bottom, under 'Properties' (you must have SketchyPhysics 3 X installed). ontouch code is called when the object collides with another, ontick every rate frame. Leave rate at 0 to run every frame. $curEvalGroup is always the group the code is written in, and there are a few other commands which are on various topics in the forums. The SketchUp ruby API may or may not be relevant to what you want to do, remember that almost any API code will work (some commands might crash the sim by attempting to end it). Hope this helps

-
Thanks! That should be enough to get me started. Is there a "master list" somewhere in my file I could look at to check if my variables, joint names, etc. are being recorded correctly. I have had some trouble with UI sliders not showing up when they should, joints misbehaving, and so forth.
-
If you set global variables (start with a $), you can check them out from the Ruby Console by typing them in. This'll work during the sim, and global variables will also stay behind afterwards. Btw, forgot to say the normal joint controller field also takes ruby code (Any blue field will). You can use a ';' to mark line breaks where there's only a single line to type in.
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