ANN: SuPy - Scripting Sketchup with Python - Correction to URL

451 views
Skip to first unread message

Greg Ewing

unread,
Feb 6, 2009, 1:37:42 AM2/6/09
to Sketchup Ruby List
[URL in previous message was incorrect, sorry!]

SuPy 1.0
--------

SuPy is a plugin for the Sketchup 3D modelling application
that lets you script it in Python.

http://www.cosc.canterbury.ac.nz/greg.ewing/SuPy/

This is a first version and is highly experimental. Let me
know if it works for you and whether you have any problems.

--
Greg Ewing
greg....@canterbury.ac.nz

Todd Burch

unread,
Feb 6, 2009, 1:01:22 PM2/6/09
to Google SketchUp Developers - Ruby API
Hi Greg. Good job.

I don't code in Python, but I did read your README file.

For this situation:

vector.reverse() # invokes 'reverse!'

because one has to leave off the punctuation, how does SuPy
(pronounced "SOOPY"? "Sketchup - Pie"?) know the difference between
the ruby methods vector.reverse and vector.reverse! ? Both of these
methods exist today in the API.

Todd
> greg.ew...@canterbury.ac.nz

Greg Ewing

unread,
Feb 7, 2009, 3:01:35 AM2/7/09
to sketch...@googlegroups.com
Todd Burch wrote:
> how does SuPy
> (pronounced "SOOPY"? "Sketchup - Pie"?)

You can pronounce it either "soupy" or "soo-pie" as
you prefer. :-)

> know the difference between
> the ruby methods vector.reverse and vector.reverse! ? Both of these
> methods exist today in the API.

Bugger! Looks like I'll have to re-think that idea...

Thanks,
Greg

Todd Burch

unread,
Feb 7, 2009, 9:41:08 AM2/7/09
to Google SketchUp Developers - Ruby API
Maybe something like reverse_shebang() for reverse! or is_a_qmark()
for is_a?

Todd

Thomas Bleicher

unread,
Feb 7, 2009, 10:36:31 AM2/7/09
to sketch...@googlegroups.com

Perhaps a more pythonic way of doing things would be
not to provide all the methods in the Ruby API but
only one to provide a particular function.

While Ruby's credo is to be as concise and elegant
as possible Python's zen[1] is to be explicit. In
Python I would do

vector = vector.revers()

rather than an in-place modification as in

vector.revers!

Shorter it may be but also less readable (at first).
I always found the Python array ('list') method 'sort()'
particularly confusing because it modifies the array
in-place while every other method returns a new array.

If there is only one method for each operation I think
it should return the new values to allow things like:

vector.normalize().revers().z

Not nice but functional.

Regards,
Thomas


[1] python -c 'import this'

r

unread,
Feb 7, 2009, 4:05:55 PM2/7/09
to Google SketchUp Developers - Ruby API
Great Job Greg! SketchUp with Python scripting is heaven on earth!

Greg Ewing

unread,
Feb 7, 2009, 5:15:00 PM2/7/09
to sketch...@googlegroups.com
Todd Burch wrote:
> Maybe something like reverse_shebang() for reverse! or is_a_qmark()
> for is_a?

PyGame has a convention of appending "_ip" for mutating
methods (standing for "in-place"). I might go with
something like that.

--
Greg

Greg Ewing

unread,
Feb 7, 2009, 7:43:34 PM2/7/09
to sketch...@googlegroups.com
Thomas Bleicher wrote:

> Perhaps a more pythonic way of doing things would be
> not to provide all the methods in the Ruby API but
> only one to provide a particular function.
>
> While Ruby's credo is to be as concise and elegant
> as possible Python's zen[1] is to be explicit. In
> Python I would do
>
> vector = vector.revers()
>
> rather than an in-place modification as in
>
> vector.revers!

That might be all right for vectors, but some methods
only have an in-place version, e.g. face.reverse!().

So far I've gotten away without having any knowledge
of particular Sketchup classes in the wrapper, and I'd
like to keep it that way if I can. Also I think it's
easier for users if there is a general set of rules
for translating Ruby method calls into Python, rather
than having to look up documentation for particular
cases.

--
Greg

Reply all
Reply to author
Forward
0 new messages