## Recommended Posts

Has anyone found an alternative for a - as far as I know - non-existing 3d-array?

I'm looking for something like:

```(...)
VAR
: ARRAY [m..n, o..p, q..r] OF
BEGIN
(...)
```

vectorscript can only handle a 2 Dimensional array.

However, structures can provide you with what you are looking for in a slightly different way.

The only downside is that the inner arrays are static, they can't be dynamic.

So ... a few days later:

I am getting n^3 results, just not the ones I was hoping for.

X, Y is OK; Z doesn't seem to work well, so - hoping someone will see what I'm trying to do - I'll just drop some code in here.

```PROCEDURE Silver_Constant;
CONST
Psi	= (1 / 2 + Sqrt (23 / 3) / 6) ^ (1 / 3) + (1 / 2 - Sqrt (23 / 3) / 6) ^ (1 / 3);
TYPE
DDD_ARRAY = STRUCTURE
H	: ARRAY [0..7] OF REAL;
END;
VAR
P, L	: ARRAY [0..7, 0..7] OF DDD_ARRAY;
a, z, n	: LONGINT;
SD		: REAL;
Obj_H	: HANDLE;

FUNCTION Block (p1, p2, l1, l2: REAL): HANDLE;
BEGIN
BeginXtrd (p1, l1);
RectangleN (p1, p2, 1, 0, l1, l2);
EndXtrd;
END;

BEGIN
SD := RealDialog ('Enter the dimensions of the smallest block', '100');
FOR a := 0 TO 7 DO
BEGIN
FOR z := 7 DOWNTO 0 DO
BEGIN
FOR n := 0 TO 7 DO
BEGIN
P[a, z].H[n]	:= SD * (SD - (SD * Psi ^ a)) / (SD - (SD * Psi));
L[a, z].H[n]	:= SD * Psi ^ a;

Obj_H	:= Block (P[a, z].H[n], P[z, a].H[n], L[a, z].H[n], L[z, a].H[n]);
END;
END;
END;
END;
RUN (Silver_Constant);
```

Edited by DeSignature

If it's just 3D points, why not make a structure with an x, y and z field and use that in an array?

(...) just 3D points (...)?

I don't understand your suggestion as the're actualy extruded rectangles, and I couldn't find a 'Draw-Extruded-Rectangle (x1, y1, z1, x2, y2, z2)'-procedure.

There also seems to be a problem with the BeginXtrd-Procedure , allthough, I actualy don't know if this specific problem applies to my situation.

Edited by DeSignature

... and I couldn't find a 'Draw-Extruded-Rectangle (x1, y1, z1, x2, y2, z2)'-procedure.

You can create a wrapper function that will create extrudes based on two 3Dpoints:

```FUNCTION BlockByBBox (p1, p2: POINT3D): HANDLE;
BEGIN
BeginXtrd (p1.z, p2.z);
Rect (p1.x, p1.y, p2.x, p2.y);
EndXtrd;
END;```

Or something like this:

```FUNCTION BlockByBBox (p1X, p1Y, p1Z, p2X, p2Y, p2Z: REAL): HANDLE;
BEGIN
BeginXtrd (p1Z, p2Z);
Rect (p1X, p1Y, p2X, p2Y);
EndXtrd;
END;```

But I don't realy understand what you try to accomplish... With this script, I get somewhat the same result.

```PROCEDURE Silver_Constant;
CONST
Psi	= (1 / 2 + Sqrt (23 / 3) / 6) ^ (1 / 3) + (1 / 2 - Sqrt (23 / 3) / 6) ^ (1 / 3);
TYPE
DDD_ARRAY = STRUCTURE
X	: ARRAY [0..7] OF REAL;
Y	: ARRAY [0..7] OF REAL;
Z	: ARRAY [0..7] OF REAL;
END;
VAR
P, L	: DDD_ARRAY;
a, z, n	: LONGINT;
SD		: REAL;
Obj_H	: HANDLE;

FUNCTION Block (p1, p2, l1, l2: REAL): HANDLE;
BEGIN
BeginXtrd (p1, l1);
RectangleN (p1, p2, 1, 0, l1, l2);
EndXtrd;
END;

BEGIN
SD := RealDialog ('Enter the dimensions of the smallest block', '100');
FOR a := 0 TO 7 DO
BEGIN
FOR z := 7 DOWNTO 0 DO
BEGIN
FOR n := 0 TO 7 DO
BEGIN
P.X[a] := SD * (SD - (SD * Psi ^ a)) / (SD - (SD * Psi));
P.Y[z] := SD * (SD - (SD * Psi ^ a)) / (SD - (SD * Psi));
P.Z[n] := SD * (SD - (SD * Psi ^ a)) / (SD - (SD * Psi));

L.X[a] := SD * Psi ^ a;
L.Y[z] := SD * Psi ^ a;
L.Z[n] := SD * Psi ^ a;

Obj_H	:= Block (P.X[a], P.Y[z], L.X[a], L.Y[z]);
Obj_H	:= Block (P.X[z], P.Y[a], L.X[z], L.Y[a]);
END;
END;
END;
END;
RUN (Silver_Constant);```

Be aware that you're creating a lot of objects that have the same dimension and position. Is this neccesary?

Maybe if you tel us what the result should be, we could help you better?

Be aware that you're creating a lot of objects that have the same dimension and position. Is this neccesary?

Maybe if you tel us what the result should be, we could help you better?

Well, exactly that, every block (at the end there should be 83 of them) should have it's unique dimension and co?ridnates.

I'm actualy trying to customize this system, kind of like Le Corbusier's Modulor.

The 2D-part looks like this:

```PROCEDURE Silver_Number;
CONST
Psi	= (1 / 2 + SQRT (23 / 3) / 6) ^ (1 / 3) + (1 / 2 - SQRT (23 / 3) / 6) ^ (1 / 3);
VAR
P, L	: ARRAY [0 .. 7, 0 .. 7] OF REAL;
a, z	: LONGINT;
GT		: REAL;
BEGIN
GT := RealDialog ('Smallest Block Dimensions = ', '100');
FOR a := 0 TO 7 DO
BEGIN
FOR z := 7 DOWNTO 0 DO
BEGIN
P [a, z]	:= GT * (GT - (GT * Psi ^ a)) / (GT - (GT * Psi));
L [a, z]	:= GT * Psi ^ a;

RectangleN (P [a, z], P [z, a], 1, 0, L [a, z], L [z, a]);
END;
END;
END;
RUN (Silver_Number);
```

And yes, of course, we might leave the necessity open for discussion ... but - whatever the result of this discussion - it might help me understand coding vectorworks.

Meanwhile I'll see what I can do with your - much appreciated - suggestions.

Edit:

Had to look really hard for it (at the most obvious place of course):

Edited by DeSignature

Not really sure how I got there, but I'm there:

```PROCEDURE Silver_Constant;
CONST
Psi	= (1 / 2 + SQRT (23 / 3) / 6) ^ (1 / 3) + (1 / 2 - SQRT (23 / 3) / 6) ^ (1 / 3);
TYPE
STRUCTUUR = STRUCTURE
P, L	: ARRAY [0..6] OF REAL;
END;
VAR
Pos, Len	: ARRAY [0..6, 0..6] OF STRUCTUUR;
Bot, Top	: ARRAY [0..6, 0..6] OF STRUCTUUR;
a, z, n		: LONGINT;
SB			: REAL;
Ext_H		: HANDLE;

BEGIN
SB := RealDialog ('Smallest Block Dimensions = ', '100');
FOR a := 0 TO 6 DO
BEGIN
FOR z := 6 DOWNTO 0 DO
BEGIN
FOR n := 6 DOWNTO 0 DO
BEGIN
Pos [a, z].P [n]	:= SB * (SB - (SB * Psi ^ a)) / (SB - (SB * Psi));
Len [a, z].L [n]	:= SB * Psi ^ a;

Bot [a, z].P [n]	:= SB * (SB - (SB * Psi ^ n)) / (SB - (SB * Psi));
Top [a, z].P [n]	:= (Bot [a, z].P [n]) + (SB * Psi ^ n);

RectangleN (Pos [a, z].P [z], Pos [z, a].P [a], 1, 0, Len [a, z].L [z], Len [z, a].L [a]);
Ext_H := HExtrude (LNewObj, Bot [a, z].P [n], Top [a, z]. P [n]);
END;
END;
END;
END;
RUN (Silver_Constant);
```

If anyone feels like to elaborate on what is actualy happening here, please do.

(...) just 3D points (...)?

I don't understand your suggestion as the're actualy extruded rectangles, and I couldn't find a 'Draw-Extruded-Rectangle (x1, y1, z1, x2, y2, z2)'-procedure.

There also seems to be a problem with the BeginXtrd-Procedure , allthough, I actualy don't know if this specific problem applies to my situation.

BeginXtrd works fine and you should use it if you are just creating extrured rectangles, that is if they are extruded on the Z axis. You have to keep it simple. If things are getting too hard, look at it another way...

Edited by Dieter @ DWorks

I'll keep that in mind.

Meanwhile I found out that the code above doens't work properly in a PIO, just because of the following lines

```(...)
RectangleN (Pos [a, z].P [z], Pos [z, a].P [a], 1, 0, Len [a, z].L [z], Len [z, a].L [a]);
Ext_H := HExtrude (LNewObj, Bot [a, z].P [n], Top [a, z]. P [n]);
(...)
```

In a PIO this line should be replaced by:

```(...)
BeginXtrd (Bot [a, z].P [n], Top [a, z]. P [n]);
RectangleN (Pos [a, z].P [z], Pos [z, a].P [a], 1, 0, Len [a, z].L [z], Len [z, a].L [a]);
EndXtrd;
(...)
```

Yep, that's a know thing, it's documented in the function reference: http://developer.vectorworks.net/index.php/VS:HExtrude

When looking up functions I don't use to often, I use the online function reference, because there are things that aren't present in the offline version. The offline version is more of a stripped down, fast version.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible. ×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×