parameters in defintions

35 views
Skip to first unread message

Axel

unread,
Mar 8, 2011, 4:22:50 PM3/8/11
to Sketch Users

Hi,

I just got across sketch and it looks like an interesting tool for 3d
drawings. Thanks for this!

One thing I am wondering is if there is some mechanism for passing
parameters to definitions in order to use the same defined objects
slightly differently, e.g. a sphere in green or red.

Are tags meant for this? They don't seem to allow me to instantiate a
green sphere and then a red sphere; or do I miss something?

Best,
Axel

Tim Lahey

unread,
Mar 8, 2011, 4:25:28 PM3/8/11
to sketch...@googlegroups.com

You can see how to do this in the Sketch Object Library at,

https://github.com/alexdu/sketch-lib

Plus, it has a number of handy built-in objects (like spheres)

Cheers,

Tim.

---
Tim Lahey
PhD Candidate, Systems Design Engineering
University of Waterloo
http://about.me/tjlahey

Gene Ressler

unread,
Mar 8, 2011, 5:36:47 PM3/8/11
to sketch...@googlegroups.com
Sorry. No parameters. Sketch macro-expands code into graphic objects as its read.  Allowing parameters would break this simple, very fast model.
 
Several people have faked parameters by storing the code objects with free variables, each in its own file.  Say the free variables for "object.sk" are a and b, then "call" with parameters by saying
 
{
  def a 3
  def b [1, 2, 3]
  input "object.sk" % code in this file uses a and b.
}
 
This seems to work fine.  If you need the full power of parameters, you're probably better off using a general purpose programming language to generate sketch.
 
Sketch 2 will support parameters.  I have a sabbatical starting in July, so there may finally be some time to work on this.
 

--
You received this message because you are subscribed to the Google Groups "Sketch Users" group.
To post to this group, send email to sketch...@googlegroups.com.
To unsubscribe from this group, send email to sketch-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/sketch-users?hl=en.




--
Gene Ressler
Reply all
Reply to author
Forward
0 new messages