DAY 2 PRE-TRAINING NOTES

TRANSACTION SCRIPTS

  • First create point and two lines
  • Save this transaction
  • Right click on last transaction. New script transaction–> insert after

Create a Point

transaction script "first try"

{

// first make the point

Point leftVariable = new Point("left");

leftVariable.ByCartesianCoordinates(baseCS, 5.0, 5.0, 0.0);

}

First line of script

  • insert a line that says to make a point
  • make me an object that is a point, call that object left variable. Make the object by executing this command. It’s new name is left.
  • Point leftVariable = new Point("left");
  • Point is the type.
  • Name is leftVariable - temporary name
  • = means execute
  • Point("left");: constructor
  • Point explains the type
  • Then (“name”)

Second line of script – compute our variable with cartesian coordinates

  • define the variable. Use the perios, and pull up cartesian coordinates
  • leftVariable.ByCartesianCoordinates(CoordinateSystem, Xtranslation, Ytranslation, Ztranslation [, Origin] )
  • leftVariable.ByCartesianCoordinates(baseCS, 5.0, 5.0, 0.0);
  • in [] is optional

Run the script to make sure it works

Create a second Point

// first make the point

Point leftVariable = new Point("left");

leftVariable.ByCartesianCoordinates(baseCS, 5.0, 5.0, 0.0);

// then make the right point

Point rightVariable = new Point("right");

rightVariable.ByCartesianCoordinates(baseCS, 10.0, 5.0, 0.0);

Create a Line

// first make the point

Point leftVariable = new Point("left");

leftVariable.ByCartesianCoordinates(baseCS, 5.0, 5.0, 0.0);

// then make the right point

Point rightVariable = new Point("right");

rightVariable.ByCartesianCoordinates(baseCS, 10.0, 5.0, 0.0);

// then draw the line

Line bridgeVariable = new Line("bridge");

bridgeVariable.ByPoints(left, right);

Next free the point manually by editing the point. Right click on the x/y

Then move the point

Check the script to see what was added.

transaction modelBased "Graph changed by user"

{

feature left GC.Point

{

Xtranslation = <free> (5.0);

Ytranslation = <free> (3.41945192602107);

}

}

transaction modelBased "free point/move point"

{

feature left GC.Point

{

Xtranslation = <free> (-6.3264554214921);

}

}

Start a new transaction. Choose the expression builder upper right to left of fx

  • This transaction makes a bunch of lines

transaction script "script transaction 02"

{

for (int i = 0; i < 5; ++i)

{

// first make the point

Point leftVariable = new Point("left_" + i);

leftVariable.ByCartesianCoordinates(baseCS, 5.0, 5.0 + i, 0.0);

// then make the right point

Point rightVariable = new Point("right_" + i);

rightVariable.ByCartesianCoordinates(baseCS, 10.0, 5.0 + i, 0.0);

// then draw the line

Line bridgeVariable = new Line("bridge_" + i);

bridgeVariable.ByPoints(leftVariable, rightVariable);

}

}

First line

for (value index = 0; index < count; ++index)

for (int i = 0; i < 5; ++i)

  • ++i indicates the increment
  • Key words in blue
  • Light blue highlight variables
  • Statement delinieated by semicolons????
  • Then copy and paste from first try and change to match above
  • Try 15 iterations instead of 5.

Debugger

  • Reduce iterations to 3
  • Add a breakpoint; before the “for” argument
  • Run the program
  • Then debugger appears
  • Step through the steps and see how the program works

Edit the coordinate system

  • Make a new coordinate system
  • Then edit script to depend on that cs
  • Resulting script

transaction modelBased "Graph changed by user"

{

feature coordinateSpiral GC.CoordinateSystem

{

CoordinateSystem = baseCS;

Xtranslation = <free> (23.2934532741567);

Ytranslation = <free> (-2.56051530619625);

Ztranslation = <free> (0.0);

HandleDisplay = DisplayOption.Display;

}

}

Make a spiral by editing previous script – number 1 (Robert Woodbury)

transaction script "First Spiral"

{

for (int i = 0; i < 20; ++i)

{

double radius = 5.0;

Point spiralVariable = new Point("spiral_" + i);

spiralVariable.ByCartesianCoordinates(baseCS, radius*Cos(30*i), radius*Sin(30*i), i);

}

}

  • Try 100
  • Backspace before spiral
  • Intorudce new coordinate stystm, with the icon
  • Then go and rename it csSpiral
  • Change the script to refer to this new sprial
  • Then go and delete this once done
  • Try to change it to a different coordinate system in the script instead of creating your own cs. This one will introduce a cs based on radius, and move the new one away from the baseCS

transaction script "First Spiral"

{

double radius = 5.0;

CoordinateSystem csSpiral = new CoordinateSystem("csSpiral");

csSpiral.ByCartesianCoordinates(baseCS, 4*radius, 4*radius, 0.0 );

for (int i = 0; i < 100; ++i)

{

Point spiralVariable = new Point("spiral_" + i);

spiralVariable.ByCartesianCoordinates(csSpiral, radius*Cos(30*i), radius*Sin(30*i), i);

}

}

Now we are going to change the radius

  • Create a spiral that can’t be done in model based GC

Change the previous script first spiral

transaction script "First Spiral"

{

double radius = 5.0;

//add a variable

double radiusStep = 0.1;

double increments = radius/radiusStep;

CoordinateSystem csSpiral = new CoordinateSystem("csSpiral");

csSpiral.ByCartesianCoordinates(baseCS, 4*radius, 4*radius, 0.0 );

for (int i = 0; i < increments; ++i)

{

radius = radius - radiusStep;

Point spiralVariable = new Point("spiral_" + i);

spiralVariable.ByCartesianCoordinates(csSpiral, radius*Cos(30*i), radius*Sin(30*i), i);

}

}

Make clock

Make two points and a line

Save the image capture two different ways

transaction script "New script transaction"

{

//breakpoint;

for (int j = 0; j < 4; ++j )

for (int i = 0; i <= 360; i=i+10 )

{

right.ByCartesianCoordinates(baseCS, Cos(i)*6.0, Sin(i)*6.0, 0.0, left);

UpdateGraph();

//right refers to something you already created

//SaveViewToImageFile(2, 500, "D:\\RESEARCH\\GC\\images\\clock_image_" + i + ".jpg");

//2 stands for view

//500 stands for pixels

}

}

Two points and line

Draw the clock behavior

Add two points to middle of line

Add two new lines to connect to the points

Create a function for a bspline curve

  • Make 4 points, then make a bspline curve by poles, order 3
  • Create a point -> by function
  • Go to text editor and type this
  • This sets up a function with two arguments, shown in parentheses

value function (ICurve curve, int num)

{

double spacing = 1.0/(num-1);

//create empty collection

Point childPoint = {};

//breakpoint;

for (int i=0; i < num; ++i)

{

//add to collection

//true indicates visability

childPoint[i] = new Point(true);

double t = spacing*i;

childPoint[i].ByParameterAlongCurve(curve, t);

}

return childPoint;

}

  • Then list of values for the argument. These are the arguments for the function above. F(x) = x2

{bsplineCurve01,6}

Create a graph variable

  • Go to graph -> manage graph variable ->make new and call it num
  • Put in a value from 0-10

Create a graph function, a function that works across the board

  • Create feature, graph function, define
  • Open the text editor, and copy the old function into the graph function

Then make a new arc and apply the graph function

Create a new feature ->point-> by function

  • function… type in graphFunction01
  • Arguments –type {arc01,num}

This will make points across the arc

And they can be changed with the num slider too

Some kind of function

  • Create two variables
  • inputToFunction
  • outputFromFunction
  • create a new graph function

function (value x)

{

return x*x;

}

Open five scripts for curves from dongle

  • method 1
  • It’s a script transaction
  • For loop creates 10 points
  • p_0, p_1, etc.
  • they are updated by cartesian coordinates, move along x,y,z
  • z = j2/10 – to make a parabola of points
  • each point is a top level feature
  • they are just points
  • put in a bspline curve
  • method 2
  • define scale variable in order to change the shape of the curve = scale is a global variable
  • internal function has this text
  • Point point = new Point(this);
  • Function point constructs a point
  • Function coordinate system constructs a coordinate system
  • Under Fx/feature types, 3 ways to create a new point
  • New point
  • creates a new top level point
  • creates a new point that is a subpoint of another
  • this refers to what you are trying to make
  • make 10 points… set update method to what it is before
  • the upper version is one point, and bottom has many separate points
  • then you can bind the one point to curveScale
  • method 3
  • use dpoints.
  • have the essence of a point
  • under geomtry tab under fx
  • only contain x,y,z
  • create a function – this explains what the function does… see file.
  • use for loop
  • not child points, it will be empty list of dpoint3ds
  • keep adding to the list by adding dpoint3ds
  • this.ByPointsOnCurveAsDPoints3ds (cs, dPoint); this makes the curve
  • method 4
  • just using a point
  • define a collection of dpoints
  • make a bspline curve
  • it only exists inside the function
  • and make a child pline?
  • Then return a point by a parameter along a bspline curve
  • It will move through space and is T along the curve
  • Excel/gaming are often end-user systems

Create dynamic text to indicate the x coordinate

  • Insert Text
  • Placement: coordinateSystem01
  • TextString "X coordinate="+coordinateSystem01.X
  • Make New TextStyle
  • Input in Defined Format
  • Apply TextStyle to Text

Roly exercise

  • Draw 9 point
  • Draw bspline surface
  • Play around
  • Add point onto surface by using point icon

  • Change point to series
  • Click on fx, and click on functions, scroll down to series
  • Series(0.3,0.6,0.05) start, final, incremental count . technique is optional, in brackets.
  • Manage graph variable
  • startU = 0.15, make it a slider
  • replace the first digit of series with the startU
  • fill the whole space
  • change second number of series with 1.0 instead of 0.5
  • change it to 1.01 instead of 1.0 to get the points to go to the edge
  • Change to
  • U: Series(startU, startU+uSize, 0.05 )
  • V: Series(startV, startV+vSize, 0.05 )
  • Play around with the values
  • Create a shape grid, features – shape – by point grid
  • Just click on one point and delete all but point name
  • Try facetoption and choose FacetOption.ForcePlanarQuads
  • Small cracks will start opening up
  • FacetOption.TriangulationAlternate, shows triangle,
  • Change u/v to 1
  • Leave it on quads

Build a component in a separate file

  • Component can be anything
  • They are adaptive
  • Line are components too, feature and components interchangeable

Create a component

  • Open a new file
  • 4 points
  • Shape – by vertices, select 4 corners
  • Coordinate system – FromShapeVertices
  • Keep everything dependent on the shape
  • Create point
  • By cartesian coordinates
  • Select coordinatesystem01
  • X=0, y=0
  • Z: shape01.Area/4
  • Create new graph variable pHeight
  • Replace 4 with pHeight
  • Create a line feature by points, start point – apex point, and end point shape01.Vertices
  • Create a cone,
  • by line, and
  • Line: line 01
  • Start/End radii: line01.Length/20
  • Generate Feature Type, brings up form, icon lots of little squares
  • Give name
  • Define inputs
  • Make the two variables
  • Change name Hfactor
  • Change to logical names, such as HFactor and PlaceHolder
  • Click both replicatable
  • Outputs - Show the other stuff as construction, except the cone.
  • Create it, close the file and open the old file
  • Then insert pyra01 by default, set HFactor to 0.75 and shape01

GENERAL NOTES

  • Modeling
  • Use construction lines as needed. Click on icon, then use control select to select the item.
  • You can extractRegionUsingStartEndPoint, this is useful for creating equal arcs for a façade
  • With ellipse, either the arcs are equal, or the lines are equal see
  • Basis for T on a ellipse is angle,
  • Create plane, it acts as a 2d coordinate system
  • To change color, select color/thickness, then apply to object
  • ProjectCurveOntoSurface
  • Switch on curve vector
  • C:\Documents and Settings\All Users\Application Data\Bentley\WorkSpace\GenerativeComponents\Transaction Files\nyc_workshop_samples\day 3\project_trim\
  • Trim by Projection
  • C:\Documents and Settings\All Users\Application Data\Bentley\WorkSpace\GenerativeComponents\Transaction Files\nyc_workshop_samples\day 3\cut_protrusion\bsplineSurface_TrimByProjectedCurve.gct
  • Program is in development phase, beta
  • Rhino had extensive beta phase too, benefited much from this
  • Intention - get GC out to people
  • Will add flyovers to rest of software
  • Coordinate systems
  • You always get a baseCS. If you delete it, everything goes
  • Scripting
  • Write for 3 audiences, yourself, the script, and your colleagues
  • Transaction script
  • Must have script in the beginning, so it knows to execute it.
  • Use comments often. They are signified with // before the text. Turns it green
  • Syntax notes
  • Syntax from C sharp… learning curve better if you learn C sharp. Java also, other end user programming systems
  • () for arguments
  • [] for array indexing
  • {} collection
  • Type of properties
  • Double is a real number, remnant from binary code days
  • Quick Help
  • Use quick help. See window. Hover over copy command and it will show you the video of how to work it.
  • Also, if you go to create an item, then you can see an icon called example.
  • Look for quick help exe file in c:\program files\Bentley\documentation and move it to c:\program files\Bentley\generative components\. Then execute it
  • Examples
  • Find examples.zip in c:\program files\Bentley\documentation
  • Unzip to C:\Documents and Settings\All Users\Application Data\Bentley\WorkSpace\GenerativeComponents\Transaction Files\Examples
  • Chm file available - C:\Program Files\Bentley\MicroStation\MicroStationVBA.chm
  • Blue properties are optional, and set to null
  • Right click – will send more documentation on this
  • Add notational property
  • These show up in purple
  • Bspline surface
  • By points – surface passes thru points
  • By poles – poles are the control points
  • Control points means that there is tangency between implied lines
  • Vclosed: bool – forces the surface to be closed
  • UcurveDisplay: int – indicates the divisions on the curve/matrix
  • Uorder: int (and Vorder)– changes order, lower = more faceted
  • Change symbol size
  • Edit -> baseCS
  • Change SymbolSize: double
  • Place point on surface
  • Choose icon
  • Or ByUVParametersOnSurface

Update session – day 3

  • Offset curve
  • Original curve, offset curve, get nasty result. Approximate a plane and offset within that. See example offset_from_bspline. You may need to set an upvector (blue)
  • Can drive by offset number
  • Or by offset point, more geometric
  • RemoveUnsuccessfulFeatures
  • Can filter out unsuccessful
  • C:\Documents and Settings\All Users\Application Data\Bentley\WorkSpace\GenerativeComponents\Transaction Files\nyc_workshop_samples\day 3 stick 2\GC Examples2\remove_unsuccesful_features\remove_unsuccesful_1.gct
  • Proptotype design
  • House that can redesign based on parameters
  • Concentrate on climate parameter
  • Database interactivity
  • Check climate conditions/date
  • Model to update based on this info
  • Roof
  • Solar panels to tilt
  • Façade
  • Shading devices
  • Windows
  • Natural ventilation
  • Roof pond

Questions

  • How to undo if you delete something
  • How to work this into other cad programs, microstation and others?
  • How to deal with license issue in the future

Excel

  • Use function – excelvalue, write value
  • Write Value
  • Sheet – Sheet1
  • “A1:A11”
  • Point05.X
  • Read Value
  • Filename
  • Sheetname
  • Grids
  • YTranslationjs: excelRange02.Value

Script Function

Function (Shape shape, double bulge, double radius, bool bSwitch)

{

For each (Shape nestedShape in shape)

{

Shape nestedResult = new Shape(this);

Foreach (Shape newstedNestedShape in nestedShape)

{

If (bswitch)

{

Cross_bar_1 nestedNestedResult = new cross_bar_1(nestedResult);

nestedNestedResult.ByDefault(nestedNestedShape, radius);

}

Else

{

Panel_2 nestedNestedResult = new panel_2(nestedResult) = new cross

  • Make your component type to optional so that you can switch from one to the other

Database_Facilities.doc – see this for more information.