GC Script Colorcube

This script generates a 3d array of a 10 x 10 x 10 unit cube. Each dimension representing one value, R, G or B. It is a helpful example for GC-users trying to script color gradients.

 

// Bentley GenerativeComponents Transaction File — File structure version 1.07. (Please do not delete or change this line.)

environment
{
GCVersion = ‘08.11.08.190’;
MSVersion = ‘08.11.07.189’;
MSProject = ‘GC_Default’;
MSDesignFile = ‘J:\1029-UKCMRI\CAD\Temp\es\GC\COLOR\110215-colorcube.dgn’;
}

transaction graphChange ‘Add point01’
{
feature User.Objects.point01 Bentley.GC.Features.Point
{
CoordinateSystem = baseCS;
Replication = ReplicationOption.AllCombinations;
XTranslation = Series(0,10,1);
YTranslation = Series(0,10,1);
ZTranslation = Series(0,10,1);
Visible = false;
}
}

transaction graphChange ‘Add Solid’
{
feature User.Objects.COL Bentley.GC.Features.Solid
{
Function = function (CoordinateSystem cs, Point[][] pt)
{

Solid col = {};
this.SymbologyAndLevelUsage = SymbologyAndLevelUsageOption.AssignToFeature;

for (int i = 0; i < pt.Count; ++i)
{
col[i] = {};

Solid coli = new Solid(this);
coli.SymbologyAndLevelUsage = SymbologyAndLevelUsageOption.AssignToFeature;

for (int j = 0; j < pt[i].Count; ++j)
{
col[i][j] = {};
Solid colj = new Solid(coli);
colj.SymbologyAndLevelUsage = SymbologyAndLevelUsageOption.AssignToFeature;

for (int k = 0; k < pt[i][j].Count; ++k)
{
int xcol = (pt[i][j][k].X/10)*255;
int ycol = (pt[i][j][k].Y/10)*255;
int zcol = (pt[i][j][k].Z/10)*255;

col[i][j][k] = new Solid(colj);
col[i][j][k].SphereByCentroidRadius(pt[i][j][k],0.5);

col[i][j][k].SymbologyAndLevelUsage = SymbologyAndLevelUsageOption.AssignToFeature;
SetPropertyValue(col[i][j][k], ‘Color’, RGB(xcol,ycol,zcol));
}
}
}

};
FunctionArguments = {baseCS, point01};
Replication = ReplicationOption.AllCombinations;
Visible = true;
}
}

About eikeschling

Architect - Computational Design Assistant - Chair of Structural Design Technische Universität München

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: