Skip to content
Jens Egholm edited this page Sep 12, 2015 · 1 revision

Introduction

RepoCad borrows concepts from programming which helps the designer become more productive by using familiar concepts of objects in their drawings. Take a rectangle as an example. A rectangle is essentially four lines with a 90° angle between them. Instead of drawing four lines each time we want to form a rectangle, we can create the concept of a rectangle and reuse it many times. Now we can forget all about the details of the four lines when we operate with rectangles. And if we want to go further, why not use our rectangle concept to create a box? Or a house? By writing a script in RepoScript - the scripting language of RepoCad - we can do exactly that. It is the aim of this brief introduction to show you how. Let's get started.

Drawing

The most basic thing you can do in RepoScript is drawing. To draw a line in a two dimensional space we need two coordinates for each end-point. So four coordinates in total. Let's make a line from (0,0) to (1,1).

line (0 0 1 1)

And that's it. If you try that out in the editor, a small line will appear. If you change one of the four numbers, the line will move to the coordinates you gave it. You can draw other things like circles and text of course. Check out the page on drawing for more on this.

Vectors

Vectors can pair coordinates into one. So if I have a Vector called a in a two dimensional space defined to be (0,0) I can avoid writing (0,0) and simply type a. If we say that the Vector b is (1,1) we can draw the same line as above by writing

line (a b)

But we still need a way to tell RepoCad what coordinates is stored in a and b. That is done by using define like so:

define a = (0 0)

Parametricity

If I have two lines which reuses one coordinate (b), I can simply reuse the Vector I already have defined.

line (a b)
line (b c)

This will give us two lines which both ends in whatever coordinate is defined by b. a, b and c are now ''parameters'' because they decide what happens with the line and because they can be changed to anything the designer wants them to be.

Reusing parameters

This is where the fun begins! Using what we already know about parameters, we can tell RepoScript to draw one line over and over again, but in many different places. Similar to defining a above we define a behaviour for drawing a line. But in the previous code a is set to the value (0 0). This time we need to draw the line depending on what the parameter is set to. In other words we need some input and depending on the input we provide some output. In mathematics that is known as a function, and that looks like this in RepoScript:

define drawLine(d e) = line (d e)

So instead of setting drawLine to a fixed value like we did with a, this piece of code can draw a line starting in d and ending in e. Now we can reuse drawLine many times:

define a = (0 0)
define b = (1 1)
drawLine(a b)
drawLine (b a)
...

The clever reader will see that drawLine is pretty useless, because it simply does what line would do. That is of course correct, and that is in fact how all drawing is implemented!

Clone this wiki locally