SketchUcation Plugin Store

 

 

SketchUp RUBY API Wishlist [way of coding wishes, please]

Open method (or Edit Component)

Postby MarcioAB » Tue Dec 16, 2008 11:42 am

Access to Model.open ( open method of Model class ) as presented in this topic1 and this topic2.

Thank you
MarcioAB
 
Posts: 50
Joined: Mon Oct 20, 2008 1:45 am
Location: Sao Paulo (23:37 S 46:38 O)

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby jessejames » Sat Jan 10, 2009 3:32 am

hello Scott,
Thanks for your interest in helping out. That game you made was pretty cool.

I would like to see some convience methods like in the Blender API. This may not be appealing to Gurus but might be quite helpful to the new rubyist. Something like...

Code: Select all
obj.LocX --> (0,0,0)
obj.LocX += 20
obj.LocX --> (20,0,0)
obj.loc = 0,0,0 #set loc
obj.getMatrix()


i am also wondering why there is no way to do simple and dirty animations, like...

Code: Select all
Loop
    obj.LocX += 10
    sleep(.02)
    SU.Redraw()


I really like most of the SU API's layout compared to Blender, except the Transformation module, it seems a little clumsy. But i might be missing something important. I am not an engineer, just a real brave lad, thats all.

So if you want to enlighten me, feel free :D
Always sleep with a loaded gun under your pillow!
jessejames
 
Posts: 166
Joined: Sat Dec 27, 2008 3:30 am

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby daiku » Thu Jan 15, 2009 6:56 pm

I'd like to be able to specify the font size for text objects.
daiku
 
Posts: 213
Joined: Mon Nov 12, 2007 2:54 pm
Location: Minneapolis
Name: Clark Bremer

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby tomot » Fri Jan 16, 2009 11:22 pm

I would like to see a GUI added to the Ruby API. This has been sadly lacking from when the Ruby API was first added to be the scripting language for SU. Please add this to your SU8 wish list. Failing that, perhaps an easier task maybe to add a Python API with GUI to SU. I see no reason why SU can't function with 2 scripting languages.
tomot
 
Posts: 615
Joined: Mon Apr 07, 2008 12:18 am
Operating system: Windows
SketchUp version: 8
License type: Free/Make
SketchUp use: architecture
Level of SketchUp: Advanced

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby thomthom » Sat Jan 17, 2009 12:06 pm

A GUI to the API what do you mean? As oppose to Webdialogs?
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17907
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby jessejames » Sun Jan 18, 2009 1:08 am

I think what tomot wants is a GUI toolkit built-in for SU scripting. Web dialogs are quite lacking. Scriptwriters need widgets!

Text, Listbox, Entry, Button, Frame, Toplevel, Spinbox, Label, Scrollbar, Dialogs, RadioButton, CheckButton, Menu, Scale, LabelFrame, Canvas, OptionMenu, PanedWindow, Image Support

Python has all this built-in to the language as Tkinter(Tk widgets) An easy to use GUI builder with every thing a script writer/SUupper needs, amoung others.

I will also volunteer to do most of the dirty work to grow a Python API(and i could get others to help also -- SU DEV would not have to do much).

One of the best things about Python as compared to Ruby is the tons and tons of great documentation. This would be very appealing to those who wish to script but cannot find good docs for Ruby. And the built-in GUI is just icing on the cake!
Always sleep with a loaded gun under your pillow!
jessejames
 
Posts: 166
Joined: Sat Dec 27, 2008 3:30 am

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby tomot » Sun Jan 18, 2009 4:18 am

jessejames wrote:I think what tomot wants is a GUI toolkit built-in for SU scripting. Web dialogs are quite lacking. Scriptwriters need widgets!

Text, Listbox, Entry, Button, Frame, Toplevel, Spinbox, Label, Scrollbar, Dialogs, RadioButton, CheckButton, Menu, Scale, LabelFrame, Canvas, OptionMenu, PanedWindow, Image Support

Yes that's exactly what I meant. Here is a Google definition of Webdialogs:

By using powerful cross-browser Javascript and CSS, WebDialog renders dialogs, windows and even modal dialogs inside the browser window. It avoids the problems caused by restrictive popup blockers and gives you greater flexibility when designing your web application's user interface.

That's not going to help my scripting endeavors without now also having to learn Javascript and CSS.

JJ you put a generous offer of the table, I would like to contribute where ever possible. Lets hope we can get ScottLininger on board? Because without some support from Google I can't see this going very far.
tomot
 
Posts: 615
Joined: Mon Apr 07, 2008 12:18 am
Operating system: Windows
SketchUp version: 8
License type: Free/Make
SketchUp use: architecture
Level of SketchUp: Advanced

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby thomthom » Sun Jan 18, 2009 1:49 pm

Coming from a webdesign background I forgot that HTML, CSS and JS is also a thing to be learnt. I see your point. I was just confused because you allready have most of the controls JJ mentioned. But as you say, it a new set of languages to learn.

As for the lacking set of widgets, there are many frameworks that can easily be added on to extend the widget collection.


But I'm puzzled by another thing, tomot; you would be willing to learn Python to make a GUI, but not CSS+JS?
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17907
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby tomot » Sun Jan 18, 2009 5:31 pm

thomthom wrote:But I'm puzzled by another thing, tomot; you would be willing to learn Python to make a GUI, but not CSS+JS?


It may surprise you Thomas; I'm not a Ruby programmer or a LISP programmer nor GDL http://en.wikipedia.org/wiki/Geometric_ ... n_Language programmer.
I could not sit down with a text editor and bang out a new Ruby without at the same time having open on my Desktop at least 2 or 3 existing Ruby's whose content may help form the basis of a new ruby idea I'm trying to bring into being. Then through lots of cutting and pasting of code and many trials and errors of loading and reloading the same script into the console, over and over again, I eventually arrive at the solution. The programming related lines I can't solve I usually bring forth to this forum for help from those that have real programming knowledge, and I'm always grateful for their support. The following piece of code was provided by Jim Foltz.
Code: Select all
normal = useanamehere.normal
normal.length = -$xxx
tr = Geom::Transformation.translation(normal)
group.transform! tr

This small piece of code has been invaluable, its used repeatedly to offset distances that make 2d lines into 3d, planes, without it Window and Door Tools could not exist.

Its also one of the reasons I'm grateful that not each Ruby contributor decides to use obfuscation on their code. Obviously if everyone did this, this community would not have benefited from my Window and Door Tools scripts.

If this Python API works out, I will approach scripting with it the same way I do with Ruby. Firstly I would ask for some simple existing Ruby's to be converted to Python. I would use that as a springboard to start scripting in Python.
tomot
 
Posts: 615
Joined: Mon Apr 07, 2008 12:18 am
Operating system: Windows
SketchUp version: 8
License type: Free/Make
SketchUp use: architecture
Level of SketchUp: Advanced

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby jessejames » Sun Jan 18, 2009 6:51 pm

tomot wrote:...I could not sit down with a text editor and bang out a new Ruby without at the same time having open on my Desktop at least 2 or 3 existing Ruby's whose content may help form the basis of a new ruby idea I'm trying to bring into being. Then through lots of cutting and pasting of code and many trials and errors of loading and reloading the same script into the console, over and over again, I eventually arrive at the solution.


I agree tomot,
The work flow for writing scripts in SU is frustrating. This must be improved. Nobody(pro or not) has the ability to write bug free scripts in one go.

1.) A built-in text editor(very simple) with syntax highlight so a new scripter can get started easily
2.) a multi-line Console(for testing snippets with proper indentation) to replace the single line Ruby Console
3.) a real GUI toolkit(Python has TK built-in to the language)
4.) a good SU specific scripting tutorial.( most important )

These are the key to happy SU scripting.

The current work flow is painful and a real determent to all who wish to learn, or write scripts for SU. Something must be done. Scripting must be made available to all, not just a few professionals at the top.

SU design is flawless everywhere but this area. Once we can fix this, the full power of SU will be available to all.
Always sleep with a loaded gun under your pillow!
jessejames
 
Posts: 166
Joined: Sat Dec 27, 2008 3:30 am

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby Al Hart » Sat Jan 31, 2009 6:01 am

UI.openpanel - bugs and improvement requests

I would like UI.openpanel to be much more powerful.

I have at three problems with it.

1. Patterns for file extensions

This first code snippet should display all files with either a .zip or .rb extension.
When I use it in SU 7 Windows, the openfile panel displays only the .zip files, (no .rb files), and showed this '*.zip;_.rb' in the File name box: (with an underscore instead of a *)

Code: Select all
fn = UI.openpanel "Select a zip file.", "",  "*.zip;*.rb"


When I pass it just one extension, it works:

Code: Select all
UI.openpanel "Select a zip file.", "",  "*.zip"


But if I pass it a starting folder it fails:

Code: Select all
UI.openpanel "Select a zip file.", "c:/tmp",  "*.zip"


showing '_.zip' in the File Name box

2. Passing patterns and a starting file separately

I should be able pass a file name (e.g. the last file the user opened), as well as a set of patterns.

3. Passing filters.

The Windows openfile dialog allows you to pass a set of filters which display at the bottom. UI.openfile should have a similar set of patterns.

#2 and #3 could be implemented with new, optional parameters.

4. Required file

Windows Openfile has a setting that required that the user enter a valid, existing file. This would be a nice feature for UI.openpanel.
Al Hart
IRender nXt from Render Plus
User avatar
Al Hart
Render Plus Systems
 
Posts: 1498
Joined: Sun Nov 18, 2007 3:54 pm
Location: Centennial, Co
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby Al Hart » Sat Jan 31, 2009 4:05 pm

Bug/new feature request for Sketchup.load

Sketchup.load does not set the filename or binding properly. errors during loading are not reported, and executaion errors are not reported properly.

Here is a test file with an error which only occurs during execution.

rps_test1.rb
Code: Select all
printf "rps_test1.rb\n"
def test1
        printf xxx
end


When you load it with ruby's load and execute 'test1' you get this error:

Code: Select all
Error: #<NameError: c:/tmp/rps_test1.rb:6:in `test1': undefined local variable or method `xxx' for main:Object>
c:/devc_2005/rptools/rpt_debug/ruby/rps_test1.rb:6


When you load it in Sketchup.load (either the .rb or the compressed .rbs), you get this error message:
Code: Select all

Error: #<NameError: (eval):11:in `test1': undefined local variable or method `xxx' for main:Object>
(eval):11


Having the file name and line number for a ruby is very important both when creating a ruby application and when debugging client problems. I have to go to a lot of trouble to work around this bug. :(

Assuming that 'eval()' is eventually used by Skethcup.load to load, binding and a file name could be passed to cause errors to be reported properly.

e.g.: eval(string, TOPLEVEL_BINDING, filename, start_line)
Al Hart
IRender nXt from Render Plus
User avatar
Al Hart
Render Plus Systems
 
Posts: 1498
Joined: Sun Nov 18, 2007 3:54 pm
Location: Centennial, Co
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: other
Level of SketchUp: Advanced

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby Todd Burch » Thu Feb 05, 2009 5:13 am

I haven't read through this post, so some of these might be duplicates. If they are, consider mine a +1.

  • Expose the Surface class.
  • Change the data model for Text so its not a global thing, but an entity thing. That way, each text-related entity can have it own font and other attributes.
  • Expose Dimensions.
  • Fix all the bugs I've reported. Really. :roll:
Thanks, Todd
Todd Burch
 
Posts: 909
Joined: Mon Nov 12, 2007 2:43 pm
Location: Katy, Texas

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby NewOne » Fri Feb 06, 2009 12:44 am

Sorry if off-topic.
But... did you guys heard something about Sketchup 7 ruby documentation? What's really new here? Will it appear? When?

Thank you. :)
NewOne
 
Posts: 329
Joined: Thu Oct 23, 2008 6:21 pm
Location: Maramures, Romania

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby ScottLininger » Fri Feb 06, 2009 1:19 am

We summarized the new SU7 features in a blog post:

http://sketchupapi.blogspot.com/2008/11 ... hup-7.html

I can't give an exact date for the detailed documentation. We're working on it.

Thanks,
- Scott Lininger
SketchUp Software Engineer
Have you visited the Ruby API Docs?
User avatar
ScottLininger
SketchUp Team
 
Posts: 170
Joined: Tue Oct 21, 2008 11:17 pm
Location: Boulder, CO

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby thomthom » Fri Feb 06, 2009 8:32 am

My suggestion of way of coding: Being able to hook up a debugger. Sorely needed some times.
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom
Global Moderator
 
Posts: 17907
Joined: Tue Nov 13, 2007 12:47 pm
Location: Trondheim, Norway
Name: Thomas Thomassen
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby Matt666 » Thu Feb 26, 2009 1:56 pm

Hi all!
To have possiblity to call a tool by its ID, with function Sketchup.send_action.
For example :
Code: Select all
Sketchup.send_action 21022

It works great on PC. On Mac, it returns this bug below in the console :
Error: #<TypeError: can't convert Fixnum into String>
Last edited by Matt666 on Wed Apr 01, 2009 6:40 am, edited 1 time in total.
Frenglish at its best !
My scripts
Matt666
 
Posts: 829
Joined: Wed Dec 05, 2007 8:38 am
Location: 48.1184, -1.675
Name: Matt

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby NewOne » Tue Mar 10, 2009 2:33 pm

To be able to add new menus in SketchUp menu bar.
Please, register (free) to access all the attachments on the forums.
NewOne
 
Posts: 329
Joined: Thu Oct 23, 2008 6:21 pm
Location: Maramures, Romania

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby jadema » Thu Mar 12, 2009 5:42 am

Extend the UI class to support the selection of a directory. Currently you can select files, but there doesn't seem to be a way to select a directory or folder.
jadema
 
Posts: 2
Joined: Sat Mar 07, 2009 6:06 pm

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby snicolo » Wed Mar 18, 2009 8:32 pm

The New Ruby API documentation is up and running.

Take a look at:
http://code.google.com/apis/sketchup/docs/index.html

enjoy.
Simone.
Simone Nicolo
QA Manager
www.sketchup.com
User avatar
snicolo
 
Posts: 48
Joined: Fri Jun 20, 2008 3:51 pm

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby jadema » Mon Mar 23, 2009 12:44 am

How about a method to refresh the SketchUp display when executing long scripts? Today the interface looks like it is frozen when you change focus to another window and then back to SketchUp. The display gets refreshed only when the script completes or a dialog box that requires user input is displayed.
jadema
 
Posts: 2
Joined: Sat Mar 07, 2009 6:06 pm

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby iceman » Thu Apr 09, 2009 10:34 pm

Let me add my two cents. I've only been using the API for a couple of days now, and I can see that dimensions aren't accessible from it. This would be very important to me. I can see it's been requested a couple of times already...

Thanks for such a great tool.

Just thought of another one. Last night I tried to create a script to let me control the camera like you would in a video game: WASD and mouselook. Turns out that key press events are consumed by shortcuts before they can get to a script. Also, you can't copy the shortcut keys, change them temporarily while your tool is running, and then restore them when it's deactivated. A way around this would be nice. I know the walk tool lets you use the arrow keys, but it would be nice to a) be able to change those keys and b) use mouse look at the same time
iceman
 
Posts: 3
Joined: Tue Mar 31, 2009 6:40 pm
Name: Zach

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby JClements » Mon Apr 13, 2009 9:06 pm

If its not going to be part of the core program, then a way to export as a Flash Animations.

A means to use object tweening within a scene or between scenes [ie., apply a name to a group ie., Object1<TweenBegin> in Scene1, and on Scene2 place a copy of that object with a name of Object1<TweenEnd> ]. Any transformations to Ojbect1<TweenEnd> such a scale, position, and rotation would be tweened between Scene1 and Scene2 at whatever frame rate the user designate to the properties of objectname<TeenEnd>.
Last edited by JClements on Mon Apr 13, 2009 11:57 pm, edited 1 time in total.
John
Illustrator
Beaverton, Oregon
User avatar
JClements
Premium Member
Premium Member
 
Posts: 774
Joined: Wed Nov 14, 2007 4:32 pm
Location: Portland/Beaverton, Oregon
Name: JClements
Operating system: Windows
SketchUp version: 8
License type: Pro
SketchUp use: illustration, cartoons
Level of SketchUp: Intermediate

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby TIG » Mon Apr 13, 2009 11:40 pm

iceman wrote:I've only been using the API for a couple of days now, and I can see that dimensions aren't accessible from it.

You can work-around this dimensions_not_being_API_accessible issue...
Make a component-dimension one_unit long and save it
In the script insert it at the first picked point, then transfoem it...
Rotate it to the angle given by the second picked point and scale it in its X to match the distance_between_the_two_points : one_unit
The dimension numbers should change to match, which the ticks and leaders remain fixed.
You could have a third picked point to locate the text and scale it in the Y to suit ?
You could then explode that instance if appropriate...
TIG
User avatar
TIG
Global Moderator
 
Posts: 14308
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

SketchUp RUBY API Wishlist

Postby billbell52 » Fri May 01, 2009 3:12 pm

Maybe I am thinking about this wrong but I think a good idea is to develop a rubygem that exposes the SketchUp Ruby API to a standard ruby install. You can continue to develop the embedded Ruby capability but a lot of existing Ruby capability/code/gems can be put to immediate use. The relieves the pressure to urgently add capability that exists someplace else. For example I may want to couple SketchUp to a RubyOnRails environment. I don't expect you to embed ROR into SketchUp. I would have the capability of doing it on my own if I could access the Ruby API from a standard Ruby install.

Also, as I understand the Sketchup Ruby API is based on 1.8.0. Exposing the Ruby API to an external Ruby environment would allow users to use a more current release.

Does this make any sense?
billbell52
 
Posts: 7
Joined: Wed Apr 29, 2009 9:45 pm
Name: Bill Bell

Re: SketchUp RUBY Wishlist

Postby buk2noy » Tue May 05, 2009 6:59 am

daiku wrote:This is music to my ears, Scott. Here's another vote for ruby control of dimension objects. CB.



nice post!
ok, how about this my officemate send me a cad file to be SU, problem is when i import them to SU the lines in 2d are not they seem to be.. they are in different axis can SU place it in one axis, :!:

(is this an existing ruby script?
if so kindly send to me) :roflmao:
seeking for peace of mind
buk2noy
 
Posts: 6
Joined: Fri Feb 27, 2009 12:29 pm
Location: 3 stars and the sun
Name: JOJO

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby trottolino » Thu May 28, 2009 5:24 pm

jadema wrote:How about a method to refresh the SketchUp display when executing long scripts? Today the interface looks like it is frozen when you change focus to another window and then back to SketchUp. The display gets refreshed only when the script completes or a dialog box that requires user input is displayed.


I'm experiencing the same problem with a routine that generates thousands of faces. The calculation is sometimes very long, but with the screen locked is impossible to understand the percentage of completion and when the calculation will end.
You have found a solution in the meantime?
trottolino
 
Posts: 10
Joined: Thu Apr 23, 2009 10:42 pm

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby mpowell1234567890 » Tue Jun 02, 2009 7:38 pm

I have a SketchUp RUBY API Wishlist:
1. A ruby script that coverts multiple lines to 1 whole line.
2. A ruby script that speeds up shadow rendering.
3. A ruby script that ables a follow-me tool to cross multiple lines "For example: a cross using any shape"
4. A ruby script that Measures a volume of a model in Gallons, Liters etc..
mpowell1234567890
 
Posts: 108
Joined: Sat May 17, 2008 5:30 am

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby remus » Tue Jun 02, 2009 7:47 pm

mpowell1234567890 wrote:I have a SketchUp RUBY API Wishlist:
1. A ruby script that coverts multiple lines to 1 whole line.

Have a look at weld.rb http://www.smustard.com/script/Weld
2. A ruby script that speeds up shadow rendering.

That would need to happen in the core SU code i.e. google needs to do that.
3. A ruby script that ables a follow-me tool to cross multiple lines "For example: a cross using any shape"

Hard to know what you mean without more details. Could you post a pic in a new thread?
4. A ruby script that Measures a volume of a model in Gallons, Liters etc..

There are a couple of volume scripts out there at the moment. Id guess it would be a fairly simple task to convert their output to litres/gallons. This would be a good place to start: viewtopic.php?f=180&t=3188

p.s. I think this thread is meant more for wishes regarding the ruby API itself, rather than individual scripts.
remus
 
Posts: 8055
Joined: Fri Nov 30, 2007 8:48 am
Location: UK
Name: remus

Re: SketchUp RUBY API Wishlist [way of coding wishes, please]

Postby TIG » Wed Jun 03, 2009 11:26 am

My Volume scripts already let you select the results in gallons [US and UK] and litres as well as most other volume units...
TIG
User avatar
TIG
Global Moderator
 
Posts: 14308
Joined: Mon Nov 12, 2007 7:24 pm
Location: Northumbria UK
Name: TIG
Operating system: Windows
SketchUp version: 2013
License type: Pro
SketchUp use: architecture
Level of SketchUp: Advanced

SketchUcation One-Liner Adverts

by Ad Machine » 5 minutes ago

Vertex Tools for SketchUp. Take control over each vertex with this vertex editor for SketchUp.

Premium Members get 20% discount!

Ad Machine
Robot
 
Posts: 2012

PreviousNext

Return to Developers' Forum

Who is online

Users browsing this forum: JQL and 2 guests