Home / Software Posts / Increase the Potential of GenerativeComponents with Key-ins

Increase the Potential of GenerativeComponents with Key-ins

Bentley Expert Profile Image

Bentley Expert

Architecture building


In MicroStation or in any other PowerPlatform tools (OpenBuildings, OpenRoads, OpenBridge) almost all functionalities has a Key-in. Key-ins allow us to use lots of functionalities with simple commands. In GenerativeComponents, there is an in-built function KeyIn() that allows us to execute any Key-ins. Key-ins could be especially helpful to use any functionalities that are not available in GC. Sometimes this approach requires less effort than taking the programmatic approach.

A bit about Key-ins

To get started with key-ins you may refer to this article: How to string key-ins together or create key-in scripts

Let’s take the example of placing a region by flood method inside some given elements.

Graph of a parabola and a straight line intersecting on a cartesian plane, showcasing GenerativeComponents.
Region that would be flooded

To achieve it through key-in we would first require to activate the ‘Create Region’ functionality and then provide key-in for the data point required to create the region.

We can easily find key-in about any functionalities from ‘Help Documentation’. In this case, we search about the ‘Create Region’ in Help to find about its Keyin. So the proper key-in would be ‘create region flood‘.

Searching Help for the right Key-in
Searching Help for the right Key-in

If you do not find the proper key-in about any specific function or option you may refer to these two wikis

Finally for entering the data point we can use the following keyin: ‘point absolute 397.8, 2307.6, -3918.9‘. The point should be inside the region.

To learn more about data point key-ins you may have a look at this article in Help, ‘Precision Input Key-ins’.

A region created through Key-in inputs
A region created through Key-in inputs

We can combine the above two key-ins in a single key-in as

create region flood; point absolute 397.8, 2307.6, -3918.9

Some great resources on key-in are available under the following section.


Using Key-in in GC

We can run the above key-in with the KeyIn() function inside a transaction script (recommended) or value node.

Now our challenge in GC would be to use the existing point node information as data points for the above key-ins. This can be achieved with few lines of GCScripting.

Step 1

Before starting, we may record a macro for initial tool settings which can be reused every time. In this case, I set the required options in the ‘Create Region’ dialog and record them in a macro.

Saving Create Region Dialogue Settings in a Macro

Step 2

We create a new ‘Script Transaction’ for executing the key-ins. In this example, I would like to create a region by flood method based on the Voronoi Sites or the below point.

Regions to be flooded
Regions to be flooded

Presently, there is no technique in GC that allows you to create regions or shapes by the flood fill method. So, the Key-in approach is very much helpful in this case. In script transactions, we use the below code.

transaction 8 script 'Run Key-in script'
    KeyIn('macro play Fill Region_OP_K'); // Runs a macro for initial dialog settings
    for (int i = 0; i < RandomPoints.Count; ++i)
        KeyIn('CO='+ Random(255));  // set active colors to a random color
        KeyIn('create region flood;T, point absolute ' + RandomPoints[i].X + ',' + RandomPoints[i].Y + ',' + RandomPoints[i].Z + '|2'); // create region based on GC points
Regions Getting Created Based on the existing Point Node


The biggest drawback of this approach is that we cannot go back to the previous state once the key-ins are executed. If any geometries are created they need to be deleted manually.

Relevant Tags

Overall, MicroStation is a powerful tool for civil design projects from roads to bridges, tunnels to railways, and everything in ...
Both CAD (Computer-Aided Design) and BIM (Building Information Modeling) are popular software technologies used in the architecture, engineering, and construction ...
WS Atkins overcame rail design challenges and site constraints with MicroStation’s parametric modeling capabilities. ...