Beruflich Dokumente
Kultur Dokumente
Essentials
08.11.08
TRN012930-1/0002
Trademarks
AccuDraw, Bentley, the B Bentley logo, MDL, MicroStation and SmartLine are
registered trademarks; PopSet and Raster Manager are trademarks; Bentley SELECT is a
service mark of Bentley Systems, Incorporated or Bentley Software, Inc.
AutoCAD is a registered trademark of Autodesk, Inc.
All ther brands and product names are the trademarks of their respective owners.
Patents
United States Patent Nos. 5,8.15,415 and 5,784,068 and 6,199,125.
Copyrights
2000-2010 Bentley Systems, Incorporated.
MicroStation 1998 Bentley Systems, Incorporated.
All rights reserved.
ii
Jan-10
Table of Contents
Course Overview ____________________________________ 1
Course Description ____________________________________1
Target Audience_______________________________________1
Prerequisites _________________________________________2
Course Objectives _____________________________________2
Design Intent _________________________________________2
Modules Included _____________________________________3
Jan-10
iii
Table of Contents
Table of Contents
Table of Contents
iv
Jan-10
Jan-10
Table of Contents
Table of Contents
vi
Jan-10
Answers __________________________________________148
Tips from this module __________________________________148
Jan-10
vii
Table of Contents
Table of Contents
viii
Jan-10
Objects___________________________________________201
Function__________________________________________201
Class _____________________________________________202
Enum ____________________________________________202
Namespace _______________________________________202
GCScript Basic Components______________________________203
Feature Properties__________________________________203
How to Operate the Script Console ____________________205
How to write and use GCScript functions ___________________208
Calling functions ___________________________________209
Creating your own Functions _________________________210
Local Functions ____________________________________210
Return Value ______________________________________211
Optional values ____________________________________215
Writing your own global functions _____________________216
Anonymous Functions_______________________________216
Script Transactions _________________________________217
Script Files ________________________________________218
GCScript Basic Components______________________________218
Basic GCScript Syntax _______________________________218
Keywords _________________________________________220
Fundamental Types _________________________________220
Variables _________________________________________223
Some additional thoughts _______________________________226
Point ByFunction Script _________________________________228
List Points with a Loop script _____________________________233
The For loop statement______________________________235
Using simple equations to describe forms _______________238
Generating Polygons ___________________________________250
Polygon grid (alternative) ____________________________252
More Scripting Examples ________________________________256
B-Spline Curve _____________________________________256
B-Spline curve using child Feature points ________________257
B-Spline curve defined by internal function ______________259
Fourth B-Spline curve only as point ____________________261
Creating a user defined function_______________________262
References ___________________________________________265
Jan-10
ix
Table of Contents
Table of Contents
Jan-10
Course Overview
Course Description
GenerativeComponents, also referred to as GC, is a parametric and associative
design system that gives you new ways to explore alternative design scenarios.
GenerativeComponents captures design intent by graphically representing both
the elements and the relationships between them, enabling efficient design
exploration and reuse without manually rebuilding a model for each scenario.
GenerativeComponents lets designers work completely graphically, or combine
graphics with scripting and programming where appropriate.
This course is an introduction to GenerativeComponents and an opportunity to
explore new options for design. You will see how a complex design can be created
from multiple instances of a feature and how the feature adapts itself to the local
placement conditions. You will see how GenerativeComponents can
automatically reconfigure each individual floor plate after changing the height
and shape of a building, or after modifying its footprint.
Target Audience
This course is recommended for the following audience(s):
Jan-10
Designers
Engineers
Architects
Fabricators
Researchers
1
Copyright 2009 Bentley Systems, Incorporated
Course Overview
Prerequisites
Prerequisites
Course Objectives
After completing this course, you will be able to:
Design Intent
Design intent includes the location of geometric primitives, the relationships
between multiple geometric primitives, the composition of primitives into
assemblies, and the relationships between multiple assemblies. Above all, intent
implies a certain conceptual compression, whereas a few bits of information are
required, along with a formula of an intention, to elaborate a complete design
response.
If you change those bits of information, the formula is intact and so the new
complete design response still reflects the intent. A change in intentions means
literally to rewrite the formula. The way to measure whether or not the intention
has been captured is if the model behaves in the desired way when either the
formula or the information is altered. Capturing design intent, then, is to capture
the bits of information, the formula, and ultimately generating the complete
response. One does not just record it, but as one records their actions, they also
Course Overview
Jan-10
Modules Included
have to organize them into the appropriate hierarchy and order, or, design the
graph.
Modules Included
The following modules are included in this course:
Jan-10
Introduction to
Basics of GenerativeComponents
Law Curves
Course Overview
Modules Included
Advanced Topics
Basics of Scripting
Design Problems
Course Overview
Jan-10
Introduction to
GenerativeComponents
Module Overview
This module presents basic GenerativeComponents concepts. These include
aspects of the interface, and terms that relate to the process.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
What is GenerativeComponents?
GenerativeComponents is a parametric and associative design system which gives
users new ways to efficiently explore alternative designs.
GenerativeComponents captures design intent by graphically representing both
design components and the relationships between them.
GenerativeComponents enables efficient design exploration and reuse without
manually rebuilding the model for each scenario.
Jan-10
Introduction to GenerativeComponents
What is GenerativeComponents?
Introduction to GenerativeComponents
Jan-10
What is GenerativeComponents?
Jan-10
Introduction to GenerativeComponents
Copyright 2009 Bentley Systems, Incorporated
What is GenerativeComponents?
The second issue is one of education. Even if a very powerful and general tool set
is provided, there is the important task of educating designers. You need to
appreciate that, to arrive at a novel or efficient solution, you cannot use preconfigured, fixed schema applications. In order to design, you must first build
your design tools. You must accept that you are completely responsible for
creating the sequence of constructive steps that result in the appropriate design
geometry. Because the rationale is that design is improved by exploration, the
resulting geometric model must be robust enough and efficient enough to
support geometric variation, which is essential to the explorative process.
In this sense GenerativeComponents represent and supports the convergence of:
The objective is to harness a range of design skills, which may vary in emphasis,
requiring geometric, spatial, compositional fluency, and those based on
computing concepts of algorithm, type hierarchy, continuous and discrete
change.
The literal implementation of the object-oriented concepts, as supported in
currently available computer languages, does not result in a system which
supports artifact creation. One of the interesting challenges in the development
of GenerativeComponents has been the development of computing conventions
that go beyond the limitations of current Object-Oriented languages, in order to
create a system that can respond to the sense of intuition and exploration which
is essential in design.
Parametric design builds complex logical relationships between objects or
elements in a design, so to harness these possibilities requires precision in the
notation used to define these relationships.
If GenerativeComponents was conceived within the restrictive limitation of
conventional design, then it might have been valid to construct some simplified
notation with which to define these logical relationships. The problem with this
approach, might occur after a user had acquired a working knowledge of the
simplified notation and then if they progressed to a more programmatic
Introduction to GenerativeComponents
Jan-10
Second, to proceed to one line scripts through the formula bar and GC
Script.
Jan-10
Introduction to GenerativeComponents
Copyright 2009 Bentley Systems, Incorporated
A change to one element via a change to one of that element's properties is not
propagated to other elements. Some people erroneously claim this to be
parametric CAD.
At the next level of sophistication you find solid modeling applications such as
Solid Edge, Solid Works, and Inventor. These applications can correctly claim to
be parametric. In these packages, complicated feature trees can be built using
geometric primitives, or features, such as rectangular slabs, cones, spheres, etc.
and boolean operations such as union, intersection and difference. These
applications also implement domain specific features for mechanical engineering
such nuts and bolts, countersunk holes, and other typical machining operations.
These domain specific features are themselves constructed out of geometric
primitives and boolean operations, with the top-level dimensional controls
exposed to you within domain specific dialog boxes. These applications are
referred to as feature tree based, because a tree-like data structure is created
and used to control the propagation of change to other down stream features.
Each object has only one set of parents, and you cannot make a connection
between two disparate elements on different levels of the hierarchy.
Basic Parametric:
No associations or expressions.
Parameters such as wall thickness
drive geometry.
Simple Parametric:
Uses Feature Tree driven modeling,
where Parent-Child/Inheritance
relationships determine geometric
properties.
Full Associative and Parametric:
Based on change propagation and
transactions. Acyclic graph allows for
more complex relationships.
GenerativeComponents is more generalized. You can draw relationships that are
complete graphs. In most cases in GenerativeComponents as elsewhere you
cannot have feedback up the tree however without the use of an outside
controller. In other words, a leaf node cannot affect a node further up the tree/
graph. In most cases you are building a propagation network that represents your
Introduction to GenerativeComponents
10
Jan-10
design. You are deferring the final decisions on size shape and design until later
on, allowing instantly changes later on. The dependency graph used in
GenerativeComponents is a generalization of the tree structure. Any tree
structure can be represented as a dependency graph. The
GenerativeComponents graph is directed, because all the relationships are from
the upstream or independent components to the downstream or dependent
components. Many components in the middle of the graph have both inputs from
other upstream component and, in turn, influence other downstream
components. A component with no inputs is referred to as a root component. A
component with no dependents is referred to as a leaf component.
In strict graph terminology, the components are nodes of the graph and the
relationships between the components are the arcs of the graph. The relationship
between two components is established by one of the input properties of the
downstream components referring to an upstream component or to a property
of an upstream component.
The key to understanding is to realize that you can feedback the property of a
graphical component. For example, you could use the length of a line to control
the radius of a circle or adjust the angle of a plane if it is greater than 15 degrees
out-of-plane.
Once you allow bi-directional relationships between components, the cognitive
complexity explodes. Even with a reasonably-complex directed graph model, you
are challenging the cognitive limits.
There are, however, important aspects of design where design intent cannot be
modeled as simple dependency relations. Therefore, bi-directionality is an
important requirement that needs to be addressed.
Jan-10
11
Introduction to GenerativeComponents
Copyright 2009 Bentley Systems, Incorporated
or
Perform some boolean operations on a solid,
1
Introduction to GenerativeComponents
12
Jan-10
The lines connecting the features show any dependencies between features. The
arrows show the direction of the dependency.
Jan-10
13
Introduction to GenerativeComponents
Copyright 2009 Bentley Systems, Incorporated
What is a Transaction?
Each change you make is recorded as a step or transactions. Use transactions to
group multiple steps into a single, logical entity. Think of this as recording the
building of a portion of the final geometric construction. When you play the
transactions, the geometric construction is built in the Geometric view.
Transactions only record the changes or deltas. The granularity of transactions is
user defined.
Introduction to GenerativeComponents
14
Jan-10
References
References
Herbert Simon - Science of the Artificial.
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
1
What is a transaction?
Answers
Jan-10
Associative.
It contains the instructions that will generate geometry. When you open
one in GenerativeComponents, you see the working environment. It is
comprised of the GenerativeComponents dialog, the Symbolic Diagram
and a Geometric view.
View 1 is a view of the geometric and non geometric features you are
placing, in graph form. The features are circles with the feature type
noted underneath the feature name.
15
Introduction to GenerativeComponents
Copyright 2009 Bentley Systems, Incorporated
Module Review
Transactions group multiple design steps into a single, logical entity. Think
of this as recording the building of a portion of the final geometric
construction. When you play the transactions, the geometric construction
is built in the Geometric view.
Introduction to GenerativeComponents
16
Jan-10
The Basics of
GenerativeComponents
Module Overview
This module describes how to create a file, place point and line features, and edit
those features. It also discusses feature association and the Symbolic Diagram,
and information about working with transactions.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Jan-10
Create a file
Create features
Define a transaction
Edit features
17
Module Glossary
Module Glossary
Transaction
A transaction file is typical of programming tools. A transaction file is executed
one time and populates a model with elements or components. To change the
result, or create a new file, all the generated elements or components must be
deleted and the transaction file is re-run with different input parameters.
Coordinate System
The coordinate system controls the direction of the X, Y and Z coordinates. When
you create a new transaction file you are automatically assigned a coordinate
system called baseCS and it is located AtModelOrigin.
Rotate the Geometric view, View 2, to Right Isometric and you will see it more
clearly. The red line is X, the green Y and the cyan is Z. The active plane is defined
by the yellow square. When you begin it is on the XY plane. You can change the
plane to the YZ plane or XZ plane using the option list in the
GenerativeComponents dialog.
Dashed line, drawn here, indicates the active plane, which is yellow in the Geometric view
18
Jan-10
File Formats
Feature
A feature is the name used to describe different geometric constructions. These
can be general such as lines, arc, curves or surfaces and solids or they can be an
action such as Export. In turn, what you build can form the basis of new features
or generative components such as a box, a wall, or a column. The generative
components that you create will be loaded every time you launch the
GenerativeComponents application.
T Value point
A T Value point denotes a relative position that is controlled by the parameter
value T, in the range of 0.0 to 1.0, along a line or curve.
Double
A double is another name for a Real number; any number with a decimal value
(1.0, 0.5, 0.03 101.9).
Integer
An Integer, or int, is any whole number (1, 2, 101).
File Formats
GC works with the MicroStation DGN file and the DGN file can be used as the
container for GC work.
There is a separate GCT file format that can be created from Save As ...
The DGN is an auto-save format, so long as you save your transactions you will
not need to save the DGN explicitly. In addition, the DGN format uses Models.
When working with GC the term Models refers to a container for graphics and
information. For example, in Microsoft Excel you have different worksheets. Each
worksheet is separate from the others and unless you link them they are
independent numerical spaces. In GC, the Models are like worksheets. They are
independent graphical spaces. They are almost like separate files in one big
container.
Jan-10
19
The GenerativeComponents GCT file does not save geometry, but the instructions
to generate geometry, so the GCT file cannot be opened in base MicroStation or
other CAD programs directly.
20
Jan-10
Basic Types
Basic Types
Built-in Types
Microstation Types
These are the types that GC is built on. They exist, but you do not use them in GC.
It is only possible to use these in C# programming interface.
GenerativeComponents Types
IPOINT - parent class (zero dimension (0D) object)
Plane (location and direction: infinite plane therefore divides the world into
two half spaces. Can also be thought of as a 2D cartesian space, with X and Y
coordinates
CoordinateSystem
vector
line
line
arc
circles
ellipses
b-spline curves
Jan-10
surface
21
Basic Types
solid
IPOINT
IDIRECTION
ISURFACE
ICURVE
ISOLID
Line
Vector
Point
Arc
(location)
Circle
Line
Plane
(location and direction)
Ellipse
Solid
B-Spline Surface
Elliptical Arc
Plane
B-Spline
Coordinate System
(location+direction+translation,
rotation, scaling, shear)
Composite Curve
Define
IPOINT
Offset
Define
IDIRECTION
Intersect
ICURVE
ISURFACE
Extract/Intersect
ISOLID
Define
22
Jan-10
Basic Types
Jan-10
23
View Controls
GC Task
Views to draw graphics
Tabs
Tool Settings
GC is case sensitive.
24
Jan-10
There are also menus that contain options not represented by the icons.
Jan-10
25
Getting help
As you step through each transaction, observe the changes on the screen.
Transaction
New Feature
Edit Feature
Variables
Console
Quick Help
Coordinates
Getting help
Access the regular Help file by selecting Contents from the Help menu.
26
Jan-10
Getting help
Example Help
Help is available in the form of pre-built examples. Each Feature type has the
option to show an Example.
Jan-10
27
Getting help
In the GC dialog, click Play All Remaining Transactions to see the geometry
that results from the example.
Spend a few minutes to try other Features and Update Methods and
explore their Examples.
Use the window control in the upper right to close the Examples tab.
This will also close the View and the Example Symbolic Diagram.
28
Jan-10
Getting Started
Getting Started
Create a transaction file
GenerativeComponents has a GCT file format. It is a simple ASCII text file that can
be opened with a text editor. If you double click on a GCT in Windows Explorer
you launch GenerativeComponents and open that file.
By default, GenerativeComponents uses seedGC.dgn to create the design file in
which you will create geometric components. This file is like a scratch file. The
directions needed to create the geometry are stored in the DGN file. The DGN file
is used to assemble and display the model that you will build and can be Saved As
a GCT file.
CAD managers should use their own default seed files as a basis for creating their
own seedGC.dgn. The delivered file is an example only, and will not contain
project specific working units, levels or any other settings.
Jan-10
29
Getting Started
Isometric and then fit it, using the view controls. Click the right mouse button
to reset after using a view control to return focus to the
GenerativeComponents dialog. Minimize View 8 and use it when you need to
identify direction.
30
Jan-10
View Control
The Transaction File tab is does not list anything because nothing has
been recorded to the transaction file.
View Control
When you work in a 2D model, you can rotate the view. Visually, this is like
rotating the xy-plane about a perpendicular, or z-axis. When you are working in a
3D model, you can rotate the view about any axis (the x-, y-, or z-axis). Again, the
Jan-10
31
View Control
visual effect on screen is like rotating a cube. You can rotate any view to a
standard view or to any other arbitrary view orientation.
When you dynamically rotate a view, for example, you can use either of the
following methods:
Using a tool
View Rotation
32
Jan-10
Creating Features
This tool is helpful in general as well as when you have elements on the same
level and some elements you want to see and others you do not.
You can use 2D or 3D elements to define the volume. When you use a 2D shape,
the clipping volume is created by sweeping the 2D shape through the entire
model. The sweep direction is perpendicular to the plane of the 2D element.
MicroStation creates a 2D clipping shape using active attributes. When a 3D
element is used, it defines the entire clip volume.
Operations, such as view rotation, fence processing, hidden line removal, and
rendering, honor the clip volumes. They ignore any elements that are not
displayed within the defined volume for the view.
Clipping elements may consist of any solid or closed extrusion, cylinders, or
closed planar elements (shapes, circles, ellipses, complex shapes, grouped holes).
Where a planar element is chosen, or you use the clipping elements by points
options, the clipping volume is generated by sweeping the planar element
through the entire model. Planar elements may be selected in any view, because
the sweep direction is orthogonal to the plane of the element. Similarly, clip
elements that you define by points may be drawn in any view. AccuDraw can be
used to set the correct orientation of the clip element.
ClipVolume is also the name of a feature type and can be used as any other
feature.
Creating Features
A feature is a graphical element or an operation on a graphical element or a
function to control graphical elements.
Jan-10
33
Creating Features
Points
It is all about Points. Almost every feature is dependent on Points.
Points are the basis of the geometry you will create. GenerativeComponents
stores the relationship between the points and associated geometry and
computes the associated geometry from the current value of the points.
Create Point tool and Line feature
Enter a data point in the Geometric view to place one point, enter another
data point to place a second point, and then click the right mouse button
to end the command.
34
Jan-10
Creating Features
Two point symbols have also been added to the graph in the Symbolic
Diagram.
Note: GC automatically names new features with their type and then a serial
Jan-10
35
Creating Features
Scroll to Line in the Feature Type list and click the + to expand the entry.
You see many update methods by which you can create lines. You will
create a line ByPoints.
5
Scroll to the ByPoints update method and expand it to see the properties
you must define.
Press and hold the Ctrl key on the keyboard, and then move the pointer
over the first point in the graphics view.
36
Jan-10
Creating Features
The point highlights and its name appears in a pop-up. You can select
features from either the graphic or Symbolic Diagram.
8
While still holding the Ctrl key, enter a data point (left mouse button), or
press Enter on the keyboard, to accept.
Press and hold the Ctrl key on the keyboard, and then enter a data point
on the second point.
The fields are populated, but no line has appeared.
Jan-10
37
Creating Features
If you are drawing multiple lines by points, first place all the points, then click the
Create New button. This takes you back to the same location in the Feature Type
list so you can define the next lines parameters.
38
Jan-10
Creating Features
Expression Field
If you feel comfortable with those expression fields then you will be fine with GC.
Jan-10
39
Creating Features
In the expression field you can enter data using Ctrl+mouse click or typing in
information.
Number
Expression
Function
For example, simple numbers, simple computations or scientific calculations. You
can even do complex expressions like:
(1/acos(0.9)+1)*5
These calculations follow the PODMAS rules:
P - Parentheses first
Orders - Powers and Roots
DM - Division, Multiplication
AS - Addition, Subtraction
Some useful notations are:
xy = Pow(x,y)
Square Root = Sqrt(x)
There is much more that can be done here, so it is important to understand these
basic functions before more complex uses of the Expression Field are used.
Defining a transaction
A transaction is a single event in a GC file. It might be placing a point, drawing a
line, moving a point, importing Excel data or many other things.
40
Jan-10
Symbolic Diagram
The geometry disappears from view. It is not gone, though, because the
instructions about placing the points and the line remain in the file. You
play the transaction to reconstruct the geometry.
8
Click the Fit button, to the right of the transaction player controls.
Now all geometry will fit in the views. Enable this button any time you
want to fit everything into the views.
9
10 Expand point01.
You can see how it was constructed. The coordinate system on which it is
based is a property and also its X, Y, and Z coordinates. Handles are used
to edit features. Use the HandleVisible property to toggle their display.
11 Save the file as first_line.gct
Symbolic Diagram
The Symbolic Diagram shows the features created and their relationship. Almost
every symbolic diagram will have a Coordinate System, by default it is given a
Jan-10
41
Symbolic Diagram
name of baseCS. There are several tools to help with managing the symbolic
diagram.
The tools in the top of the window allow you to set the direction of the flow chart,
with options for Top, Bottom, Left and Right. There are Zoom In, Zoom Out, Fit
View, Actual Size and Refresh.
The Search button on the right allows you to find a specific string of text as a
name or content in the Symbolic Diagram.
42
Jan-10
State
There is also right-click functionality in the Symbolic Diagram. When you right
click on a feature in the Symbolic Diagram you see the following menu.
State
The State dialog is showing which plane you are on and allows you to change the
plane. You may dock it anywhere, for example on top the tool settings so it forms
a tab.
Jan-10
43
Parameter Spaces
Parameter Spaces
Parameter spaces allow you to describe a mathematical relationship between the
parameter space and the geometry.
UV Values
on Surface
UV Values in
Parameter Space
The figure shows a 2D representation of a 3D space to provide a method of action
of the surface.
T Value point
A T Value point denotes a relative position that is controlled by the parameter T,
in a range of 0.0 to 1.0, along a line or curve. It is created by the feature Point >
ByParameterAlongCurve.
Scroll to Point in the Feature Type list and expand the entry.
44
Jan-10
Parameter Spaces
Press and hold the Ctrl key on the keyboard, and then enter a data point
on the line, or press Enter on the keyboard, to accept.
Note: If an invalid expression value is entered the field will become shaded.
Type 0.5.
This means that the point will always be in the center of the line. The
value 0 would place a point at the start of the line, 1.0 at the end of the
line, 0.2 at 20% from the start of the line, and so on.
Rename the feature TValuePoint in the Name of feature field, and then
click OK.
A point appears in the center of the line.
Select the Transaction File tab and click Record User Changes into the
Transaction File.
Jan-10
45
Parameter Spaces
Editing Features
You can edit a feature different ways. You can use the Move Feature tool to move
a feature in the geometric view, you can change the values in the Expression
fields on the Transaction File tab or you can click the blue property editor icon
that appears when you click in the Expression field and enter values in the
resulting dialog.
X-axis = Red
Y-axis = Green
Z-axis = Cyan
Select the Move Feature tool, click on one of the handles, and the point will move
along the selected axis, adjusting the corresponding parameter accordingly. For
each pair of axes, X-Y Y-Z and X-Z there is a corner handle. If that one is selected
you can change both variables simultaneously (move in a plane instead along an
axis). However, you cannot click the center of the point and move it.
Click one of point01s red handles, continue pressing the mouse button,
and move the point along the X-axis.
46
Jan-10
Parameter Spaces
A Feature Coordinates tab dialog is opened. It has been docked with Tool
Settings and State.
3
Select the Transaction File tab and check the XTranslation value for
point01.
It has not changed. The values here are part of the first transaction.
Jan-10
Click Record User Changes and replace the default name with a more
meaningful name, if desired.
Expand the new transaction, expand point01, and see that the changes to
point01 are recorded as a separate transaction.
Click Save.
47
Parameter Spaces
The T Value point appears and then point01 and the line move.
You can turn handles off from Tools > Toggle Feature Settings > Handles Visible or
In the free state you can use the graphic handles to move a feature interactively.
If a value is typed in manually, or the button is pressed, it changes to locked and
the feature can only be edited through a parameter edit.
48
Jan-10
Parameter Spaces
Feature association
During the exercise you saw that moving point01 moved the line and the T Value
point. That is because of the dependencies, which you can see in the Symbolic
diagram. The graph in the Symbolic diagram shows that the association flows
directly from point01 and point 02 to the line. The line is dependant on the
points, which are dependant on the location of the baseCS.
The T Value point is also dependent on the line. So, when you change a feature on
a higher level of the hierarchy, all other features which are linked to that feature
will update accordingly.
The symbols in the Symbolic diagram did not move when you moved the point.
You can move the symbols as desired in the Symbolic diagram to get a clear idea
of the feature structure of your model. This does not change their position
geometrically.
Note: You can also select the feature in the Geometric view. However, since
the T Value point sits on the line, it is easier to select it in the Symbolic
diagram.
The Edit Feature tab is added to the GenerativeComponents dialog.
3
Click in the T: double field, change 0.5 to 0.3, and click Apply.
The point moves closer to the start of the line.
Note: A transaction will also be recorded if you unplay and replay all
transactions.
Jan-10
49
Parameter Spaces
Click Save.
Suppress transaction
When you right click on a transaction, or the node that precedes it, you can select
Suppress Transaction from the menu. This allows you to play the steps in the
transaction file, skipping the steps in that particular transaction.
While you can delete transactions from the right click menu, it is better to
suppress transactions than delete them. Once the work is done, you may want to
apply it else where. You can copy and paste transactions to do this.
50
Jan-10
Parameter Spaces
The T Value point moves, but point01 and the line do not move since the
instructions that make this occur have been suppressed.
Right click on the last transaction that is now listed and select Paste
Transaction > Insert After.
Click Save.
Any of these changes can be saved without changing the current transaction file
by selecting File > Save <file name> As.
Jan-10
51
Select the Create Point command and place five points as shown.
52
Jan-10
Select Create Feature and draw two Lines, with method ByPoint, as
shown. Use the default names (line01 and line02).
Select Create Feature and create a Line with method ByPoints, select the
point off to the side and the intersection point.
Jan-10
Select the Move Feature tool and click on the corner (where the red and
green lines touch) to move the point in a planar fashion.
53
Select the corner in the upper right so that you can move in X and Y.
Note how the third line disappears when the intersection condition is
broken.
54
Jan-10
Module Review
This point is only created at the time it is needed, and does not exist otherwise.
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
1
What is a double?
What is an integer?
Where are the directions about how to create the geometry stored?
Answers
Jan-10
A double is another name for a Real number; any number with a decimal
value.
The directions about how to create the geometry are stored in a DGN file.
In the free state you can use the graphic handles to move a feature
interactively. When locked and it can only be edited through a parameter
edit.
55
Learn the basics of the interface. Spend 15 minutes exploring menus and
tools for your first few sessions.
Understand how to use the View Controls, spend five minutes at the
beginning of each session practicing zoom in/out and rotating. Spin the
mouse wheel for Zoom In/Out, double click to fit the view and Shift+press
the wheel for Rotate about center of view.
Remember it is all about points. Explore the Point feature and its Update
Methods.
The Symbolic Diagram is a great way to find, insert into expression fields
and operate on features.
56
Jan-10
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Drawing economically
Introductory Knowledge
Before you begin this module, let's define what you already know.
Jan-10
57
Copyright 2009 Bentley Systems, Incorporated
Module Glossary
Questions
1
Answers
1
In the expression fields for the update methods for different feature
types.
Module Glossary
Graph variable
These work hierarchically and affect elements in the graph to which they belong.
A graph variable will control all elements or constructions that reference it. When
you change the graph variable, all references to that variable will change along
with it.
Curly brackets {}
These are used to define collections or sets, such as a set of features made up of
{point01, point02, point03}. These can be passed as a parameter value.
Syntax
Sets
Sets use curly brackets: { }
58
Jan-10
Syntax
Consider a circle defined by a center point and radius. You could have one circle
with a defined radius of 5 units.
Radius set to 5
or,
you can have a set of circles by using curly brackets and a set of numbers for radii.
Jan-10
59
Syntax
Index
Index of inputs uses square brackets: [ ]
The Index count starts at 0.
For Circle01 below we have:
[3]
[4]
[2]
[0]
[1]
60
Jan-10
Syntax
For example, consider the 2D array of points, this is two sets of X values and Yvalue for one point, point01:
Point01[0][2]
Point01[5][3]
Point01[2][0]
Point01[9][0]
Within a set you can also mix types, for example add a variable as a set member.
Functions
Functions use parentheses ( ). For example,
Sin(1.28)
Series(0,9,1)
Jan-10
61
Graph Variables
Graph Variables
The Symbolic view contains the graph, or graphs, of geometric and nongeometric features. You can create a new model and its baseCS is free from the
default models baseCS. The Symbolic view can contain more than one graph, and
they only become interrelated if you design a dependency between them.
Variables are named data containers that can hold values as single values or as
lists of values. The values are accessed by using the variable name in place of the
needed value.
A graph variable belongs only to one graph. A graph variable named ObjectHeight
in the default graph is exclusive of a graph variable named ObjectHeight in a
graph named secondaryModel.
62
Jan-10
Graph Variables
Jan-10
63
Graph Variables
10 Select the Transaction File tab, click Record User Changes and replace the
Continue in the same file, and ensure that you are working in the Top view
rotation in the Geometric view.
You want to place four points on the same plane.
Place 4 points.
Scroll to Polygon in the Feature Type list, expand it and then expand the
ByVertices update method.
Place the pointer in the Vertices expression field, press and hold the Ctrl
key on the keyboard, and then select the four points.
64
Jan-10
Graph Variables
Press Enter.
Note that in the expression filed the vertices are a set of points with curly
braces.
Select the Transaction File tab, click Record User Changes and replace the
default name with a more meaningful name, if desired.
Now you need to define the center of the polygon and place a point at that
location.
Jan-10
65
Graph Variables
allradii[5] = 10
Remember with a list you start counting at 0.
Sets or Collections
Parameters that include (repl.) let you use a list of inputs, effectively replicating
the feature that they define. For instance, instead of a single value for the X
parameter of a Point> ByCartesianCoordinates there will be as many point
instances as there are values in the list.
Use curly braces to surround input that you want to be treated as a set.
When a collection is required as the input property, GenerativeComponents
displays {} (the symbol for an empty collection) to indicate this. You can add to
the contents of a collection. For example, in the Expression field:
{point01, point02, point03}
You should be aware that the choice to add or not add an additional level of nest
might have downstream effects. For example, if these points are being used to
define the StartPoint of Lines. The affect of adding a {}, is adding an additional
level of nest, is that when you hover over the resulting lines you will see:
line01[0][n]
66
Jan-10
Graph Variables
Without the additional level of nest you will see line01[n], where n is the index of
the Line being hovered over. So, the additional level of nest caused by the
(potentially) redundant {} propagates down stream via the replication process.
You need to be aware of this and consciously control this process.
The purple box icons in the list indicate an alternate Update Method or Function.
The hand on the list icon indicates a Property of the feature.
You can use these properties to create new features. It is an economical way of
working, as it will reduce the number of features overall.
Sets and dot operators are two of the most powerful tools of GC (there are many
others), but you must master the use of sets and variables.
In the following exercise, you will use a set consisting of the four points to define
the center of the polygon. This point will be the base of a new coordinate system
which will help when establishing the pyramids height.
Jan-10
67
Graph Variables
Scroll to Point in the Feature Type list, expand it, and then expand the
CentroidOfSet update method.
Click OK.
Select the Transaction File tab, click Record User Changes and replace the
default name with a more meaningful name.
68
Jan-10
Graph Variables
graph variable. This means that if you rotate the pyramid, the height will always
be perpendicular to the base.
Scroll to Coordinate System in the Feature Type list, expand it, and then
expand the ByOriginXPoint update method.
Required parameters are the origin and an X point.
Place the cursor in the Origin expression field, press and hold the Ctrl key,
and then select the centroid point.
Click OK.
Select the Transaction File tab, click Record User Changes and replace the
default name with csPyramid.
Now you need to draw a line in the Z direction from the centroid, defined by
GraphVariable PyramidHeight. This will define the height of the Pyramid.
Scroll to Line in the Feature Type list, expand it, and then expand the
ByStartPointDirectionLength update method.
Place the pointer in the StartPoint expression field, press the Ctrl key, and
then enter a data point on the centroid.
Note: It may be easier to select the point (point05) in the Symbolic view.
Jan-10
69
Graph Variables
Place the pointer in the Direction expression field, press the Ctrl key, and
then enter a data point on csPyramid.
Now you need to define the direction in which you want the line to go. To
define height, you need to indicate the Z direction. So, you will define the
property csPyramid.ZDirection.
Place the pointer after csPyramid in the Direction expression field, and
type a period. This is the dot operator.
A menu containing valid parameters opens.
Place the pointer in the Length expression field, press the Ctrl key, and
then select the GraphVariable in the Symbolic view, as it is not in the
Geometric view.
Click OK.
70
Jan-10
Graph Variables
You will now add a point at the end of the vertical height line. This is
helpful in some instances when using this pyramid. Though you could
simply use the endpoint of the line just created.
11 Select Create Feature, select Point with Update Method of
How could use exisiting geometry and avoid creating this point?
As you will find out you will need it later, so please create it.
Scroll to Polygon in the Feature Type list, expand it, and then expand the
ByVertices update method.
Place the pointer in the Vertices field, press the Ctrl key, and then select 2
edge vertices, and the ptTopPoint .
Vertices: {polygon01.Vertices[0],polygon01.Vertices[1],ptTopPoint}
ptTopPoint.
4
Click Create Copy and create filled polygons ByVertices on the other 3
sides. Simply change the index of the vertices. For Example,
Vertices: {polygon01[1],polygon01[2],ptTopPoint}
You can rotate the view dynamically so you can distinguish the sides.
Reset after using a view control to return focus to the
GenerativeComponents dialog.
Jan-10
71
Graph Variables
To see the fill attribute, click the MicroStation icon at the upper left of
View 2 and select View Attributes. Enable the Fill check box.
Use the slider bar to change the graph variable of the pyramid height.
You can also edit the graph variable by selecting the Edit Feature tool and
clicking the GraphVariable in the Symbolic view. Then you can change the
object Value expression.
Hint: Think about using one line endpoint as the start point of another line.
Drawing Economy
There are more efficient ways of drawing the geometry we created.
Click the Create Point tool, create 2 points and then create a line ByPoints.
To draw a second line perpendicular to the first, graphically you would
create a third point and then the line. You can also draw the line using
additional feature properties.
72
Jan-10
Graph Variables
Place the pointer in the Origin expression field, press and hold the Ctrl
key, and then select the first point.
Click OK.
Scroll to Line in the Feature Type list, expand it and then expand the
ByStartPointDirectionLength update method.
10 Place the pointer in the StartPoint expression field, press and hold the Ctrl
line01.StartPoint
The StartPoint of line02 is now defined as line01.StartPoint. Next you
define the direction of the line as CoordinateSystem01.Ydirection.
Remember you defined the X Direction when you selected point02 when
you created the new coordinate system. When you select the Y direction
you know it will be perpendicular to line01.
13 Place the pointer in the Direction expression field, press and hold the Ctrl
Jan-10
73
Graph Variables
14 Place the pointer in the Length expression field, press and hold the Ctrl
key, select line01, type a period, then and double click on Length to select
it.
15 Click OK.
Click OK.
74
Jan-10
On the Transaction File tab, click Record User Changes and replace the
default name with a more meaningful name, if desired.
Jan-10
75
You must use the correct syntax, as the file is case sensitive.
3
Click OK.
76
Jan-10
The transaction file does not tell you which type of line or point you have created.
It just lists feature line04 GC.Line. It does not note that it is a line
ByStartPointDirectionLength or ByPoints. This because GenerativeComponents
knows which feature type you have used by the expression inputs. Each feature
has a set of unique expression inputs.
In the GenerativeComponents dialog, click the Edit Feature tool and select
line04.
Select Also show inactive update methods to see alternate ways to draw
that feature.
Expand ByStartPointDirectionLength.
Some of the expressions are already entered. All you need to do is supply the
required expression, or expressions, that are unknown and click Apply to change
the update method used to draw the line. The exact update method GC chooses
(by itself behind the scenes) relies upon an analysis of the input properties
supplied, giving preference to the latest input properties supplied.
Jan-10
77
Module Review
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
True or False: The Symbolic view can contain more than one graph.
Why did you crate a T Value point at the top of the ZDirection line, the top
of the pyramid?
When defining the length of the ZDirection line, why did you select the
GraphVariable in the Symbolic view?
True or False: Once you have created a transaction file you can edit it.
78
Jan-10
Answers
1
A variable that controls all elements that reference it, within a specific
graph.
A set of values.
True. The Symbolic view can contain more than one graph and they only
become interrelated if you design a dependency between them.
So you could control the height of the pyramid from this defined position.
The pyramid height will always be perpendicular to the base.
True. Use the Edit transaction file tool to open the transaction file.
True. You must use the right syntax, as the transaction file script is case
sensitive.
On the Edit Feature tab there is an option list that shows the Active
update method. Select Also show inactive update methods to see them.
Jan-10
Sets can be created in two basic ways: curly brackets or a Series function.
There are other ways but these work well for most challenges.
Know how to read and find a location in a list for example, Line01[2][1]
Be efficient: Use the output of one feature as the input of a new feature.
Know your Types: Variable Types (string, bool, int, etc) and GC Types
(IPoint, ISolid, etc).
79
80
Jan-10
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Use Replication
Module Glossary
Series
Round brackets or parentheses () are used to define functions like a Series. One
example of a Series is a collection of points along a line or a surface. The Series is
defined inside the parentheses (start, finish, increment). These inputs generate
and return a collection of numbers from the start to the finish, at intervals
specified by the increment.
Jan-10
81
Copyright 2009 Bentley Systems, Incorporated
Module Glossary
These are Series of ints and doubles, for example. Series(1, 10, 1) returns {1, 2, 3,
4, 5, 6, 7, 8, 9, 10}. It starts at 1, ends at 10 and increments at intervals of 1.
Series(1, 10, 2) returns {1, 3, 5, 7, 9} Series(2, 3, 0.25) returns {2, 2.25, 2.5, 2.75,
3}.
Function
A Function turns inputs into something else. A Series is a type of Function. Each
Function listed in GenerativeComponents Script Expression Builder has a short
description. What the Function returns, or gives you back, is also noted. When
you use a Function you can see the syntax, or, how to write the inputs. A quick
way to access functions is to use the Fx button in the Script Builder. The most
important question to ask is, What does a function return. The answer has to be
in two parts: what type does it return (string, double, int, etc) and what value
does it return.
Replication
Replication in GenerativeComponents is to make copies of a feature, through the
use of series or curly brackets.
(repl.) = replicable
If you have a feature type comprised of a line drawn between a start point and an
end point, when you place this feature it would respond to a single start point
and a single end point. However, if you make features within it replicable, it can
respond to a series of start points and end points. The resulting generated feature
type would be a set of lines.
82
Jan-10
Creating a Series
We have seen replication at work with the multiple circles. One radius = One
circle. Four radii = Four circles. You do not draw four circles, you simply specify
four radii.
Creating a Series
When you want multiple sets of points to define geometry, and you know exactly
what the increments between those points should be, you can use a Series.
Select File > New File. Name the new file Series.dgn
Make sure that you are working in the Top view rotation in the geometric
view.
Scroll to Point in the Feature Type list, expand it and then expand the
ByCartesianCoordinates update method.
Place the pointer in the CoordinateSystem expression field, press and hold
the Ctrl key, and then select the baseCS in the Symbolic view.
You will use a Series to define the X and Y and Z coordinates. A Series is a
Function, so you will select it from the Script Expression Builder.
The Series Function will create a list of values given a start value, final
value and the increment. Start, final, and increment are referred to as the
arguments of the function.
Jan-10
83
Creating a Series
84
Jan-10
Creating a Series
Select the Functions tab in the Script Expression Builder, scroll to Series,
and double click it.
Place the pointer inside the parenthesis and replace (start, finish,
increment) with 5,15,1.
Jan-10
85
Creating a Series
There are 11 points along the X-axis, equidistant apart. (There are not 15
points, as you started at 5, not 0.)
14 Select the Transaction File tab, click Record User Changes and replace the
How would have created these points using a Set with Curly Braces?
Continue in the same file, and select Create Point and add another point.
Select Create Feature, select Line with the Update Method ByPoints, and
set the following:
StartPoint: point01
Remove the indexing of point01, so should read point01, not point01[0].
EndPoint: point02
Lines are automatically drawn to all instances of point01.
Move Point02 and see what happens. Did you expect the result?
86
Jan-10
Creating a Series
Editing a Series
Use the Edit Feature Tool to edit an existing series. You will edit the points so that
the Series is in the Y direction rather than the X.
Continue in the current file, and return to the Edit Feature tab.
Click Apply.
Select the Transaction File tab, and click Record User Changes.
On the Edit Feature tab, copy Series(5,15,1) from the YTranslation field
and paste it into ZTranslation field, replacing the 0 value.
Click Apply.
Jan-10
87
Replication
Replication
While it is a fancy word, replication is a simple concept, and one that all designers
have used in regular CAD application and that is copying. In GC, the copying is
more intelligent and controllable. In addition, one can easily do multidimensional copying as well. The initial concept of replication is based on the
Series function or by typing in a set as an input.
In addition, you can turn the Replication style to see all combinations.
Continue in the same file, and edit the point01 feature and replace the
XTranslation expression field with Series(1,9,2).
88
Jan-10
Replication
What you see here is are lines going from one point (point02) to five
instances of point01, but in this case the point01 instances are at
{(1,1),(3,2),(5,3),(7,4),(9,5)}, which corresponds to point01[0], point01[1],
point01[2], point01[3], point01[4].
3
Jan-10
Place the cursor on any instance of point01, and note the dual instancing.
89
Replication
Exercise: 3D Replication
1
90
Jan-10
Sort
While a very useful function Sort is generally used in GC Script, though the
thoughtful geometrician can certainly use this function in an expression field.
The sort function goes through the list making comparisons between pairs of
values according to a supplied sort criteria/function. The general form is:
Sort (numbers, function(x, y)
where function(x,y) tells us how to sort (ascending, descending, etc). For
example,
double[] sortedNumbers = Sort(numbers, function(x, y) { return x < y; });
sortedNumbers is just a variable that is delcared on-the-fly.
Here the sort criteria is set by calling a temporary function where for each x < y
the number (x) is lower in the list.
The Sort funtion returns an object, a sorted list.
Jan-10
91
Sublist
Returns a new list comprising a contiguous sequence of members of the given
list. Specifically, the resultant list comprises the members at index positions
(firstIndex) through (firstIndex + count 1), inclusive. If the count is omitted, the
entire remainder of the list is returned.
For example, if you have a Series of point01 and you use:
Sublist(point01,1)
then you start at point01[1] instead of point01[0].
Add
Returns a new list comprising all members of the given list, plus the given
additional value. This function does not change the given list. To add a new
member directly to the end of a list, call the Add method on that list, itself.
Place four Points and create two Lines between them as shown.
92
Jan-10
Now you will use the Sublist function to create lines between the Series
points.
5
Select Create Feature and choose Line with Update Method of ByPoints
with the following parameters:
StartPoint: point06
EndPoint: point05
Now you shift the start point of the cross lines by one.
Select Edit Feature and choose Line just drawn and change the following
parameter:
StartPoint: Sublist(point05,1)
Jan-10
93
94
Jan-10
Module Review
Optional Exercise:
Try doing the same thing with two circles and a series of lines in between
them.
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
1
What is a Series?
Answers
1
Click the fx icon in the feature expression field. Select the Functions tab in
the Script Expression Builder, scroll to Series, and double click it.
When you want multiple sets of points to define geometry, and you know
exactly what the increments between those points should be.
Jan-10
You can create a list by using a set (curly braces) or a Series function.
95
96
Jan-10
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Jan-10
97
Copyright 2009 Bentley Systems, Incorporated
Create a new DGN file, by selecting New File. Provide a name for your file.
Select Create Feature and place a Line, ByPoints between the two points.
Hint: The quickest way to Rotate the view about center is to use Shift+Middle
98
Jan-10
Select the Move Feature tool and move point01 and note the change in
the height of the vertical line. Right-click to cancel Move Feature.
Continue in the same file, select Edit Feature, and select point02.
Rotate to the Front View to see that each line is of a different height.
Try replacing the XTranslation field of point01 with a Series and see what
happens.
Can you explain what you see?
Jan-10
99
Object Operators
Object Operators
The following operators can be applied to any values of any type, since every
value is an object, in addition to whatever other type (IPoint, ICurve, etc.) it is.
Keep thinking of value and type.
val1 == val2
Is the test for equality. The result in a boolean (bool) value. The result is true if the
two values are equal, false if they are not.
val1 != val2
Is the test for inequality. Results in a bool value that is true if the two values are
not equal, false if they are.
b ? val1 : val2
Is a conditional expression. This is a very useful operator and one that is used
widely.
This is another important tool. Remember it.
The value b must be an expression of the type bool. The values val1 and val2 may
be of any types and not necessarily of the same types. For example,
If b is true, the result of this operation is val1 (and val2 is not even calculated).
If b is false, the result of this operation is val2 (and val1 is not even
calculated).
val is type
Is the test for data type. Operators can be words as well as punctuation marks.
The value type is the name of a data type, such as double. Results in a bool value:
true if the value is of the specified data type, false otherwise.
More precisely, the is operator returns true if and only if the value (number,
string, etc) is an instance of the specified type. This means that:
100
Jan-10
Object Operators
The value was created as an instance of the specified type, or of a type thats
derived from the specified type.
or
The specified type is an user type, and the value was created as an instance of a
type that implements that user type, either directly or through derivation.
Note that the is operator tests for what the value actually is, not for what it could
become through automatic type conversion.
val as type
Is another test for data type with a different output than the previous.
The value type is the name of a data type, such as double. Results in val if that
value of the specified type, otherwise results in null.
The as operator is functionally equivalent to - val is type ? val : null
Jan-10
101
Object Operators
This gives you access to properties like color, style, and weight among
others.
4
102
Jan-10
Object Operators
This entry says if the length of line02 is less than 7 (you may need to adjust
this number), then make it green (color 2), if the length is greater than
make the line red (color 3).
Two right-most lines are red while the left are green
Now lets look at another method of a doing a vertically dependent line by using
an inverse relationship.
Name it reactor.dgn.
To begin, you will place two Points in a Right Isometric view in the Geometric
view. One of these points will represent a tree within a courtyard. This can also be
called the trigger point. The other point will represent the base point, or grid
point, for a roof.
Click the Create Point tool and enter 2 data points in the Geometric view
to place 2 points.
You will create a Line between these points in order to measure the
distance between the tree and the roof base point.
Jan-10
Scroll to Line in the Feature Type list, expand it and then expand the
ByPoints update method.
103
Object Operators
Hint: To select an existing feature, place the pointer in the desired expression
field, press the Ctrl key, and then click the feature in the Geometric
view with the left mouse button (a data point).
4
Select the Transaction File tab, click Record User Changes and replace the
default name with a more meaningful name, if desired.
Click Save.
Now you will create a point that is vertically offset from the base point of the
roof. You will create another Line, but this one is based on the location of the
base point (as the StartPoint) and in a vertical direction, with a length equal to the
length of first line you created. The Update Method for this new line is
ByStartPointDirectionLength.
Scroll to Line in the Feature Type list, expand it and then expand the
ByStartPointDirectionLength update method.
Place the pointer in the StartPoint expression field, press and hold the Ctrl
key, and then enter a data point on point02.
104
Jan-10
Object Operators
Place the pointer in the Direction expression field, press Ctrl, and then
select the vertical, Z, axis, of the baseCS.
Place the pointer in the Length expression field, press Ctrl, and then enter
a data point on line01.
Place the pointer after line01 in the Length expression field, and type a
period.
A menu containing valid parameters opens.
Click OK.
As before, you can test a model dynamically by moving one of the input points
and observing the resulting behavior.
Note: The length of line02 is always the same as the length of line01.
If the StartPoint of line02 represents the base point of the roof, then EndPoint of
line02 represents the height of the roof. You want the roof to be higher the closer
it is to the tree, which is represented by point01. You have the inverse of the
relationship that is required. You will change this.
Jan-10
105
Object Operators
You add the +1.0 to line01.Length, so that if line.01.Length was zero, you
would not divide by zero. Put line01.Length+1.0 in parentheses so that
this is evaluated before the division.
3
Experiment with different expression for the Length input property for
line02.
Point02 and line02 represent a sample point within the proposed courtyard. You
now want to replicate point02, and hence line02, to represent a grid of points
within the courtyard.
Click on point02.
You are going to change the single XTranslation value to a Series.
Copy and Paste the expression Series(5, 10, 1) into the YTranslation and
ZTranslation fields field and press Enter.
Fit View.
106
Jan-10
Object Operators
Click the Toggle Replication tool and select point02 in the Symbolic view.
You have a list of points, where each point has a corresponding
YTranslation for each XTranslation. You want a rectangular array of points
and lines, where, for each XTranslation, you iterated through all values of
YTranslation.
In order to see what you created, you need to suppress the display of some of the
intermediate construction. To make the length of the vertical lines (line02) more
readable, you can display the EndPoint using the Toggle is Construction tool, then
use the Toggle Visibility of Construction tool.
Jan-10
107
Object Operators
Select point02 and line01 in the Symbolic view to make these elements
Construction elements.
108
Jan-10
Object Operators
The points representing the courtyard roof points (point02) are fixed in
the X and Y using the Series function. You will move the point
representing the tree (point01).
5
Selecting a handle
Jan-10
109
Object Operators
Click Save.
110
Jan-10
Module Review
Deferred Dynamics - Turns on/off the Dynamic response in the view. Not used
very often, sometimes helpful when working with large models.
Extra Exercises
Try to control the radius of a circle with a proxmity of a point. The closer the point
the lower the radius. Then use a Series to replicate the circle in a squre grid and
then test with moving the point.
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
1
Answers
Jan-10
111
Tools > Toogle Feature Settings or the seventh icon in the Main task.
You can Copy and Paste from one expression field to another.
Use Toggle Display option where helpful. Remember they are toggles and
can easily turned on and off.
112
Jan-10
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Label Polygons
Module Glossary
Working Prototype
Working prototypes are functioning prototypes developed for the purpose of
proving and testing a concept and design. Working prototypes are not about
Jan-10
113
Copyright 2009 Bentley Systems, Incorporated
Your GC Workflow
CONCEPT + PREPARATION
You will first need to evaluate design challenges and pick one that suits your
interest. You will then need to prepare a method to achieve the desired goal and
determine variables needed. Next an examination of what will be replicated and
what properties you can use for each successive stage. Describe your transaction
names to give yourself a direction to take when you start with GC.
DESIGN
During the Design process you will actually construct your basic GC file.
FABRICATION
Creating a Fabrication plan is essential to a working prototype. Use Fabrication
Planning tools in GC to assist you.
TESTING
Testing is a key step in evaluating a working prototype. The aim is to produce a
physical prototype using 3D Printing, Laser Cutting or other methods.
Your GC Workflow
So far you have learned enough to start to create a workflow.
1
114
Jan-10
The next exercise will take our existing work and build on it to create the
beginning of a working prototype. This prototypical roof will respond to in height
to a single vertical line under the roof. Essentially, you will add the surface and
move a tent pole under a tent and take notice of the different surfaces that
tent makes.
Scroll to BSplineSurface in the Feature Type list, expand it, and then
expand the ByPoles update method.
Place the pointer in the Poles expression field, press and hold the Ctrl key,
and then select any line in the Geometric view until the name of the
feature appears in the input field.
For example, {line02[2][3]}.
Jan-10
115
You have selected an individual point but you want the entire 2D array
(or, collection of collections). You need to remove the indexs [2][3] and
add .EndPoint
Click and hold the View Display Mode icon and select Smooth.
116
Jan-10
Fabrication
Click point01.
You now have a responsive surface using only five features; baseCS,
point01, point02, line01, line02, bSplineSurface01.
Optional Exercise:
1
Fabrication
So how would you build such a roof? GC has a FabricationPlanning feature to help
in this process. The FabricationPlanning feature has many Update Methods, you
will learn about the LayoutPolygons method. You will first create points in the
Surface and then you will turn off the display of the B-Spline Surface and use the
points to create polygons.
Jan-10
117
Fabrication
U: Series(0,1,0.2)
V: Series(0,1,0.2)
This Series controls the granularity of the polygon mesh. Later you can
come back and change the series to add more points, for example,
Series(0,1,0.1)
2
Select Toggle Replication Styles and select the point you just created.
Click on Create Feature and select Polygon, with the Update Method
ByPointGrid.
In the Point expression field select Point03 in the Symbolic View and click
OK to create.
If you select point03 in the geometric view then you get an instance of the
point, for example, point03[1][3]. In this case, simply remove (delete) the
instancing, so it should just be point03.
118
Jan-10
Fabrication
To check for planarity of the polygons, select Edit Feature and select a
polygon.
Jan-10
119
Fabrication
Model: UnFoldModel
13 Name this new Coordinate System csUnfold.
120
Jan-10
Module Review
Optional Exercise
1
You can also turn the B-Spline surface to turn it on and use the Update
Method SurfaceDevelopmentPanels.
Module Review
Questions
1
True or False: A B-Spline Surface and a Mesh of polygons are the same
thing.
Answers
Jan-10
121
To call a list (or a list of lists) simply call the feature itself without any
additional syntax. For example, Point01 not {Point01} or Point01[0].
Basic B-Spline surfaces can be built from points, but other methods exist,
for example create the edges of a surface and use the
FromBoundaryCurves update method.
You cannot build a B-Spline surface in real life unless you use a low
stiffness material like the tensile membranes used on the Main Terminal
of Denver International Airport. If you want build out of glass and steel
then you will need to explore the FabricationPlanning feature or later
script your own.
122
Jan-10
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Jan-10
123
Copyright 2009 Bentley Systems, Incorporated
Module Glossary
Module Glossary
Generated feature type
A generated feature type can be compared to a MicroStation cell. A cell is a
complex element, composed of a group of elements, that is stored for repeated
placement. However, a generated feature type can contain a graph variable and
all references to that variable will change when the component changes.
Input
You begin to create a generated feature type by defining inputs. Inputs are what
need to be in place before you can place a generated feature type.
124
Jan-10
The first step is to select the inputs of the new Feature. This is best accomplished
by looking at the symbolic diagram for features that act as inputs. Once you have
elected to create a new Feature, the symbolic diagram turns grey. This is done so
the system can highlight the Feature tree based on the input you select. This
Jan-10
125
helps to visualize the components that are part of the new Feature and which
parts are becoming the inputs.
The outputs are everything that is downstream from the inputs in the symbolic
diagram. It is best to start by selecting the inputs if one knows them as then one
can immediately see whether the selection is sufficient to include all the desired
outputs (where the outputs are the new Feature one is trying to create). The
system automatically selects any input necessary in addition to the selected
inputs based on the associated Features. For instance if a StartPoint for a Line is
selected as the input the Line is automatically becoming an output. But since the
Line also relies on the EndPoint it is selected as a suggested input by the system
as well.
Ideally you want minimum inputs to maximum outputs. This would be the case
when you have a complex model, but only you want to experiment with certain
features at one time.
Nested Features
Features created by users can also form the basis of a new Feature with
previously user-created Features inside. This principle is referred to as nesting
and offers powerful options of structuring complex designs into parametric subcomponents reused at different levels. For instance a wall element can be is
made up of several instances of a glass tile component. Those components can be
assembled to form another building part. Parametric adaptability is preserved at
all levels.
126
Jan-10
Other Options
Jan-10
127
node of the type of the new Feature with the specified name. This is useful to
collapse large symbolic trees into more compact dependency trees. In order to
re-define the Feature upon Feature creation a new transaction step is being
generated that captures the model at its stage just before the replacement.
Rewinding the transaction player back to this point allows the recovery of all the
output elements for re-defining a new version of the user-defined Feature.
If a complicated Feature is being recreated many times over the course of a set of
design iterations, it can become very tedious to refill all the fields and property
names over and over. In this case, you can use the function, which allows you to
use a previously defined user Feature as a starting point to populate all input and
output fields with the settings applied previously and allows you to adjust their
settings for the new version accordingly without having to start from scratch
Open the Pyramid.dgn file containing the transactions that create a foursided pyramid.
Select Utilities > Manage Feature Types > Generate Feature Type or select
the icon from the GC task.
128
Jan-10
In the Input Properties section of the dialog, click Select from Model.
The features are added to the Input Properties section of the dialog.
Jan-10
129
10 In the Output Properties section, enable the Construction check boxes for
If Construction is enabled you wont see that output when you place the
GenerativeComponents. It will exist, it is just not visible.
The Dynamic property allows you to modify the feature on the fly. This
column is enabled by default.
11 Click OK.
12 Save your transaction.
The Replace the current features with an instance of this type option lets you
replace the features that comprise the drawing of the GenerativeComponent
with the actual GenerativeComponent you are creating. Initially it is a good
practice to save a copy of the pre-GenerativeComponent elements. Saving this
way gives you the greatest flexibility later.
Once a user creates a Feature it is placed in the Create Feature list like all other
Features that already exist. Placing a user-generated Feature is accomplished
using the ByDefault Update Method. For a manually created Feature, the
130
Jan-10
Scroll through the Feature Type list to Pyramid_Four and expand it.
Type in a pyramid height, for example 2 or later you can use the variable,
PyramidHeight.
Place the pointer in the point expression field, press and hold the Ctrl key,
and select the 4 points.
Click OK.
You now have a GenerativeComponent in the model.
Select the Transaction File tab, click Record User Changes and replace the
default name with a more meaningful name, if desired.
When sharing a GenerativeComponent you must remember to provide the .cs file
or the GCT that generates the unique feature type (more common procedure). In
Jan-10
131
this case, it is a simple matter of supply the transaction to create the Pyramid and
create the generated feature type.
It is an int value and you cannot change the height using the variable like before.
The Pyramid_Height GraphVariable is part of the GenerativeComponent feature,
but you must now change it by using the Edit Feature tool and adjusting the
height expression. A graph variable belongs only to a particular [symbolic] graph.
Name the variable PyramidHeight (in the Name of New Feature filed).
132
Jan-10
Module Review
10 Remove the value from the PyramidHeight expression field, press the Ctrl
key, and then click the new GraphVariable in the Symbolic view.
11 Click Apply.
You can now use the variable to change the height. That means that if you place
multiple Pyramid_Four GenerativeComponent features in a model and link them
to the graph variable, you can control all their heights at once.
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
1
What is Replication?
Answers
1
Jan-10
Carefully select Inputs based on what you will use as the placement
feature. For example, we would place the pyramid by its base so our input
was a four-sided polygon.
Carefully select the outputs for what will be visible. If a feature is not
needed visually, then set the feature to Construction.
133
134
Jan-10
Law Curves
Module Overview
This module discusses law curves and how to implement them. LawCurves in
combination with a LawCurveFrame, are a means for interactively defining an
array of variables.
Law curves are very flexible. If there is geometry you cannot create with a sketch
or other curves, a law curve often represents the only way to do it. The Law Curve
function gives you many different ways of defining curves or surfaces.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Jan-10
Understand relationships
135
Copyright 2009 Bentley Systems, Incorporated
Law Curves
Module Glossary
Module Glossary
Law Curve
A Law Curve is a feature, which has a level of control over its properties,
represented in a Law Curve Frame or graph. The X and Y values of the graph are
both properties of the Law Curve. When you draw a graph you create an X
direction and a Y direction. The X direction is the independent and the Y direction
is the dependant. X can go where it likes, but Y is dependent on where X is, as its
always perpendicular to it.
Law Curves are always created in the XY Plane and hence are 2D only.
String
When you see the word String, you are being asked to provide your own text. Use
quotation marks to provide your own text space. You can type anything you
want, as long as it is enclosed by the quotation marks.
Plane
Each side of a cube is a different plane. There is the Top (the 2D plane), Front and
Side. Everything you draw is dependant on the plane. If you rotate the plane,
everything on it rotates. A plane, unlike the cube, is actually infinite in size. You
can create a series of planes, with each one representing a floor of a building.
Moving a plane would move everything on that floor with it.
Order
A B-spline curves Order defines the curves distance from the control polygons
poles. The greater the order number, the further the curve can lie from the poles
of its control polygon. The order describes smoothness. The higher the order, the
smoother the curve.
Law Curves
136
Jan-10
Dependent Variable
Dependent Variable is a property of a feature. The Dependent Variable does not
have to be defined by a number or a Series, you can define it by assigning the
property.Variable. In a graph, points on the dependent Y-axis can vary as the Law
Curve position alters. A DependentVariable means that Y points can change but
you don't know what theyll change to.
Here the distance between the points is equal but you can change that by
changing the straight line to a curve.
Jan-10
137
Law Curves
Law Curves
138
Jan-10
Click OK.
Another view window containing the LawCurve coordinate system opens.
This is a separate DGN model.
Law Curves are always created in the XY Plane. You can either create a Plane
ByCartesianCoordinates or you can use the coordinate system you created and
specify the XYPlane property.
Jan-10
139
Law Curves
How many points will you need? A good rule is to have a few more than you tink
you need. For example, if you need to control 10 lines with a law curve use 20
points in both dimensions.
Place the pointer in the Plane expression field, press the Ctrl key, and
select csLawCurve, type a period and select XYPlane.
csLawCurve.XYPlane
Enter the following dimensions, which are the maximum size of the Law
Curve Frame:
XDimension: 20
YDimension: 10
Law Curves
Click OK.
Select Create Feature and select Point with Update Method OnPlane.
140
Jan-10
Plane: csLawCurve.XYPlane
XTranslation: 5
YTranslation: 5
11 Place a third point at:
Plane: csLawCurve.XYPlane
XTranslation: 10
YTranslation: 5
12 Place a fourth point at:
Plane: csLawCurve.XYPlane
XTranslation: 20
YTranslation: 7
13 Select the Transaction File tab, click Record User Changes.
Jan-10
141
Law Curves
An alternate method of placing these points is to Ctrl + left click on the coordinate
system plane and then place the points freely. This lets you skip freeing the points
later.
Scroll to LawCurve in the Feature Type list, expand it and then expand the
ByControlPoints update method.
Place the pointer in the LawCurveFrame expression field, press the Ctrl
key, and then select the Law Curve frame.
Place the pointer in the ControlPoints expression field, press the Ctrl key,
and then select the four points in the frame, point01, point02, point03
and point04.
Law Curves
142
Jan-10
Click OK.
The next step is to create geometry to tie into the Law Curve and then the Law
Curve will control this geometry. You will return to work in the Default model.
Scroll to Point in the Feature Type list, expand it and then expand the
OnPlane. Create two points and use the same for both (these will be
point05 and point06):
Plane: baseCS.XYPlane
XTranslation and YTranslation: anywhere
Select Create Feature and choose Line, ByPoints. Use the last two points
created.
Jan-10
143
Law Curves
IncludeStart: true
IncludeEnd: true
We will now tie a piece of geometry to the Law Curve.
Note how the profile of the circles is the same as the Law Curve itself! This s the
connection from the Law Curve to the geometry. Once again we use a existing
feature to act as the input of a new feature.
Law Curves
144
Jan-10
Before you can test the Law Curve we must free the point in the Law Curve Frame
so you can move them.
Select Edit Feature and click on any one of the points in the Law Curve
Frame.
In the Edit Feature tab, right click on the numerical value for X and select
Free.
Repeat for Y.
In addition, you can Free these points from the Coordinates dialog.
Use the Move Feature tool to move one of the two inside points in the
Law Curve Frame.
Optional Exercises:
1
Suppress the Circle Transaction and try other Features and see if you can
control them with the Law Curve.
For example, Lines or a B-Spline Curve.
Try adding to your circle geometry by covering it with polygons. First use
the Point ByParameterAlongCurve with the T value set to Series(0,1,0.05).
Why is the Series increment set to 0.05?
Second, add a Polygon with Update Method ByPointGrid.
Jan-10
145
Law Curves
Select File > Save As ... and save the file with a new name.
Select Create Feature and choose Graph Variables with Update Method
EvaluateExpression.
Law Curves
146
Jan-10
Module Review
Click Apply.
Click the Variables tab and use the slider to change the X axis value and
note the number of Circles shown.
For even more control, use the Edit Feature and replace the following:
lawCurve01 > Independent Variable to: Series(0,Point_On_Line,1)
point07 > NumberOfEquallySpacedBays to: Point_On_Line
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
Jan-10
What is a String?
What is a Plane?
147
Law Curves
Answers
1
A Law Curve is a Feature, which has a level of control over its properties,
represented in a Law Curve Frame or graph. The X and Y values of the
graph are both properties of the Law Curve. When you draw a graph you
create an X direction and a Y direction. The X direction is the independent
and the Y direction is the dependant. X can go where it likes, but Y is
dependent on where X is, as its always perpendicular to it.
When you see the word String, you are being asked to provide your own
text. Use quotation marks to provide your own text space. You can write
what you want, as long as it is enclosed by the quotation marks.
Everything you draw is dependant on the plane. If you rotate the plane,
everything on it rotates. A plane, unlike the cube, is actually infinite in
size. You can create a series of planes, with each one representing a floor
of a building. Moving a plane would move everything on that floor with it.
Law Curves
Law Curves can be used to establish other relationships such the number
of points on a curve based on its overall length.
The way to connect a Law Curve to geometry is to use the Law Curve as an
input the geometry. By now, this should not be a surprise.
148
Jan-10
GenerativeComponents Import
and Export
Module Overview
You can import GenerativeComponents data to and export it from a database or
Excel using a transaction. Just as you create a transaction to create a feature, you
create a transaction to import or export. In addition, you can import and export
using MicroStation tools, which include most of the popular CAD formats
available.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Jan-10
Export to Excel
149
Module Glossary
Module Glossary
Pre-compiled Assembly File (*.dll)
A DLL, or Dynamic Linked Library, is Microsofts implementation of the shared
library concept. DLLs provide the standard benefits of shared libraries, such as
modularity. Modularity lets you change code and data in a single, self-contained,
DLL. It can then be shared by several applications without any change to the
applications themselves. As with EXEs, DLLs can contain code, data, and
resources, in any combination.
Microsoft Excel
Microsoft Excel is a spreadsheet application. It has calculation and graphing tools,
so you can compute any type of equations and use formulas with data. It uses the
*.xls file as its native format. The *.csv file is the ASCII text format of the *.xls file.
Spreadsheet
A spreadsheet is a rectangular table, or grid, of information. The word came from
spread in its sense of a newspaper that covers two facing pages, extending across
the center fold, treating the two pages as one large page. The compound word
spread-sheet came to mean the format used to present bookkeeping ledgers,
with columns for categories of expenditures across the top, invoices listed down
the left margin, and the amount of each payment in the cell where its row and
column intersect, which were traditionally a spread across facing pages of a
bound ledger or on oversized paper sheets ruled into rows and columns in that
format.
Database
A computer database is a structured collection of records or data that is stored in
a computer system. A database usually contains software so that a person or
program can use it to answer queries or extract desired information. The term
database refers to the collection of related records, and the software is referred
to as the database management system (DBMS). When the context is ambiguous,
however, many database administrators and programmers use the term
150
Jan-10
Excel Import/Export
database to refer to both the data collection and the software that enables it to
be accessed.
Excel Import/Export
Before using the ExcelRange features, you must load the correct library.
Jan-10
Enable the Load Automatically in Future Sessions check box so this .dll can
load automatically when you launch GenerativeComponents.
Click Close.
151
Excel Import/Export
Syntax
A critical aspect of the using this feature is exact syntax, including case sensitivity.
The ExcelRead properties are as follows.
Workbook and File name: Use double quotes and double path separators
unless the Excel file is in the same folder as the .gct, then the path to the Excel
file is not necessary. For example:
C:\\spreadsheets\\my_point_data.xls
Sheet Name: Use double quotes to indicate which sheet within the file is
being read. For example, Sheet1
Range Address: Double quotes are required to indicate the range of cell to be
read into GC. Use standard Excel Range syntax. For example, A1:C4.
The ExcelWrite the properties are the same except the Value field.
152
Jan-10
Excel Import/Export
The first transaction loads the correct .dll. The second loads the .xls file,
sheet and range. The third creates points based on the excel data. The
fourth creates a closed curve and the fifth reports the area of the curve
back to Excel.
Jan-10
In the Excel spreadsheet, make any change you want to the range values
and then, in the GenerativeComponents dialog, unplay and replay all the
transactions to see the dynamic update.
153
Excel Import/Export
Export to Excel
The Export function is similar to the import function, except you need an existing
feature on which to report.
Open excel_write.gct.
The first transaction loads the correct .dll. The second creates point
features. The third creates a B-Spline Curve based on those points as
Poles. The fourth reports point coordinate data to Excel and the fifth
reports curve area data to Excel. The sixth transaction can be used to alter
the point data for testing.
154
Jan-10
Database Import/Export
A good practice in both of these examples is loading the correct .dll as the first
transaction. This is how you ensure that whoever runs the transactions will get
the correct results.
Database Import/Export
GenerativeComponents also includes facilities for accessing data stored in many
types of databases, generally, any kind of database supported by ADO.NET.
GenerativeComponents provides two general techniques for accessing
databases.
The first technique uses the Feature Types, DataImporter and DataExporter. The
second technique uses the GCScript classes, DataConnection and DataTable. The
first technique is generally easier to use, while the second technique is generally
more versatile. In both cases, the underlying implementation is based around
ADO.NET. However, you wont work directly with ADO.NETs classes.
For Access, you can construct DataTables using the standard table design tools in
Access.
Jan-10
The name and type of the columns of the data tables may directly match
properties of the associate Features, or can be mapped to the properties
using an SQL statement.
When importing data from the database, GenerativeComponents regenerates the required Features by automatically finding an update method
that matches the set of properties from the DataTable. This facility is not
limited to Features delivered with GenerativeComponents, but also applies to
a User Generated Feature, which, of course, was previously unknown to
GenerativeComponents at the start of an interactive session.
155
Image Capture
If the DataTable is constructed with a unique key, then you can interactively
edit the dataTable from within GenerativeComponents.
Image Capture
Besides the MicroStation methods for image capture (Utilities > Image >
Capture), there is another method of capturing an image from a view. The
Feature is called ImageCapture. This feature allows the capture of a sequence of
images of a specified window, dependant on the Update of a specified object.
Inputs
StartFrame (optional) default value is 0 is the frame number for first image
capture.
Driver object (optional) will specify the driver for image capture. Modification
of the driver object triggers image capture. The default value is null.
156
Jan-10
Module Review
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
1
Answers
1
ExcelRange.
Jan-10
157
158
Jan-10
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Module Glossary
Building Envelope
The building envelope is a critical component of any facility since it both protects
the building occupants and plays a major role in regulating the indoor
environment. Consisting of the building's roof, walls, windows, and doors, the
envelope controls the flow of energy between the interior and exterior of the
building. The building envelope can be considered the pathway for a building to
Jan-10
159
Copyright 2009 Bentley Systems, Incorporated
work with the climate, by responding to heating, cooling, ventilating, and natural
lighting needs.
Array
An array is a group of individual items.
A one-dimensional array looks like a simple linear list: {value1, value2, value3}.
A two dimensional array is a Matrix or Grid: {value1, value2, value3},{value4,
value5, value6}.
When a feature requires an input of an array, it is indicated by [].
When a feature requires an input of a single value, or an array, it is indicated by
([]).
These two approaches can also be combined []([]), meaning that the property
expects an array of points, but optionally can be given an array of an array of
points.
Transpose
Transpose is to: swap/reverse/switch/invert/reorder/rearrange/change. In
simple terms it swaps the rows and columns of a two dimensional array.
For example array {{A,B},{C,D}} becomes {{A,C},{B,D}}.
160
Jan-10
Jan-10
Click Create Feature and create a Graph Variable with Update Method of
EvaluateExpression. Name it Height with a minimum of 5, maximum of
100, and step size of 5, and make Limit Value to Range, true.
Place four, or more (go ahead, have some fun), XY planar points as the
building base.
Draw the height lines for the building using the Line Feature, with the
Update Method ByStartPointDirectionLength. Use the baseCS.Zdirection
for the Direction of the lines and the GraphVariable Height as the length.
161
Click the Create Copy button and change the point number to the next
point number (point01 to point02), keeping the other properties the
same.
Next you want to create Planes, one for each of the floors.
6
162
Jan-10
YTranslation: 0
ZTranslation: Series(0,Height,5)
The GraphVariable Height is now controlling the height of the lines and
the number of planes.
7
Jan-10
163
Click the Create Copy button, change the line number to the next line
number, and then click Apply.
164
Jan-10
11 Examine (use Move Feature and put your cursor over one) the points on
the lines so far. They are arranged so that the instance increments on
each line. Points 5-8 instances rise in the Z direction.
If you drew this in a two dimensional array, or matrix, it would appear as
the following:
Point05
Point06
Point07
Point08
Point005[0]
Point006[0]
Point007[0]
Point008[0]
Point005[1]
Point006[1]
Point007[1]
Point008[1]
Point005[2]
Point006[2]
Point007[2]
Point008[2]
12 For all the floors you want to create a polygon from the vertices
This only results in one floor. You can repeat the polygon, or use a built in
function to fix the data.
First you will remove the index information, the [1], from each point and
create a matrix of points. Then Transpose the matrix index of all points.
The matrix is read from left to right. This means that even though you
place the correct collection of points, it wants to create the shape up the Z
axis through Point05[0], Point05[1], Point005[2], Point05[3] instead. As a
result, you don't see the polygon you want.
You need to use the Transpose function. Transpose will change the Matrix
so that the rows are columns, and the columns are rows. Now when you
read the matrix from left to right, you get the points that match the
collection.
Remember, when you write the collection you take off the [i] instance
number to indicate that you want polygons on all the points, not just the
defined ones.
Note: The () round brackets are used to define functions like Transpose. The {}
following:
Jan-10
165
Transpose({point05,point06,point07,point08})
166
Jan-10
Now that you have the polygons, you want to be able to create text for the area
calculations. First, create a new Coordinate System for the text.
Jan-10
167
Bool = false. This makes the text flat on the XY plane. True would make the
text vertical on the XZ plane.
6
Now you need to put the area into an Excel file. Please note that you need
Microsoft Office 2003.
Open Excel and create C:\Floor_area.xls, save it, and exit Excel.
In GC, use the Feature ExcelRange, with the Update Method WriteValue.
Use sheet name Sheet1 (no spaces) and cells A1 through A20 and range
address.
Add the following to the end of the transaction file, by clicking on the
Edit this Transaction file icon.
168
Jan-10
{
feature walls01 GC.Polygon
{
Function = function (point08,point07)
{
for (int j = 0; j < point08.Count -1; ++j)
{
Polygon poly = new Polygon(this);
poly.ByVertices({point08[j], point08[j+1], point07[j+1], point07[j]}, false,
true, 0, null, null);
}
};
FunctionArguments = {point08, point07};
}
}
Jan-10
169
How would you add the walls for the other faces?
How else could you have added the walls? Hint: How did we skin other
objects?
Once the basic schema is done, changing it with other options is quick and
easy. For example, replace the first four points (the base) with four points
on a circle. Replace the vertical lines with variable radius arcs, i.e. radius
changes as Height changes.
Adding Text that is tied to a variable is very helpful for quick reporting.
170
Jan-10
GenerativeComponents and
Other Formats
Module Overview
This module looks at MicroStation models and references, and explores working
with them in GenerativeComponents. MicroStation is the graphics engine for
GenerativeComponents, and the basis for all the features types available.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Models
When you create elements in a design file, or DGN, you are creating a model. A
model is stored as a discrete object within a DGN file. Each DGN file, therefore,
contains one or more models. It may be helpful to think of a DGN file as a box that
Jan-10
171
References
can contain both 3D and 2D drawings, or models, any of which you can view
individually.
Models are very similar to Sheets in Excel. Each Sheet in Excel can hold different
data that is separate from another Sheet, yet they can both be in the same file.
You saw how handy multiple models are with Law Curves.
Models are also useful when printing or plotting sheets.
Hint: You have access to thousands of MicroStation tools while using
References
References can also be attached to a design file and used as a guide for drawing
construction. Although you cannot modify reference elements, you can snap to
them, measure them, and even copy all or part of a reference into the active
design file. Remember the essence of a reference file is look [and plot] but do
not touch/edit.
You have two ways of referencing in GenerativeComponents, the traditional
MicroStation way, which is convenient for one time look at other files or the
GenerativeComponents way in which the referencing action is a Feature Type.
172
Jan-10
References
Click the References tool in the Primary Tools tool box at the edge of the
application window.
You can also select File > MicroStation Reference File Dialog in the
GenerativeComponents dialog.
2
Orientation options set the view of the model that you will see. Coincident, the
default, aligns the references with regard to design plane coordinates only.
Coincident World aligns the references with the active model with regard to both
Global Origin and design plane coordinates. You can also select to attach any
standard view, saved view or name fence that is in the selected model.
Jan-10
173
References
Toggles define settings for the reference. The first one is Display. If on, the
reference is displayed. Second is Snap. If on, you can snap to elements in the
selected reference. Next is Locate. If on, you can select elements in a reference
for construction purposes. Enable Treat Attachment as Element for Manipulation
so you can manipulate references, as a whole, with the standard MicroStation
manipulation tools. True Scale uses units in the active model and those in the
referenced model to calculate an appropriate scaling factor so that the reference
scale reflects a true real-world scale.
Scale (Master:Ref) sets the ratio of the master units in the active model to the
master units in the attached model. Use this if the reference elements need to be
scaled. For example, 2 to 1 would make the referenced elements twice as large as
elements in the master.
The primary reason to do this is to reference other non-GC graphics for context.
Click OK.
You have attached a model to your work file for reference purposes.
DesignFileToAttach: This is the file path to dgn as a string. Use the green fx
button and Files tab to navigate to browse file location and then insert.
174
Jan-10
References
Hint: There is also a RasterAttachment Feature type to attach files such as .jpg
and .tif.
Jan-10
175
Using Range
A Range is a cubic volume delineating part of model space and can be used in
conjunction with ModelAttachment and many other feature types.
This is a very handy Feature Type as it allows you to capture part of a model for
use [usually] as an attachment to another model. Though there are many other
uses for Range once you have created it. The process is as follows.
1. Create a Range - The most common update method is
ByLowHighRangePoints.
2. Use the Range - Use the Range feature type and the update method
SelectFeaturesWithinRange.
Sets the active level, color, line style and line weight
176
Jan-10
Three point features are added to both views and the circle is promoted
to circle01, a Line ByPoints.
4
If the element is eligible to be more than one type of feature, or the update
method is not definite, the Select Feature Type and Update Method dialog
appears so you can define these.
This workflow applies to DWG elements as well.
Jan-10
177
Import IGES
IGES is a public domain, neutral file format that serves as an international
standard for the exchange of data between different CAD/CAM systems. The
fundamental unit of data in an IGES file is the entity. There are 2 major categories
of entities. Geometry entities define physical shapes, such as points, curves,
surfaces, solids, and relations, which are collections of similarly structured
entities. Non-geometry entities provide specific attributes or characteristics for
geometry entities. Non-geometry entities include view, drawing, general note,
dimension, property, and associativity entities.
Select File > MicroStation Import From > IGES in the GenerativeComponents
dialog to import .igs files.
Save As V8 Options
Remapping
Options on the Remap tab control how element parameters such as levels,
symbology, fonts, or cell names are remapped to different values when the file is
saved to a V8 file. For example, you can remap elements on level 24 of the active
file to level Annotation in the V8 file. Remapping is useful when you need to
convert standards to comply with organizational requirements.
To remap element parameters, you use a remapping table. This table is saved in a
CSV (comma separated value) file that is created by a macro embedded in a
spreadsheet program.
The Remap tab of the Save As V8 Options dialog box lets you create and edit the
remapping table through the Microsoft Excel spreadsheet program. You can also
control which sections of the remapping table to use when the file is saved.
178
Jan-10
References
The References tab contains controls that determine how references are handled
when you save a file as a V8 file. This is dependent on the Geometry setting in the
Filter tab.
If set to Selection Set, or Fence, only the Allow Optimized Clip For Reference
Merge setting is enabled. All other settings are disabled with the result that
all selected geometry, or fence contents, will be merged and references
discarded in the saved file.
You can choose to keep references as attachments, combine a file and its
references into a single output file, or omit the reference attachments from the
output file.
Filtering
The Filter tab contains controls that are used to filter the data that is saved to the
output file. Options let you select the file geometry you want to include, letting
you filter by fence or selection set. You can also select specific models to save.
Jan-10
179
You can choose to save or eliminate saved views, shared cells, named groups,
frozen levels and tags.
180
Jan-10
References
Options here control how references are handled when you save a DGN file to a
DWG or DXF file. The DWG file format does not support all the reference
attachments possible in MicroStation.
Options here are similar to those when saving as V8 DGN. There are additional
options for Non-Default Models Attachments, as AutoCAD is limited to one
default model per file with one or more sheets. The Masked Attachments option
controls how clipping masks in attachments are handled.
Exporting to IGES
You can also export to IGES using similar operations.
By default, the file name is the design file name with the extension .igs. A
different directory and file name can be specified by choosing Export As from the
File menu in the Export IGES File dialog.
The Start Section File fields are used to input information that is included in the
IGES file's start section; the Author, Organization, and Product Name.
The status area displays progress messages during the conversion. These are also
saved in the log file.
Jan-10
181
The STL format is poular as an input to many 3D Printers. Using the Export STL
command allows you to prepare your 3D model for 3D printing.
Select the objects to export. You can draw a window around them.
A Save As ... dialog opens. Name your file and choose the folder location.
ExportFeatureAsElementsToAnotherDesginFile
ExportFeatureAsElementsToAnotherModelWithinActiveDesignFile
182
Jan-10
Module Review
Module Review
Now that you have completed this module, lets measure what you have learned.
Questions
1
What is a model?
What is a reference?
When attaching references, what does the Scale (Master:Ref) option do?
Answers
1
A DGN file component that contain elements. A DGN file can contain
many individual models.
A model attached to, and displayed with, the active model for printing or
construction purposes. A reference cannot be modified. You can attach,
as a reference, a model that resides in either the open DGN file or some
other DGN file.
It sets the ratio of the master units in the active model to the master units
in the attached model. Use this if the reference elements need to be
scaled.
Jan-10
Promoting elements from existing CAD drawings can be a good way to get
started for certain workflows.
183
184
Jan-10
Using Patterns
Module Overview
This module is loosely based on the excellent work of Rob Woodbury at the
Simon Fraser University in Canada. You will examine concepts regarding applying
patterns to learn parametric software.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Design Patterns
The idea of Design Patterns is to use a pattern to control parametrics.
A pattern in this context is a type of theme of recurring events of or objects,
sometimes referred to as elements of a set. These elements repeat in a
predictable manner.
The following is taken with permission from Rob Woodbury.
Jan-10
185
Copyright 2009 Bentley Systems, Incorporated
Using Patterns
Using Patterns
186
Jan-10
Select Create Point and place four points for a B-Spline Curve.
Jan-10
187
Using Patterns
Name: curvePoint
After typing in the 0.5 tab out of the field, right click on T property, and
select Free.
Next you will define a direction that is usable by both the controller and
the geometry to control.
5
Using Patterns
188
Jan-10
Length: 2
Select Create Point and place two points for a controller line. Name the
two points: cPoint01 and cPoint02.
Select Create Feature and choose Line with Update Method ByPoints and
use the following:
StartPoint: cPoint01
EndPoint: cPoint02
Name: cLine01
Jan-10
189
Using Patterns
Curve: cLine01
T: 0.5
Name: cPoint03
After typing in the 0.5 tab out of the field, right click on T property and
select Free.
Finally, you can connect the point on the controller to the point on the
curve.
10 Select Edit Feature and click on curvePoint and change the following:
T: cPoint03.T
Using Patterns
190
Jan-10
References
12 Test the Controller by moving the point on the controller line (cPoint03).
References
Rob Woodbury has produced many other useful GC based pattern tools. Please
review:
http://www.designpatterns.ca
Also, look for the upcoming book on Design Patterns from Rob at the Bentley
Institute Press.
For further generic reading on this topic please review:
Jan-10
191
Using Patterns
Using Patterns
Visit http://www.designpatterns.ca
192
Jan-10
Advanced Topics
Module Overview
There are many advanced topics in GenerativeComponents. You will examine two
specific advanced topics in this module. The first is working with BIM applications
from Bentley such as Bentley Architecture, Bentley Structural, and Bentley
Building Mechanical Systems. In addition, you will look at solid modeling
techniques unique to GenerativeComponents.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
BIM Objects
BIM features for GenerativeComponents is an add-in which introduces Walls,
Structural members, Doors and Windows. It also re-introduces Drawing
Jan-10
193
Copyright 2009 Bentley Systems, Incorporated
Advanced Topics
BIM Objects
Overview
Bentley Architecture
Bentley Structural
The concept of BIM Objects relies on the installation of Bentley Architecture. You
can out more about Bentley Architecture at:
http://www.bentley.com/en-US/Products/Bentley+Architecture/
BIM Features for GenerativeComponents 08.11.07.xx are:
One model One source
Use your conceptual model directly, for further detailing without any loss of data.
Advanced Topics
194
Jan-10
BIM Objects
GenerativeComponents Integration
Fully integrated in the GC feature tree. Acts like a normal GC feature. One session
with GC running together with a Building application like Bentley Architecture
BIM Integration
Elements created are compatible with Building products like Bentley Architecture
or Bentley Structural and can be used and edited in the target application. No
translation or conversion is needed.
Jan-10
195
Advanced Topics
Namespace concept
GC's concept of Namespaces is incorporated to allow advanced users to classify
feature instances and generated feature types. New features will show up as
(Bentley.Building.Wall, Bentley.Building.Beam, etc)
Native language
Completely rewritten in C# to match GC's native language.
MicroStation08.11.07.171
GenerativeComponents08.11.07.66
Bentley Architecture08.11.07.69
For now you can get BIM Features, since this software is in Beta, as a Select
Download.
Drawing Extraction
There are two ways of getting your production drawings from your GC and BIM
model. The first is to use Dynamic VIews from MicroStation. Dynamic VIews
Advanced Topics
196
Jan-10
allows you to dynamically move a section plane or detail area through a 3D model
to see and produce production drawings. This method relies on a deeper
understanding of MicroStation.
The second way is to use the DrawingExtraction feature type.
Jan-10
197
Advanced Topics
Solid modeling tools are available from the Feature Type Solid. In addition, you
can promote solids created in MicroStation.
Cone
Protrusion
Slab
Sphere
Torus
BetweenSurfaces
OffsetFromClosedCurve
ThinShell - Shell out the interior of a solid leaving a thin outer solid.
TrimWithSurface
BooleanOperation
Advanced Topics
198
Jan-10
Scripting Basics
Module Overview
This module presents the basics of the GCScript language and tools. GCScript is a
C style programming language, like C, C++, Java, and C#, that is optimized to work
with Bentley GenerativeComponents.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Jan-10
Use basic functionality of The Script Editor and Script Expression Builder
199
Copyright 2009 Bentley Systems, Incorporated
Scripting Basics
Module Glossary
Module Glossary
C# (sharp)
C# is an object-oriented programming language developed by Microsoft as part
of the .NET initiative and later approved as a standard by ECMA and ISO. The C#
language has a procedural, object-oriented syntax based on C++ and includes
aspects of several other programming languages (most notably Delphi and Java)
with a particular emphasis on simplification.
Temporary Feature
Temporary Features can be created in scripting. They are created only locally in a
function for as long as the function is running and afterwards erased. Temporary
are often used in scripts to create intermediary Points for instance to construct
something else from. They do no appear in the Symbolic view either, but can still
be full fledged GenerativeComponent Features.
Child Feature
Replication of a point is an example of a child feature.
Reflection
The process by which a program can read its own metadata. A program is said to
reflect on itself, extracting metadata from its assembly and using that metadata
either to inform you or to modify its own behavior. Figuratively speaking, it is
then said that the program has the ability to observe and possibly to modify its
own structure and behavior.
Scripting Basics
200
Jan-10
Module Glossary
Objects
Objects are key to understanding object-oriented technology. Look around right
now and you'll find many examples of real-world objects: your dog, your desk,
your television set, your bicycle.
Real-world objects share two characteristics: They all have state and behavior.
Dogs have state (name, color, breed, hungry) and behavior (barking, fetching,
wagging tail). Bicycles also have state (current gear, current pedal cadence,
current speed) and behavior (changing gear, changing pedal cadence, applying
brakes). Identifying the state and behavior for real-world objects is a great way to
begin thinking in terms of object-oriented programming.
You will notice that real-world objects vary in complexity; your desktop lamp may
have only two possible states (on and off) and two possible behaviors (turn on,
turn off), but your desktop radio might have additional states (on, off, current
volume, current station) and behavior (turn on, turn off, increase volume,
decrease volume, seek, scan, and tune). You may also notice that some objects, in
turn, will also contain other objects. These real-world observations all translate
into the world of object-oriented programming.
Software objects are conceptually similar to real-world objects: they too consist
of state and related behavior. An object stores its state in variables and exposes
its behavior through functions. Functions operate on an object's internal state
and serve as the primary mechanism for object-to-object communication. Hiding
internal state and requiring all interaction to be performed through an object's
functions is known as data encapsulation a fundamental principle of objectoriented programming.
Function
A function represents an independent block of GCScript statements. In computer
science, a function, sub-routine, method, procedure, or sub-program) is a portion
of code within a larger program, which performs a specific task and can be
relatively independent of the remaining code. The syntax of many programming
languages includes support for creating self contained functions, and for calling
and returning from them. A function has inputs (of type: int, double, etc) and
output of type.
Jan-10
201
Scripting Basics
Module Glossary
Class
In object-oriented programming, a class is a construct that is used as a blueprint
to create objects. This blueprint includes attributes and methods that the created
objects all share.
Usually, a class represents a person, place, or thing. It is an abstraction of a
concept within a computer program. Fundamentally, it encapsulates the state
and behavior of that which it conceptually represents. It encapsulates state
through data placeholders called member variables; it encapsulates behavior
through reusable code called methods.
Enum
Enum provides methods to compare instances of this class, convert the value of
an instance to its string representation, convert the string representation of a
number to an instance of this class, and create an instance of a specified
enumeration and value.
Namespace
A namespace is an abstract container or environment created to hold a logical
grouping of unique identifiers or symbols (i.e., names). An identifier defined in a
namespace is associated with that namespace. The same identifier can be
independently defined in multiple namespaces. That is, the meaning associated
with an identifier defined in one namespace may or may not have the same
meaning as the same identifier defined in another namespace.
For example, if you install the BIM add-on you will it uses Namespaces, seen as:
Scripting Basics
202
Jan-10
Building.Beam
Building.Door
Building.Wall
You can create Namespaces to help categorize and sort out different useddefined features (generated feature types). Some examples might be:
myCompany.utilities.triangulate
myCompany.components.crossbar
Structure.Steel.Ibeam
Feature Properties
Whenever you fill in the value of a property, that value is a GCScript expression,
which can be as simple or as complex as you like.
Jan-10
203
Scripting Basics
Scripting Basics
204
Jan-10
Jan-10
205
Scripting Basics
Scripting Basics
206
Jan-10
You type text into the entry field, which is across the bottom of the page. You can
type any GCScript expression or statement, then press the Enter key.
You can scroll to review your previous entries using arrow keys. You may
optionally edit any of your previous entries, and re-issue them by highlighting and
pressing the Enter key.
Alternately, you can click the drop-down button (to the right of the entry field) to
see and/or select any of your previous entries.
Finally, you can click the Clear Log button to clear the log display.
Single Lines Only, Please
The script console handles only expressions and statements that fit into single
entries. It cannot handle larger passages of code, such as a multi-line function
definition. Try the following.
Jan-10
207
Scripting Basics
Type the following text into the data entry field of the Console window:
2+3
You will see the result in the output (log) portion of the page:
* 2+3
5 (the result)
4
Scripting Basics
208
Jan-10
Calling functions
Functions provide a very good way organizing code into modules that do specific
tasks. Calling functions allows a user to easily utilise this encapsulated
functionality. Writing code in functions makes code more reusable. The same
function can be called repeatedly again and again.
In GenerativeComponents it is possible to distinguish between three functions:
Anonymous functions
Functions which are global in scope can be called anywhere within a transaction
file. Functions which are local in scope are callable only locally within the scope of
the function. GC has a number of built-in global functions such as Abs(), Cos(),
MembersAt(), Series().
Functions can be called in one of two ways. The usual way is by calling the
function directly by name followed by a list of the arguments:
functionName(functionArguments);
A second way is normally only used in very particular circumstances uses the GC
script function CallFunction:
CallFunction(string functionName, functionArguments )
When calling a function the arguments must be listed in the same order as they
are defined in the function. The values must also be of the same type as specified
by the function arguments.
The built-in global function SeriesByCount accepts three arguments all of which
must be numbers and returns a single array of numbers.
transaction script "New script transaction"
{
double list = SeriesByCount(0, 10, 2.5);
//list has the value {0.0, 2.5, 5.0, 7.5, 10.0}
}
In the example below, the built-in global function Abs is called. This accepts a
number as an input and returns a number.
transaction script "New script transaction"
Jan-10
209
Scripting Basics
{
double theta = -53.2;
double result
= Abs(theta);
Local Functions
Another way to create a function in GenerativeComponents is by using the
statement builder and selecting function. Local functions are limited in scope to
the file that you define them in.
This gives the basic construction.
function (arguments)
{
}
Functions, like variables must be defined above the place where they are called in
the code otherwise the compiler will throw an error.
Scripting Basics
210
Jan-10
Arguments
The Arguments (essentialy inputs) for a function are listed in parenthesis to the
right of the function name. The type of each argument is normally written before
each value. In the example below the function type is double, the function name
is multiply and the arguments are two doubles number1 and number2.
double multiply(double number1, double number2)
{
return number1*number2;
}
GenerativeComponents does not require that the type is given for any argument.
Specifying the nature of the any input argument does however restrict the input
which is often advantageous. If any of the arguments are arrays, etc, the rank can
be indicated using the appropriate number of sets of opening and closing square
brackets after the Type.
Inputs are generally given specific names within the function, to distinguish them
from variables outside of the function. This gives the user the opportunity to
clarify, by appropriate naming, their role within the function.
Return Value
The return statement is used to indicate what is returned from the function. The
type of the return value must be the same as the type of the function. Only one
value can be returned from a function, although this can be an array or a multiple
array of values.
There are other ways to passing more than one value out of a function such as
using ref or out values as function arguments.
It is possible to create functions which do not return any values; these are known
as void functions.
transaction script "New script transaction"
{
void showValues(int x, int y)
{
ShowMessageBox("The values selected are " + x + " and " + y +
".");
}
Jan-10
211
Scripting Basics
int x = 2, y = 4;
showValues(x, y);
}
The following exercise will allow you to draw a point with a function. You will
need to use unique names for your arguements and variables. In other words,
you cannot use the same name for two different variables.
Expand the ByFunction Update Method and click n the blue icon for the
Script Editor.
In the Script Editot click on the Statement Builder icon and select function.
You can also right-clcik in the text window and select Statement Builder.
Scripting Basics
212
Jan-10
CoordinateSystem
myCS
the open curly brace indicates the beginning of the actual function contents.
myPoint
the equals sign says: Take the value on the right of the equal sign and put it into
the variable on the left, after processing this line of code.
=
the word new is reserved for GCScript, so you cannot use it to name a
variable. That is why the text is blue. New indicates a new feature is being
created. Another way to say it is: new instantiates (creates an instance) the
memory for this object.
new
Jan-10
213
Scripting Basics
Point() this tells what new thing to create. Note the (), indcating that this is
the Point function and it will return a point to the screen (if asked too).
tells the computer that the line has ended, and that it can start the next one.
Almost all statements will have this at the end.
myPoint.ByCartesianCoordinates(myCS, 3, 5, 0);
myPoint. is your variable of type Point. Typing in the dot provides you with a list
of possible options.
ByCartesianCoordinates
(myCS, 3, 5, 0)
;
return myPoint;
the keyword return is a function which puts the point on the screen for
you to see. Here you are returning the type Point.
return
myPoint
end of function.
Scripting Basics
214
Jan-10
This is the basic structure that you will use to create and show features.
Lets enhance what has been written by adding a set. You will split the singular
point into several points by giving it a {list} for its X translations.
The only difference here is that we define a variable of the type double, then fill
it up with a list and use the variable instead of the list itself.
Both of these variations will produce exactly the same outcome, three points will
appear when you click Apply.
Optional values
Arguments can be optional. In the following example the built-in GC script global
function Round takes an option second argument which sets the precision In the
example below, uses the built-in global function Round and the global variable PI.
When the precision is not given the value is rounded to a whole number. This
function will use a rounded value for Pi called pie.
transaction script "New script transaction"
{
Jan-10
215
Scripting Basics
This creates a new global function that is just like the built-in functions. It is not
associated with the current graph, and therefore, it persists through the entire
session, regardless of opening/creating of new/existing files.
The user can also create global variables.
global double Tolerance = 0.01;
Like global functions, global variables persist through the entire session.
Anonymous Functions
Every function is a kind of object, which can be assigned to a variable, passed as
an argument to a method call, or returned as the result of another function.
Furthermore, like a number or a string, a new function can appear spontaneously
within an expression or statement, without needing an associated name. These
ad hoc functions are called anonymous functions.
To create an anonymous function, use the keyword function instead of a name.
Also, its conventional to omit the types of the return value and the arguments,
but you can include those types if you prefer.
For example,
double Plus(int x, int y) { return x + y; }
// A named function that, when called, will add two numbers.
function(x, y) { return x+ y; }
// An anonymous function that, when called, will add two numbers.
Scripting Basics
216
Jan-10
//
You might be interested to know that, from the standpoint of the GCScript
compiler, the following two statements are identical:
int Plus(int x, int y) { return x + y; }
int function(int x, int y) Plus = int function(int x, int y) { return x +
y; }
Script Transactions
In a transaction file, a script transaction lets you enter any number of arbitrary
GCScript statements, which are executed in sequence when that transaction is
performed.
Jan-10
217
Scripting Basics
Script Files
A script file is a text file designed to contain a complete GCScript program. You
can run the program, manually, whenever you wish, or you may run it
automatically within any other GCScript code.
Using the Script Console to learn and experiment with GCScript
As you read the rest of this manual, please feel free to use the script console as a
way to learn and experiment with the GCScript language.
Syntax
Keywords
Types
Variables
Block comment
A block comment begins with the symbol /* (a slash followed by an asterisk) and
continues through the symbol */ (an asterisk followed by a slash).
Spaces
Generally, the GCScript language processor ignores spaces and line breaks that
occur between adjacent symbols. You should use as much or as little spacing as
you wish, to make your script code readable to yourself and others.
Scripting Basics
218
Jan-10
From GCScripts point of view, the following examples are identical. Which is best
depends on your programming style.
(temperature32)/1.8
(temperature 32) / 1.8
Names
The names of variables and other symbolic values follow the standard
convention: A letter or an underscore character, followed by any number of
letters, digits, and/or underscore characters.
Correct syntax
count
Point01
k
TOTAL_HEIGHT
Incorrect Syntax
Examples of syntactically incorrect names. The reason why they are incorrect
follows the example:
3pointcounter (starts with a digit).
pointsandcircles (includes illegal characters).
Names are case-sensitive, for example, lineLength and LineLength are two
different names.
Jan-10
219
Scripting Basics
Keywords
A keyword is a name that has a special meaning within the language, and
therefore cannot be used as the name of a variable or other symbol. Following is
a complete list of GCScript keywords.
as
enum
namespace
this
break
false
new
true
breakpoint
for
null
typeof
case
foreach
optional
using
class
function
out
void
const
global
params
while
continue
goto
ref
default
if
replicatable
do
in
return
else
is
switch
Fundamental Types
The following types are built-in to the GCScript language processor.
bool
A bool value represents either true or false.
char
A char value represents a single text character. You specify a char value by
enclosing it within apostrophe characters. For example,
'm'
'4'
'?'
To specify an apostrophe character, itself, preface it with a backslash within the
outer apostrophes. For example,
Scripting Basics
220
Jan-10
\
To specify a backslash character, itself, preface it with another backslash within
the apostrophes. For example,
'\\'
datetime
A datetime value represents a point in time ranging from year 0001 A.D. through
year 9999 A.D., precise to the millisecond (thousandth of a second).
new datetime(year, month, day, hour, minute, second, millisecond)
Any of the items may be omitted from the end of the list; those items are treated
as zero.
For example:
new datetime(2007,2,12)
double
A double value represents a floating-point (real) number ranging from -10E08
through +10E08, with approximately 14 digits of precision.
Double values are distinguished from integer values by the presence of a decimal
point.
Jan-10
221
Scripting Basics
function
A function value represents an independent block of GCScript statements. This is
covered in more depth in a later section. For example:
function(x, y) { return x + y; }
int
An int value represents an integer ranging from -2,147,483,648 through
+2,147,483,647.
long
A long value represents an integer ranging from -9,223,372,036,854,775,808
through +9,223,372,036,854,775,807.
Unless you have specific reason to use the long type, you should instead use the
int type, which operates much faster.
object
The object type is a universal type: Any item of any type can be automatically
converted to and from an object type.
Another way of saying this is: Every value is an object, in additional to whatever
other type it is.
There are no specific examples of object types, because all of the examples
herein can be examples of object types!
string
A string value represents a sequence of text characters, treated as a single unit.
To specify a string, enclose the text characters within quotation characters. It
doesnt matter whether the text would otherwise be interpreted as a value of
another type. For Example:
bebo ergo sum
Scripting Basics
222
Jan-10
12.34
// an empty string
To include a backslash character, itself, within a string, preface it with another
backslash. For example:
C:\\My Files\\Survey Data.xls
timespan
A timespan value represents a length of elapsed time, measured as days + hours +
minutes + seconds + milliseconds (thousandths of a second).
new timespan(days, hours, minutes, seconds, milliseconds)
Each item in the list is an integer. Any of the items may be omitted from the end
of the list; those items are treated as zero.
type
A type value represents a data type, itself.
typeof(type)
Examples:
typeof(int)
typeof(timespan)
Variables
A variable is a storage area that can hold a value, and it is labeled with a name.
The stored value can be retrieved simply by using the variables name.
You can store as many values as you want into a variable, but only one value at a
time. Each new value replaces the previous value.
Declaring Variables
Before you can use a variable for the first time, you must declare it. This means
telling GCScript the name of the new variable, and the type of values you expect
to store into it. For example:
Jan-10
223
Scripting Basics
int poleCount
string levelName
bool isImageInverted
As a convenience, you can define multiple variables of the same type with one
statement.
double minorRadius, majorRadius, angle, chordLength
Each variable may contain only a value of the type that you specified in its
declaration. For example, a variable of type int can contain any of the values 5,
1094, or -13, but not the string value one dozen.
Sometimes, you dont know precisely what types of values will be stored into a
variable, or you want to be able to store different types at different times. In that
case, you can use the generic type, object. An object-type variable can hold any
value of any type because every value is an object, in addition to whatever other
type it is.
object resultOfOperation // Could be a number or perhaps an error message.
Scripting Basics
224
Jan-10
Variable Operators
Variable operators provide a convenient way to modify a variables value based
on its current value.
For example, instead of saying
accountBalance = accountBalance + deposit
you can say
accountBalance += deposit
which has the same effect.
Jan-10
225
Scripting Basics
Scripting Basics
226
Jan-10
XValue
is saying equal to an empty list. Implying you will add more than one
number here.
= {}
declares a variable, i, for use within the loop. This variable is our
counter and is set to start at 0.
int i = 0;
sets the condition, for a value of i of less than ten then continue into the
loop, if the value for i is 10 or greater then exit the loop now (without going
through the loop).
i < 10;
i++
)
{
XValue[i] = i; //the number at position i in the list is i
}
{
XValue[i]
= i
Jan-10
says the indexed value is equal to the index number. For example,
227
Scripting Basics
You will be creating a point feature using the Feature Type list, but rather than
using one of the model based methods to define it, you will use a function.
Scripting Basics
Click in the Function expression field and click the script editor icon to
open a script editor where you will create the function.
228
Jan-10
You see a list of script statement templates that make it easier to create
standard scripting expressions. You will use it to create a transaction
wrapper.
4
The brackets {} denote the beginning and the end of the function body.
Inside the parenthese, the word arguments is the placeholder for any
input arguments you may define for the function. You define the input
arguments by replacing the placeholder with your own inputs for this
specific function.
Jan-10
229
Scripting Basics
CoordinateSystem cs
Next you need to define a variable of Type Point to hold the Point feature
inside the function.
6
You want the Point in the function to become a parent of the Point
feature you are creating using the ByFunction update method.
The reason for creating the Point as a child to the top level Point in the
function is so you can refer to it using the same name as its parent. This is
useful if you make a list of points later.
Scripting Basics
230
Jan-10
11 Click Close.
Although you initialized the Point, pt01, it still is not created. To do so you need to
select an update method from the list for Points. You will use
ByCartesianCoordinates.
You will use the variable pt01 that refers to the new Point object to call the
update method using the dot operator. Once you type pt01, a list of available
update methods will display.
Jan-10
231
Scripting Basics
You must insert the input arguments with values, or variables, that are
valid to the function.
4
[, Origin} is an optional value which you will not use for now, so
remove it
Type a semi-colon.
The function appears as follows.
Now that the function is complete, you need to pass it one input argument, since
you defined an input argument of Type CoordinateSystem.
Click OK.
This passes the argument to the function through the cs variable you
defined as the ByCartesianCoordinates update method, and that creates
Scripting Basics
232
Jan-10
the Point at x=3, y=1, and z=0. The Point appears in red, as a child feature
of the top level Point point01 that hosts the function.
Click Save.
Jan-10
233
Scripting Basics
Select the Edit Feature tab and click on the Script Editor icon in the
Function expression field.
Place the pointer into a new line after the opening bracket of the function,
right click and select Statement Builder.
Note: To indent a section, highlight the lines and click the Increase Line Indent
Scripting Basics
234
Jan-10
Replace the count placeholder with the value of 10 and move the closing
bracket of the For loop after the pt01.ByCartesianCoordinates statement.
You usually use single letters such as i, j or k as the index variable. Count specifies
how many times the content in the loop is being run. You can use 10 as a fixed
value and replace it later with a variable that may become an input argument, like
cs, to change the number of Points from the outside.
In the script editor change the X position of pt01 by editing the line as
follows:
pt01.ByCartesianCoordinates(cs, 3*i, 1, 0);
This will increment the X position of the Point by 3 with each cycle of the
loop.
Jan-10
235
Scripting Basics
Click Apply.
If you want to control the number of Points through the input arguments, rather
than using the hard coded 10, you can add it to the input argument list.
Replace the explicit value 10 in the For loop with the new variable, num.
for (int i = 0; i < num; ++i)
Scripting Basics
236
Jan-10
The error in the GCScript Debugger indicates that the Function requires at
least 2 arguments, but only 1 was provided. This means that you did not
add a second argument in the argument list to the ByFunction update
method.
5
Run the transaction, Name it For Loop and Record User Changes.
Click Save.
In order to describe more complex forms then a straight line you can use the
Cosine and Sine equations to define the X, Y, Z position of the point list. You start
with the script from you created and add variables of Type double for xPos, yPos
and zPos.
Jan-10
237
Scripting Basics
Start with xPos and yPos only to specify the Points to form a circle. Using
trigonometry you can define a circle with Cos for the xPos and Sin for the yPos.
The following expression gives a unit circle, meaning a circle with a radius of 1.
double xPos = Cos(360/num*i);
double yPos = Sin(360/num*i);
pt01.ByCartesianCoordinates(cs, xPos, yPos, 0);
Scripting Basics
Exercise: Defining the X,Y,Z position using a Sine and Cosine equation
1
On the Transaction File tab, expand the For Loop transaction, then expand
point01. Click in the Function field and open the script editor.
Add xPos and yPos variables and replace the hard coded X and Y values.
238
Jan-10
Jan-10
Click OK.
239
Scripting Basics
The result would appear as follows, using a radius of 5 and the number of
points (num) set to 25.
With a simple addition you can make a climbing spiral of fixed radius from the
circle by defining the zPos to be a factor of the i variable.
Open the script and add the following line after the yPos definition:
double zPos = i;
Scripting Basics
240
Jan-10
The zPos will be defined by the height h divided by the number of steps,
times the current loop count i, or zPos = h/num*i.
Click OK.
Height (as defined by h) is now an input argument and needs to be
added to the FunctionArguments expression field. Youll also change the
number of points to 25 if you have not already done so.
Jan-10
241
Scripting Basics
You must rotate the view dynamically (Shift+Middle Mouse Button click)
and see result.
You have a spiral with a constant radius. Now you will make the radius adjust
based on the height of the point to create a more interesting outline. To achieve
this you will replace the simple assignment radius = 5 with a Sine expression
based on the i count.
You will reduce the range of the Sine function to one that creates positive values
only, so that there is no crossing of the spiral over the central axis.
Open the script and change the radius definition to the following:
double radius = Sin(180/num*i)*5;
Five is the scaling factor for the maximum radius when the sine function
returns a value of 1. Remember sine varies from 0 to 1.
Scripting Basics
242
Jan-10
Click OK.
Rotated view
Top view
Jan-10
243
Scripting Basics
Think of the spiral defining a path on a possible surface for a tower. For instance,
one similar to free-form towers such as Fosters Swiss Re or Jean Nouvels Torre
Agbar tower in Barcelona.
You may want to adjust the range 0-180 degrees so that the spiral does not start
at 0 at the towers base. To reduce the range to 80-180 degrees you will scale the
loop range defined by i to cover the difference between 80 and 180 or 100, and
then shift those results by 80 so the start value is 0+80 =80 and the end value
100+80=180.
Open the script editor and change the radius expression to the following:
double radius = Sin ((100/num*i)+80) *5;
Scripting Basics
Click OK.
244
Jan-10
Rotated view
Top view
The new spiral has a base that is wider at the bottom, but converges to a
point at the top.
Now you will create a variable number of spirals in a circular pattern to create a
Point cloud which you could use to define a surface. To do this you will add a
second For loop surrounding the inner loop that is used to start each spiral at a
different point in the circle.
Jan-10
245
Scripting Basics
Right click above the first For loop, select Statement Builder, and double
click for in the menu.
Change i in the outer For loop to j so the counter variable does not conflict
with i, which is already being used.
Move the closing For loop curly bracket so it is after the closing bracket of
the inner for loop.
Use the Increase and Decrease Line Intent tools as necessary.
Scripting Basics
Add another input argument to define the number of spirals around the
perimeter of the tower named spNum and of Type int.
246
Jan-10
You now need to adjust the xPos and yPos definitions to take the changing
starting Point of the spirals into account, otherwise all the spirals appear
in the same spot and it will look like you have one spiral.
You shift the value inside the Sine and Cosine function with each new
spiral by a fraction of 360 degrees.
Define this as the variable shift and define it again as a fraction of the
overall circle 360 (360/spNum where spNum is total number of spirals)
multiplied by the spiral number counter from the outer for loop j.
7
Add this shift value to the values in the Sine and Cosine expression of xPos
and yPos:
double xPos = Cos((360/num*i) + shift)*radius;
Jan-10
247
Scripting Basics
Click OK.
Rotated view
Scripting Basics
248
Jan-10
Top view
Using the same script structure but a different set of equations one can generate
different tower outlines. Rounding of the top of tower can be done with cubic
function.
The difference here is that the height of the spiral is defined by the function (not
h) and the radius is defined by the even increments. This is necessary in order to
flip the x and y axis to fit the tower. It also is mirrored to not stand upside down
and shifted to start at the z=0 level.
The Function Pow is double Pow (double x, double y). The result is x raised to the
y power.
To do this you use the cubic equation to define hShift to be the incremental shift
in height through the loop and start with an inverted cubic (height) by using the
minus sign. Otherwise, the tower would be upside down. Youll make it based on
i, so that you draw circles that converge cubically in height. A good place to find
3D information like this is:
http://mathworld.wolfram.com
Jan-10
249
Scripting Basics
Generating Polygons
double radius = i;
double shift = 360/spNum*j;
double hShift = ((1.0/num)*(Pow((num-1),3))*0.2);
double height = ((-1.0/num) * (Pow(i,3))*0.2)+ hShift;
double xPos = Cos((360/num * i) + shift)*radius;
double yPos = Sin((360/num * i) + shift)*radius;
2
Using other functions for hShift and height you can control the form of the circles
in height.
Generating Polygons
The generation of the Surface or the Polygons could also be integrated into the
function itself but then the parent Feature would have to be of the Type of the
final outcome and the Point would become an internal Feature that is not drawn.
The script would adapt for the last tower case, using a Polygon.ByFunction
method because the Feature that is supposed to be drawn and seen is a Polygon
not the Point. Generally, one should not mix Feature Types for children.
The method is to remove the return type and instead creates a Polygon variable
called poly here and makes it a child of the Polygon created ByFunction method
using the this keyword as in the beginning of the Point function example. The
Points are not parented to anything but only passed into the Polygon.ByPointGrid
method and therefore are not displayed in the final result.
Remember this script has to be placed inside the Polygon.ByFunction method,
not, as in the previous example, in the Point.ByFunction method. This is because
you are making the Polygon a child of the parent Polygon.
Cut and Paste the code from the Point feature to the Polygon feature,
with Update Method ByFunction.
With a GraphFunction we could called it in either the point or polygon
feature type.
Scripting Basics
250
Jan-10
Generating Polygons
Jan-10
251
Scripting Basics
Generating Polygons
You can now attach the cross bar or the pyramid to the replicated polygon.
Scripting Basics
252
Jan-10
Generating Polygons
For example:
transaction modelBased "First Point"
{
feature point01 GC.Point
{
Function
FunctionArguments
= {baseCS};
}
}
transaction modelBased "For Loop"
{
feature point01 GC.Point
{
Function = Point [][] function (CoordinateSystem cs, int num, double h, int spNum)
{
Point pt01 = {};
for (int j = 0; j < spNum+1; j++)
{
Jan-10
253
Scripting Basics
Generating Polygons
pt01[j] = {};
for (int i = 0; i < num+1; i++)
{
double shift = 360/spNum*j;
double radius = Sin ((100/num*i)+80)*5;
double xPos = Cos(360/num*i + shift) * radius;
double yPos = Sin(360/num*i + shift) * radius;
double zPos = h/num*i;
pt01[j][i] = new Point();
pt01[j][i].ByCartesianCoordinates(cs, xPos, yPos, zPos);
}
}
return pt01;
};
FunctionArguments
}
}
Scripting Basics
254
Jan-10
Generating Polygons
Points
= point01;
}
}
transaction modelBased "Polygon Grid"
{
feature polygon01 GC.Polygon
{
Points
= point01;
}
}
Results are seen on the Transaction File tab.
You can now use the New Feature tool to add crossbars to the polygon.
Jan-10
255
Scripting Basics
B-Spline Curve
The first example uses a script transaction that creates a set of top level Point
Features. Therefore the Features appear as individual Points in the Symbolic view
and can be referenced by their top level name. The disadvantage of this approach
is that the points are separate from the script that generated them and will only
be regenerated if the transaction script is replayed.
Exercise: Creating a Script
From the Transaction tab open the Script Editor and type in the following
script:
Scripting Basics
256
Jan-10
{
feature curve1 GC.BSplineCurve
{
Points = {p_0, p_1, p_2, p_3, p_4, p_5, p_6, p_7, p_8, p_9};
SymbolXY = {103, 103};
Color
= 2;
}
}
Jan-10
257
Scripting Basics
{
feature points2 GC.Point
{
Function = function (CoordinateSystem cs, int num, double scale)
{
for (int j = 0; j < num; ++j)
{
Point point = new Point(this);
point.ByCartesianCoordinates(cs,j+1.0,0.0,scale*j*j/num);
}
};
FunctionArguments = {baseCS,10,1};
SymbolXY
= {102, 99};
}
}
transaction modelBased "Second (using child Feature points) BSpline curve"
{
feature curve2 GC.BSplineCurve
{
Points
SymbolXY
Color
Scripting Basics
= points2;
= {103, 99};
= 4;
258
Jan-10
}
}
Jan-10
259
Scripting Basics
{
DPoint3d dPoint = {}; // list of points
= {103, 97};
}
}
Scripting Basics
260
Jan-10
= 0.5;
LimitValueToRange
= true;
RangeMinimum
= 0.0;
RangeMaximum
= 1.0;
SymbolXY
= {109, 98};
}
feature point4 GC.Point
{
Function = function (CoordinateSystem cs, int num, double scale, double t)
{
DPoint3d dPoint = {}; // list of points
for (int j = 0; j < num; ++j)
{
dPoint[j] = new DPoint3d(1.0+j, 0.0, scale*j*j/num);
Jan-10
261
Scripting Basics
}
BSplineCurve childBSpline = new BSplineCurve();
childBSpline.ByPointsAsDPoint3ds(cs, dPoint);
this.ByParameterAlongCurve(childBSpline,t);
};
FunctionArguments
SymbolXY
}
}
Sequence these scripts as four separate transactions in one gct file.
Scripting Basics
262
Jan-10
Jan-10
263
Scripting Basics
t_space_list[i] = i*t_spacing;
}
this.ByParameterAlongCurve(supportCurve, t_space_list );
return true;
};
}
}
An example of a mathematical GraphFunction you define, could be a very simple
user-defined square function. You would define one input argument of type
double to allow a user to specify the value to be squared. Then you can define a
local variable to store the result of your calculation called result. Finally, you need
to return that variable so the GraphFunction square_user(3) returns the value 9,
for instance, and can be used anywhere where a double value is expected.
transaction modelBased "create a square function"
{
feature square_user GC.GraphFunction
{
Definition = double function (double number)
{
double result = number * number;
return result;
};
}
}
Scripting Basics
264
Jan-10
References
Once this function is defined you can use it to define for instance the Xtranslation
of a Point Xtranslation = square_user(3);
And Xtranslation will take on the returned value of the function, in this case
3*3=9,
References
Jan-10
http://mathworld.wolfram.com
265
Scripting Basics
References
Scripting Basics
266
Jan-10
Design Problems
Module Overview
Several Design Problems are worked out for you in this module.
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Module Glossary
Hierarchical Control
Theory of the control of large systems which is always organized in a distributed
hierarchy. In all kinds of hierarchical systems, the common feature is the fact that
the decision-making process has been divided. There are several decision-maker
units in the structure, but only some of them directly access the control system.
The other decision-maker units are at a higher level on the hierarchy and they
define the tasks and coordinate the lower units.
Jan-10
267
Copyright 2009 Bentley Systems, Incorporated
Design Problems
Reference
Mesarovic, Macko, and Takahara book called Theory of Hierarchical, Multilevel
Systems. Also, Bailey, and Brdys wrote the book Control and Coordination in
Hierarchical Systems.
Design Problems
Arrange the windows in such a way that they don't overlap and both the
Symbolic view and the Geometric view are visible as well as the GC control
panel.
268
Jan-10
Jan-10
Select Create Point and place four points. in the Isometric view.
From the available feature method (the different possible ways to create
this feature based on various combinations of inputs) select ByPoles.
269
Design Problems
In order to construct the list of points, click in the Poles input field.
To select an existing feature, hold down the Ctrl key, then hover over the
point in the Geometric or Symbolic view until the name of the feature
appears in the input window. Clicking will confirm the selection and add a
comma. Repeat until all four points are filled in, then press Enter to
confirm the selection.
The next step is to create some working planes that are parallel and
perpendicular to the path.
Design Problems
270
Jan-10
Use Edit Feature and select plane01, then right click on the T variable and
make sure the free option is checked so the plane can be moved along the
curve for testing.
Select the Move Feature and click on the red circle handle that is around
the plane you just created. and test the attachment to the curve.
Now you will create a second plane that will be horizontal at all times.
First select the baseCS, pressing the Ctrl key, and then type a period after
the feature name.
A menu containing valid parameters opens.
10 Select the XYPlane from that list by double clicking on it and then click OK.
Jan-10
271
Design Problems
This should create the second Plane, plane02 at the same location as
plane01 but with a different orientation.
The next step is to create one inverted "T" cross section of the roof along the
path. In order to complete the roof you will construct one cross section first and
later replicate it along the path. For the section you need a plane that is
perpendicular to the path and one that is parallel to the horizontal component of
the path.
Now you can use plane02 to create a line that defines the height of the roof.
Design Problems
Select Create Feature, choose the Line feature, and as the Update Method
choose ByStartPointDirectionLength.
272
Jan-10
If you want to jump ahead use the expression 5-plane01.Z instead, which
makes the length responsive to the path. The 5 ensures that the top of the
roof is at least 5 units above ground plane.
Creating the ribs or outrigger of the roof you need to first define the
direction the cross members should be pointing to. You can derive this
direction from intersecting the two planes you already have, since their
intersection will create a Direction that is always horizontal and always
perpendicular to the curve.
3
Click Apply, not OK, to keep the dialog open, because you need it for the
next step.
To repeat the line to the other side you can use the Create Copy button to
the left of Apply.
Create Copy keeps the current values but creates a new Line instance.
Jan-10
The only change you need to make is inverting the direction of the Line by
changing the Length from 0.5 to -0.5 and pressing OK.
273
Design Problems
You should see an upside down T now, which is the roof section.
Now you will replicate the single section multiple times along the curved path.
You can replace a single input value for a feature with a List of values, which
causes anything that depends on that feature to be replicated for each of the
values in the array. In this case you will use the T parameter of plane01. Instead of
a single T = 0.3 value you will replace it with a List of values. The syntax for a list
requires curly brackets and coma separated values. T = {0, 0.2, 0.4, 0.6, 0.8, 1.0}.
To change the T value you use Edit Feature on plane01. Select the Edit
Feature tool and click on plane01 (the plane with the red handle circle).
In the edit window click on the T value and replace the single value T = 0.3
with the list, T = {0, 0.2, 0.4, 0.6, 0.8, 1.0}
Design Problems
274
Jan-10
You can now use the Lists of Line.Endpoints of the sections to define a
BSplineSurface, which will be the design surface for the roof.
Jan-10
275
Design Problems
The lines are replicated already and therefore form Lists of Lines.
Therefore their EndPoints are also Lists, so you can reference to them
directly. For example, line01.EndPoint is such a List.
Be sure to remove the [0] indexes after selecting the lines with the Ctrl
key, since you want the entire List of endpoints, and not just one.
Currently the roof height is constant in height and width even as the path goes up
and down. To make it more interesting you can make it responsive to the
undulation of the path. To do so, you replace the fixed length of the vertical line,
line01, of the sections with an expression that calculates the height as a function
Design Problems
276
Jan-10
of the desired maximum height of the roof and the height of it base point along
the path.
Edit the vertical line line01 by selecting on the Edit Feature tool and then
the line. or select the line in the Symbolic diagram.
In the length field of the line subtract the Z value of plane01 from a fixed
value. This value will be the maximum elevation of the roof in absolute Z
of the baseCS CoordinateSystem: Length=5-plane01.Z.
This will adjust the height of the roof so that it will always exactly reach
the height of absolute 5 in the Z-Axis of the baseCS. This is possible
because the simple equation varies the line01.Length to compensate for
the ups and downs of the path.
Use the move command to vary the initial four points height and position
to see the roof respond.
This completes building the roof surface - the next step explains how to
create a users defined component and populate it on the surface.
You will see one way to place a user defined cross bar panel along the surface
using a point grid on the surface and a intermediary ShapeGrid.
Jan-10
277
Design Problems
Use the Create Point and hold down Ctrl before clicking on the
BSplineSurface. Click to place it anywhere on the surface.
Once the point is placed on the surface use the Edit Feature command to
edit the point.
Replace the current U and V value with a Series functions to obtain a grid
of point rather then a singular point.
U should be set to U = Series(0.0,1.0,0.05)
V should be set to V = Series(0.0,1.0,0.1)
Click Apply.
You will see a diagonal set of points. In order to get the full grid of points
you need to toggle the replication option of the point. Choose the Toggle
Replication command and click on the points once. That should turn the
diagonal into a full grid of points.
Design Problems
278
Jan-10
Select the feature Polygon and as the creation method used ByPointGrid.
Set the PointGrid variable to the point you just created on the surface,
most likely point05. Remove the curly braces, {}. When selecting the point
make sure to erase the index's [0][1] to get the entire array not just one
point of it.
Next you will create a simple crossbar panel. You use a placeholder shape to
create it on the side. Then you create a new feature from it. After that you can
use the new feature to populate the roof surface using the grid of shapes instead
of the placeholder as the input to the crossbar panel. This will create an elegant
lattice as a roof, which still can be manipulated moving the initial four points of
the path.
Jan-10
279
Design Problems
Place four planar points in a square configuration away from the roof
using the point shortcut.
Using those points create a Polygon from the feature list using the
ByVertices as the Update Method. The input needs to be in the form of a
list of points.
Vertices = {point06, point07, point08, point09}
After creating the shape, hide the original points using the Toggle Visibility
command. This is so you do not accidentally select them. Use the
Symbolic view for easier selection.
In order to be able to replicate the Generated Feature Type (a generative
component) using a polygon grid you need to use only the polygon
vertices as input, not the underlying points.
For the other diagonal click Apply and then the Create Copy button and
replace [0] with [1] and [2] with [3] in the Vertices index.
Remember that a Polygon counts its Vertices in a circular fashion, not row
by row. In this case you have four vertices therefore the index goes from
0-3. You now have a diagonal cross.
Design Problems
280
Jan-10
Think of other geometry besides a crossbar that you can substitute here.
Now you create a new user defined feature from the crossbar. To do so,
select the Generate Feature Type tool.
The Generate Feature Type window opens.
Click on Select from Model to select the geometry of the new feature.
The symbolic model turns grey to prepare for the selection. As input,
choose the placeholder polygon (polygon02) you created for the
component. Click OK.
In the Symbolic view you see the line and cone icons in green, which
confirms your selection. This will be the Output of the new feature, the
input, the shape appears in cyan.
4
Enable the Construction check box for the two diagonal lines so you dont
see the lines in the final placed crossbar feature check.
Jan-10
281
Design Problems
In the final step, place the new feature crossbar01 onto the polygon grid on the
roof.
Use the ByDefault update method and select the grid of shapes on the
BSplineSurface, polygon01 as the input.
Be sure to remove the index square brackets when selecting the
polygon01 with the Ctrl key, as you want to use all shapes, not just one.
Design Problems
Click OK and you will see the crossbar grid populating the surface.
282
Jan-10
Shade the view by selecting the Set View Display Mode and Smooth as the
shading type.
Jan-10
Use the Pyramid feature type you created earlier in the class. It, too, is
looking for a polygon input type.
Adjust the Series function for U and V for the point on the surface
(point05) by adding finer increments. For example, change to
Series(0,1.01,0.25).
In order to be able to move the initial points you may want to toggle the
BSplineSurface update property to Deferred using the Toggle Deferral
tool. Click on the bSplineSurface01 in the Symbolic tree model. Since it is
hidden, you cannot select it from the geometry model). This will cause the
283
Design Problems
BSplineSurface and all its children (the crossbar etc.) to not update while
moving the path points. Once the path is adjusted, you need to toggle the
deferred property of the surface again to update its position.
Exercise: Setup
1
Design Problems
284
Jan-10
RangeMinimum: 0
RangeMaximum: 2000
RangeStepSize: 50
Name: RollerDia
Value: 40
LimitValueToRange: true
RangeMinimum: 0
RangeMaximum: 100
RangeStepSize: 5
Name: SideHeight
Value: 100
LimitValueToRange: true
RangeMinimum: 0
RangeMaximum: 500
RangeStepSize: 5
Name: SideWidth
Value: 20
LimitValueToRange: true
RangeMinimum: 0
RangeMaximum: 100
RangeStepSize: 5
Name: SupportDim
Value: 50
LimitValueToRange: true
RangeMinimum: 0
Jan-10
285
Design Problems
RangeMaximum: 200
RangeStepSize: 5
4
Design Problems
286
Jan-10
point05
CoordinateSystem: baseCS
XTranslation: ConLength
YTranslation: ConWidth/2
ZTranslation: 0
point06
CoordinateSystem: baseCS
XTranslation: ConLength
YTranslation: -ConWidth/2
ZTranslation: 0
7
Select Create Feature and choose Line with Update Method ByPoints and
create two lines as follows:
line01
StartPoint: point03
EndPoint: point06
line02
StartPoint: point02
EndPoint: point05
Next you will create the sidebars of the conveyor. These will be small in
comparison to the length of the conveyor so in order to see them you will
need to Rotate to the Left (or Right) View and zoom in.
8
Jan-10
287
Design Problems
Design Problems
288
Jan-10
NumberAlongCurve: line01.Length/(RollerDia*2+25)
IncludeStart: false
IncludeEnd: false
point08
Curve: line02
NumberAlongCurve: line02.Length/(RollerDia*2+25)
IncludeStart: false
IncludeEnd: false
Jan-10
289
Design Problems
EndRadius: RollerDia
Design Problems
290
Jan-10
IncludeEnd: true
Now you will create several points for a support for the conveyor.
20 Select Create Feature and choose Point with Update Method
Jan-10
291
Design Problems
point10
CoordinateSystem: baseCS
XTranslation: 0
YTranslation: 0
ZTranslation: 0
point11
CoordinateSystem: baseCS
XTranslation: 0
YTranslation: ConWidth/2+SupportDim/2+SideWidth/2
ZTranslation: 0
point12
CoordinateSystem: baseCS
XTranslation: 0
YTranslation: ConWidth/2+SupportDim/2+SideWidth/2
ZTranslation: -ConHeight
point13
CoordinateSystem: baseCS
XTranslation: 0
YTranslation: ConWidth/2+SupportDim/2+SideWidth/2
ZTranslation: -ConHeight+25
point14
CoordinateSystem: baseCS
XTranslation: ConLength
YTranslation: ConWidth/2+SupportDim/2+SideWidth/2
ZTranslation: -ConHeight+125
Design Problems
292
Jan-10
point15
CoordinateSystem: baseCS
XTranslation: 0
YTranslation: ConWidth/2+SupportDim/2+SideWidth/2
ZTranslation: 250
point16
CoordinateSystem: baseCS
XTranslation: 0
YTranslation: ConWidth/2+SupportDim/2+SideWidth/2
ZTranslation: -ConHeight+250
The remaining points will mirrored copies of the first points.
21 Record User Changes into Transaction file.
22 Select Create Feature and choose Point with Update Method
Jan-10
293
Design Problems
FeatureToMirrorCopy: point14
Plane: baseCS.XZPlane
point21
FeatureToMirrorCopy: point15
Plane: baseCS.XZPlane
point22
FeatureToMirrorCopy: point16
Plane: baseCS.XZPlane
23 Select Create Feature and choose Line with Update Method ByPoints and
Design Problems
294
Jan-10
EndPoint: point14
line05
StartPoint: point17
EndPoint: point20
line06
StartPoint: point15
EndPoint: point21
Jan-10
295
Design Problems
XDimension: SupportDim
YDimension: SupportDim
bsplineSurface04
Path: line05
XDimension: SupportDim
YDimension: SupportDim
bsplineSurface05
Path: line06
XDimension: SupportDim
YDimension: SupportDim
You will now turn these surfaces into Solids.
26 Select Create Feature and choose Solid with Update Method
Design Problems
296
Jan-10
SurfaceToCap: bsplineSurface05
Jan-10
297
Design Problems
EndRadius: 75
cone04
StartPoint: point20
EndPoint: point19
StartRadius: 10
EndRadius: 10
cone05
StartPoint: point19
EndPoint: point18
StartRadius: 75
EndRadius: 75
cone06
StartPoint: point15
EndPoint: point22
StartRadius: 10
EndRadius: 10
cone07
StartPoint: point21
EndPoint: point16
StartRadius: 10
Design Problems
298
Jan-10
EndRadius: 10
Name: SupportConveyor
Inputs (select from Symbolic View):
baseCS - make replicable
ConHeight
ConWidth
SideWidth
SupportDim
Outputs:
Keep default but:
Make all bsplineSurfaces Construction
Make all lines Construction
Jan-10
299
Design Problems
Design Problems
300
Jan-10
baseCS: coordinateSystem01
Jan-10
301
Design Problems
Design Problems
302
Jan-10
Module Prerequisites
Module Objectives
After completing this module, you will be able to:
Display Styles
Luxology Manager
Materials
Lighting
Output to 3D PDF
Display Styles
A Display Style consists of a shading mode plus other settings and overrides
(color, transparency, etc) that you can specify. Display styles are created and
Jan-10
303
managed in the Display Styles dialog. They are typically saved as shared resources
in DGN libraries, but can be stored in the active file.
The point of using Display Styles is to have a permanently shaded (until you
change it back to wireframe) view. You can zoom, pan and rotated in shaded
mode with Display Styles turned on.
Display styles apply to saved and dynamic views, as well as normal views. The list
of styles is sub-divided by Display mode. Wireframe display styles are followed by
hidden line, filled hidden line, and shaded display styles.
Review different Display Styles by clicking and pressing and holding the
Display Style icon and selecting different modes.
304
Jan-10
displaying its viewing cone in all other views that display the same volume of the
design file. When this tool is selected you are prompted to select an active view.
In this example View 2 the Right Isometric view is selected. You now have the
option of selecting the camera position and target using any of the other open
views. You can work in one view and use AccuDraw to manipulate the camera
and target position.
After an active view is selected you can then select the type of lens available from
the options list and enable Camera Height, Target Height or select these positions
using AccuDraw and AccuSnap on the view geometry.
Jan-10
Continue in solid_between_related_surfaces.gct.
Open Views 2 and 3 and set them to Top and Front and set View 1 to
Isometric.
305
In the View Control tool bar, right click on any tool and from the menu
select Camera Setup.
Select Setup Camera and left click once in View 1 (the Isometric view).
Then, left click in the Front View as shown, to set the camera position.
306
Jan-10
You can use other tools to manipulate the camera as needed. The most common
method is to choose the Navigate View tool (you might need to right click and
turn this tool on like you did with the Camera Setup tool) in the View Control tool
bar.
Jan-10
307
308
Jan-10
In the pop-up menu select New Script Transaction, and select Insert After.
This opens a new window within which we write the following code:
transaction script "Animate Pyramid Height"
{
int frames = 15;
/* double otherVar= othervalue; */
double heightStep = 0.75;
In the code above, each of the variables perform the following task:
heightStep - The increments that the height graph variables will increase at
every iteration.
One very important line to note is the UpdateGraph() function. This instructs
GenerativeComponents to regenerate all open geometry windows at every
iteration.
Animating a Camera
The code necessary for animating a camera is similar to the code for animating
graph variables, except rather than modify the value of a graph variable, this time
the code modifies the camera eye point's T value on the curve. Again, create a
new script transaction and write code to do this. YOu wil first need to create a GC
Camera Feature Type.
Jan-10
309
In the pop-up menu select New Script Transaction, and select Insert After.
This opens a new window within which we write the following code:
transaction script "Animate Camera"
{
int frames = 15;
double tVal = 0;
double tInc = 1/frames;
310
Jan-10
UpdateGraph();
tVal = tVal + tInc;
}
}
The frames variable indicates how many frames will be iterated, the tVal variable
holds the T parameter value for the camera point, in this case named point10,
and the tInc variable contains the increment value to step the point along the
curve. For this animation we would like the camera to move along the entire
curve, regardless of how many frames are iterated. Instead of calculating the T
value increment manually, a simple equation based on the number of frames will
work. Again, note the UpdateGraph() function and remember that this function
instructs GenerativeComponents to regenerate all open geometry windows at
every iteration.
Exporting Frames
This simplest way to export individual frames to stitch together later is to use the
SaveViewToImageFile() function. As arguments, you can specify which view
window to export, the height of the image to export in pixels (the width will be
derived proportionally from the aspect ratio of the window), and a file path for
the exported JPEG. The current view's shading settings will be used for rendering
the image before exporting it. Replace the code in the last transaction with the
following:
transaction script "Animate Camera and Capture Image"
{
int frames = 15;
double tVal = 0;
double tInc = 1/frames;
Jan-10
311
Luxology Manager
Luxology Manager
The Luxology Manager allows you to control Rendering, Materials and Lighting.
You can open Luxology from MicroStation > Utilities > Render > Luxology, or click
on the Render icon in the View control tool bar. Once again you can turn this tool
on by right clicking on the View Control tool bar and selecting Render from the
menu.
Render
Render Options
Lighting
Materials
View to Render
Left click on the Render icon to see the rendered image. The time to render is
dependent on several variables like: complexity of model, lighting, materials and
hardware.
Note: To remove the points select Render Settings and turn on Ignore Open Elements
and Text.
312
Jan-10
Materials
Materials
Materials allow you to add realistic imagery to surfaces, like wood, marble, glass,
etc. Luxology allows for many types of formats, like JPG or TIF or specialized
Luxology materials to add Fur or 3D materials.
By default, Luxology rendering assumes that each design file surface is made of a
material with a smooth shiny surface, such as plastic. Material definitions let you
specify that an element is water or wood or brickwork. When rendered, instead
of seeing the plastic element, you see the specified material. Each material
definition can include a pattern map and/or a bump map, as well as other settings
determining the finish and transparency/translucency of the material plus much
more. Pattern maps and bump maps are image files that are applied to surfaces
during the rendering process.
Pattern maps
A pattern map is an image file that is applied to an element. You can think of this
in terms of wall-papering a wall. When you render an element that has a pattern
map applied to it, instead of seeing the element (wall) you see the pattern map
(wall-paper). MicroStation provides a large range of image files, in JPG and TIF
format, that can be used for pattern maps. These are stored in the
\Workspace\system\materials\pattern folder. Additionally, you can use your
own image files as pattern maps.
Bump maps
Like pattern maps, a bump map is an image file that is applied to an element.
Where it differs from a pattern map is that a bump map applies roughness or
texture to a rendered surface. While it is not mandatory for bump map images to
be grey-scale, quite often they are. MicroStation uses the contrast in the bump
map image to calculate texture, or bumps, in the rendered image. As part of the
material definition, you can vary the height of these bumps. This lets you use the
same bump map image file, for example, to create cast metal from very roughcast through to nearly smooth.
Jan-10
313
Materials
Open solid_between_related_surfaces.gct.
Click on Open Palette or select the menu item Palette > Open.
314
Jan-10
Lighting
Left click once on the geometry in any view and left click again on nothing
(empty space).
The second left click is to Accept the assignment of the material.
Explore other materials and try them out. You can Remove Assignment the same
way, by right clicking and choosing Remove.
Lighting
Lighting is the key to photo realism. Spend more time with lighting and you will
have better results.
Jan-10
315
Lighting
There are two basic types of lighting: Global Lighting and Source Lighting. To open
the Light Manager, select the Light icon in the Luxology Manager.
Global Lighting
Global lighting affects all elements in a file.
Ambient
Ambient lighting affects every element in the model. It adds lighting equally to all
elements. As you increase the value of Ambient lighting, the amount of contrast
diminishes. Ambient lighting is useful for illuminating surfaces that would not
otherwise receive light. No shadows are cast by Ambient light. Settings for this
light source let you adjust its Lux, Color, and Temperature.
Flashbulb
Like a flashbulb on a camera, this light source illuminates all elements that are
facing the viewing position or camera. Useful for checking models during
construction, you also can use it to add light to a final image. No shadows are cast
by this light source. Settings in the Global Lighting dialog, let you adjust the Lux,
Color and temperature of the Flashbulb.
316
Jan-10
Source Lighting
Solar
Used to simulate lighting from the Sun, Solar lighting has settings that let you set
any of the following:
You can input this data manually in the appropriate fields, or you can use dialogs
to select a city from a list or pick a location from a map of the world. These
dialogs are opened by clicking one of the following options in the Location section
of the Global Lighting dialog:
Cities opens the Location By City dialog from which you can select a city
from the list.
Map opens Google Earth. Enable View > Grid to display longitude and
latitude and View > Show Time>Automatically. With this method, you must
still enter the GMT Offset manually.
Zones opens the GMT Offset By Time Zone dialog from which you can
select a time zone.
Optionally, you can turn on Solar Shadows to view the effect of shadows
generated by the Solar lighting (sunlight) when rendering with the Phong or Ray
Trace options. As with other Global light sources, you can specify the Lux, Color
and temperature of the simulated sunlight.
Source Lighting
Unlike Global Illumination, which is controlled solely from a dialog, Source
lighting consists of light sources in the form of special cells that you place in the
design. This is done with the Define Light tool, which you will look at shortly. First,
a brief description of source lighting.
Source lighting cells are stored in the cell library lighting.cel, which is accessed
automatically by the Place Light tool. You do not have to attach this cell library
before placing light sources. The Place Light tool has various settings for each
light source type, which you enter prior to placing the light source. The same tool
lets you modify them, if necessary, at a later date. The cells consist of
construction class elements and are placed by default on level Default.
Jan-10
317
Source Lighting
Point
Similar to a light globe, point light sources radiate light in all directions, from a
point light source. Shadows can be generated by this light source in Ray Trace
rendering only; they are not supported by Phong rendering.
Spot
Directional light source that behaves similar to a flashlight. Spot Lights have a
conical beam. This can be defined to taper off to zero at the edge of the beam.
You can define the Cone Angle for the beam and a Delta Angle through which the
beam reduces from full intensity to zero. Shadows can be generated by this light
source for Phong and RayTrace rendering.
Area
Created from existing polygons in the design, these light sources are useful for
simulating fluorescent lighting, for example.
Directional
Directional light source that produces parallel light rays throughout the design,
similar to sunlight. It does not matter where in the model that you place one of
these light sources, all surfaces that face the direction of a Distant light source are
illuminated by it. Shadows can be generated by this light source for Phong and
RayTrace rendering.
318
Jan-10
Output of Imagery
Sky Opening
Used with Ray Tracing, Radiosity solving, and Particle Tracing, to generate more
efficient solutions for indoor scenes lit with Solar Lighting, Sky Light, or Distant
Light sources, through an opening in a wall or ceiling. Rather than consider the
entire sky for calculating the lighting effect, only the lighting that is visible
through the opening is considered.
Each source lighting cell that you place in a design can have different settings for
such things as Intensity and Color. You can specify whether or not they cast
shadows for the supported rendering modes.
Output of Imagery
There are many ways to share your computer graphics imagery (CGI). One way is
to create a 3D PDF of your rendered model, another is to Save an image to disk.
Jan-10
319
Output of Imagery
Click Print.
320
Jan-10
Output of Imagery
Save Image
To save an image to disk you can use MicroStation > Utilities > Image > Save.
Here you can choose several things, including: Format, DPI and Render Mode. For
a quick test choose Luxology from Render Mode.
Jan-10
321
Output of Imagery
322
Jan-10
GenerativeComponents Quick
Reference
Tools
Plane Selector
New
Open
Save
Save As...
Jan-10
323
Tools
Update Graphs
Promote MicroStation Element to Feature
using Element Symbology
Create Feature
Create Point
Create Plane
Move Feature
Switch Support
Copy Feature
Mirror-Copy Feature
Edit Feature
Delete Feature
324
Jan-10
Tools
Toggle Dynamics
Toggle Visibility
Toggle Deferral
Toggle Replication
Toggle Is Construction
Split Points
Merge Points
Create Model
Jan-10
325
Symbolic Diagram
Symbolic Diagram
326
Jan-10
Jan-10
327
Dot Operator: Use . (period, dot) to get pull down list of feature properties.
328
Jan-10