V8i (SELECTseries 3) - Bentley · 2019. 6. 6. · OpenPlant Component Scripting V8i (SELECTseries...

of 96/96
OpenPlant Component Scripting V8i (SELECTseries 3) Bentley Institute Course Guide TRN017180-1/0001
  • date post

    31-Jan-2021
  • Category

    Documents

  • view

    7
  • download

    11

Embed Size (px)

Transcript of V8i (SELECTseries 3) - Bentley · 2019. 6. 6. · OpenPlant Component Scripting V8i (SELECTseries...

  • TRN017180-1/0001

    OpenPlant Component ScriptingV8i (SELECTseries 3)

    Bentley Institute Course Guide

  • Trademark Notice

    Bentley and the "B" Bentley logo are either registered or unregistered trademarks or service marks of Bentley Systems, Incorporated. All other marks are the property of their respective owners.

    AccuDraw, MDL, MicroStation, and SmartLine are registered trademarks; PopSet and Raster Manager are trademarks.

    AutoCAD is a registered trademark of Autodesk, Inc.

    Copyright Notice

    Copyright ©2012 Bentley Systems, Incorporated. All Rights Reserved.

    OpenPlant Component Scripting 2 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Feb-12

    Table of Contents

    Course Overview ____________________________________ 3Course Description ____________________________________3Target Audience_______________________________________3Prerequisites _________________________________________4Course Objectives _____________________________________4Modules Included _____________________________________4System Requirements __________________________________5Software Requirements_________________________________5Important Notes: ______________________________________7

    Additional Information _______________________________ 9Module Overview _____________________________________9Module Prerequisites __________________________________9Module Objectives_____________________________________9Best practice to developing scripts ________________________10Local Workspace ______________________________________10Base workflow ________________________________________11Launching Modeler ____________________________________12Place standard component ______________________________14Key-in _______________________________________________17Place Non-existent Component___________________________18Add EC Class__________________________________________18Add CREATION_ATTRIBUTE to Link EC Class to .NET Class ______20Create New .NET Assembly from Scratch ___________________23Publishing .NET Assembly to Local Workspace _______________30Parameterize Geometry ________________________________34Debugging ___________________________________________42Error Handling ________________________________________44Preview Diagram ______________________________________46Toolbar Icon __________________________________________49Placement Points ______________________________________52Datum ______________________________________________54Mapping EC Class to Spec/Catalogue table__________________56Value Mapping________________________________________58Property mapping _____________________________________58Ports & Piping ________________________________________58

    1 OpenPlant Component ScriptingCopyright © 2012 Bentley Systems, Incorporated

  • OpenPlant Compon

    Table of Contents

    Differencing Schemas __________________________________70Publishing to Managed Workspace________________________74Advanced Examples____________________________________80

    Additional Information _______________________________ 87Joint Implementation __________________________________87Controlling EC Property view behavior _____________________89Component Creation Setup______________________________90

    Course Summary ____________________________________ 93Course Summary ______________________________________93

    ent Scripting 2 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Course Overview

    Course Description

    This course contains step by step exercises to create custom parametric 3D components using the OpenPlant software.

    This course is designed to instruct the project administrator how to create and customize a project to meet corporate standards. You will use several tools in the OpenPlant family of products built to support these functions. It is rare when a company can use a software application without making modifications to the symbology or menus or component definitions.

    You will be instructed on how to extend projects with custom component classes and properties as well as define custom 3D geometry of the components. You will also learn the structure of component hierarchy and how to extend it. You will create and debug C# programs, modify behavior of existing components and spec records. You will learn how to maintain project schemas and publish finished components to the project repository.

    Target Audience

    This course is recommended for the following audience(s):

    • Engineers, Designers and Drafters responsible for customizing the OpenPlant Modeler software to fit their corporate needs.

    • Users should be familiar with programming. Understanding object oriented programming concepts and knowing .NET technology is advantageous.

    Feb-12 3 Course Overview

    Copyright © 2012 Bentley Systems, Incorporated

  • Prerequisites

    Prerequisites• Students taking this course should have a working knowledge of CAD systems

    and 3D modeling concepts

    • Students should have completed the OpenPlant Modeler User Fundamentals course and the OpenPlant Modeler Administrator course.

    Course Objectives

    After completing this course, you will be able to:

    • Create custom parametric 3D components

    Modules Included

    The following modules are included in this course:

    • Creating Custom Components

    Course Overview 4 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • System Requirements

    System Requirements

    You must have a CD drive or Internet access for product installation. The following prerequisites are required to run the OpenPlant Modeler (SELECTseries3):

    Processor: Intel Pentium 4 processor or AMD Athlon, 3.0 GHz or greater, or Intel or AMD Dual Core Processor, 2.0 GHZ or greater

    Operating System: Windows 7, Windows 7 x64, Windows Vista, Windows Vista x64, Windows XP Professional (SP2 or later) Windows XP Professional x64, Windows XP Home Edition (SP2 or later), Windows XP Tablet PC Edition, Windows 2000 Professional (SP3 or later), Windows 2000 Server, Windows Server 2003 (SP1 or later), Windows Server 2003 x64, Windows Server 2008, Windows Server 2008 x64.

    Microsoft Office: Professional Edition 2000 (SR1a), XP, 2003 or 2007.

    Memory: 2GB minimum recommended (More memory almost always improves performance, particularly when working with larger models.).

    Hard Disk: Requires 30 MB minimum free hard disk space in addition to the OpenPlant Modeler V8i requirement of 400 MB minimum free hard disk space.

    Input Device: Any industry-standard input device supported by Windows.

    Output Device: Any industry-standard output device supported by Windows.

    Software Requirements

    Install following software prior to joining OpenPlant component scripting training

    Note: It can take several hours before you install everything

    • Bentley Desktop Prerequisites pack

    • Bentley ProjectWise Explorer & Administrator (optional for testing ProjectWise integration)

    • Bentley Class Editor

    • Bentley OpenPlant Modeler

    • .NET Framework 4.0

    Feb-12 5 Course OverviewCopyright © 2012 Bentley Systems, Incorporated

  • Software Requirements

    • LINQPad: Excellent learning tool and scripting environment for .NET

    http://www.linqpad.net/

    Download and install the free version. Autocompletion is not necessary but if you want to invest into learning C#, it is a great helper, works just like the intellisense in Visual Studio.

    • IlSpy: Browser, navigator, decompiler of .NET assemblies

    http://wiki.sharpdevelop.net/ilspy.ashx (requires .NET Framework 4.0)

    • One of the following development environments for .NET - required to build and debug component scripts:

    • SharpDevelop 4

    Open source development environment for .NET trying to look and feel same as Visual Studio. Supports attaching debugger. MSDN library is not integrated directly into product as is in Visual Studio but the .NET documentation is available from Microsoft website freely, so it's not a problem. I’d recommend to take a look at SharpDevelop even if you have access to Visual Studio.

    http://www.icsharpcode.net/OpenSource/SD/

    -or-

    Visual Studio 2010, 2008 or 2005 Professional – not a free product

    90-day trial version can be downloaded:

    http://msdn.microsoft.com/cs-cz/evalcenter/bb655861(en-us).aspx

    The express version of visual studio can’t be used for script debugging as it lacks the attach debugger to running process feature.

    Course Overview 6 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Important Notes:

    Important Notes:

    For OpenPlant (SELECTseries 3) there are differences in the installation directories for Windows XP, Windows 7 or Windows Server 2008. The following tables provide the paths to the software files.

    Windows XP:

    Note: Whenever Network_Root/Local_Root/Project_Root are mentioned in the document, it refers to the above paths.

    Windows 7 (32 bit) or Windows Server 2008:

    Note: Whenever Network_Root/Local_Root/Project_Root are mentioned in the document, it refers to the above paths.

    Windows 7 (64 bit) or Windows Server 2008:

    Network_Root: Program:C:\Program Files\Bentley\OpenPlantModeler V8i\

    Local_Root: C:\Documents and Settings\All Users\Application Data\Bentley\OpenPlantModeler V8i\WorkSpace\Projects

    Default Projects Root: C:\Bentley Plant V8i Projects\

    Network_Root: C:\Program Files\\OpenPlantModeler V8i\OpenPlantModeler

    Local_Root: C:\ProgramData\Bentley\OpenPlantModeler V8i\WorkSpace\Projects

    Default Projects Root: C:\Program Data\Bentley\OpenPlantModeler V8i\WorkSpace\Projects\

    Network_Root: C:\Program Files (x86)\Bentley\OpenPlantModeler V8i\OpenPlantModeler

    Feb-12 7 Course OverviewCopyright © 2012 Bentley Systems, Incorporated

  • Important Notes:

    The training manual is written using Windows 7 (64-bit), so all snapshots and steps used in exercises will have locations according to Windows 7 (64-bit). If you are using a different OS, please refer to the table above.

    Local_Root: C:\ProgramData\Bentley\OpenPlantModeler V8i\WorkSpace\Projects

    Default Projects Root: C:\Program Data\Bentley\OpenPlantModeler V8i\WorkSpace\Projects

    Course Overview 8 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Additional Information

    Module Overview

    This module provides the steps to create custom parametric 3D components

    Module Prerequisites• Familiarity with CAD systems and OpenPlant Modeler software.

    Module Objectives

    After completing this module, you will be able to:

    • Create a custom parametric 3D component

    Feb-12 9 Additional Information

    Copyright © 2012 Bentley Systems, Incorporated

  • Best practice to developing scripts

    Best practice to developing scripts1 Develop and test scripts in local workspace modifying local schemas.

    2 Publish to ProjectWise Managed Workspace.

    3 Test from a different machine.

    Local Workspace

    The Local Workspace is installed with OpenPlant Modeler by default into following locations.

    (Operating System Local_Root)\Bentley\OpenPlantModeler V8i\WorkSpace

    Note: All exercises in this book assume using OPModeler_Imperial project and PlantInstances.dgn.

    Additional Information 10 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Base workflow

    Base workflow

    Feb-12 11 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Launching Modeler

    Launching Modeler

    This section contains hands on exercises to build a custom component “My Box” from scratch and serves as accompanying material to Advanced Training.

    Exercise:

    1 Launch OpenPlant Modeler by clicking on a desktop icon or from the Start menu.

    2 Click Cancel in ProjectWise Login dialog. We will be developing a new datasource using a local dgn file.

    3 Open PlantInstances.dgn file from OPModeler_Imperial project.

    Hint: Use bottom right section to quickly navigate to the desired location by selecting

    User: OPModeler

    Additional Information 12 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Launching Modeler

    Project: OPModeler_ImperialMetric

    Feb-12 13 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Place standard component

    4 Click Cancel in Open a Repository dialog. Connection is not necessary when developing locally.

    5 Modeler opens up ready for your input.

    Place standard component

    Exercise:

    1 Launch OpenPlant Modeler.

    2 Click Place Horizontal Vessel.

    Additional Information 14 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Place standard component

    3 The Place Equipment window with Design Geometry properties group opens.

    Feb-12 15 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Place standard component

    4 Finish placing the component by clicking twice into Isometrics view.

    5 Right-click on the vessel and select Modify Component from the context menu.

    6 In the Design Geometry property group modify the field B: Length tan tan to 250in6570mm.

    7 Click Apply Changes.

    Lessons learned

    • Components are placed by clicking on an icon.

    • Place Equipment and Modify Equipment dialogs show component diagram and also lists some properties.

    • 3D geometry of a parametric component is controlled by property values.

    Additional Information 16 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Key-in

    Key-in

    Exercise:

    1 Select Utilities > Key-in.

    2 Type mechaddin place HORIZONTAL_VESSEL_PAR DSC=EQUIP into the Key-in dialog and click Enter.

    Note: From now on, we will refer to typing a key-in expression and clicking enter by simply saying: Key-in .

    3 Finish placing the component.

    Lessons learned

    • Every component can be placed using a key-in expression by specifying appropriate class name.

    Feb-12 17 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Place Non-existent Component

    Place Non-existent Component

    Exercise:

    1 Key-in: mechaddin place MY_BOX DSC=EQUIP.

    2 Observe message center.

    Lessons learned

    • Every custom component requires an EC Class defined in the OpenPlant_3D schema.

    Add EC Class

    Exercise:

    1 Launch Bentley Class Editor V8i.

    Note: Class Editor is not a standalone product (at the time of this writing). However, it is installed with OpenPlant Administrator or Bentley i-model Composer.

    2 Open OpenPlant_3D.01.02.ecschema.xml file located in:

    (Operating System Local_Root)\Bentley\OpenPlantModeler V8i\WorkSpace\Projects\OPModeler_Imperial\DataSet\Schemas\

    3 Supplement OpenPlant_3D with OpenPlant_3D_Supplemental_Modelling.

    Hint: To supplement the schema right-click OpenPlant_3D schema in the tree and select Supplement Schema. Navigate to the same location as above to select the supplemental schema.

    Additional Information 18 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Add EC Class

    4 Add a derived class from Equipment.

    5 Change attributes of the new class as follows:

    Name = MY_BOX (use capital letters separated by underscores for Name)

    DisplayLabel = My Box (use proper case separated by spaces for DisplayLabel)

    Hint: Class Names are used as XML tag name, so special characters or spaces are not possible. As you can see, Class definition will be stored into OpenPlant_3D schema.

    Feb-12 19 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Add CREATION_ATTRIBUTE to Link EC Class to .NET Class

    6 Click Save in the bottom-right of the screen to apply your changes.

    Note: Depending on your version of Class Editor – if the Save button is not present, all in-memory changes are applied automatically as you type. Note that you will still need to save the schema file to disk after you make all your desired changes to make it available.

    7 Select File > Save to save your schema changes

    8 Restart Modeler to reload your schema changes.

    9 Key-in: mechaddin MY_BOX DSC=EQUIP.

    Observe message center.

    Lessons learned:

    • EC Class definition alone is not enough - we will need a draw script (to be implemented in .NET class) and then link the draw script to My Box EC class using Custom attribute named CREATION_ATTRIBUTE.

    Add CREATION_ATTRIBUTE to Link EC Class to .NET Class

    Exercise:

    We will proceed to add CREATION_ATTRIBUTE first and then define .NET class in the next exercise.

    1 Back in Cass Editor with OpenPlant_3D schema opened and supplemented by OpenPlant_3D_Supplemental_Modelling.

    Additional Information 20 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Add CREATION_ATTRIBUTE to Link EC Class to .NET Class

    2 Open OpenPlant_CustomAttributes.08.11.ecschema.xml from: (Operating System Local_Root)\Bentley\OpenPlantModeler V8i\WorkSpace\OPModeler\schemas\.

    3 Right-click on My Box class in the tree and select Custom Attributes > Add/Remove...

    4 Find CREATION_ATTRIBUTE in the list, push it to the bottom list, change its location to OpenPlant_3D_Supplemental_Modelling.

    Feb-12 21 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Add CREATION_ATTRIBUTE to Link EC Class to .NET Class

    5 Click OK.

    6 Fill in following values of the Creation Attribute properties:

    Assembly Name = MyComponents

    Class Name = MyBox

    Namespace = MyComponents

    Placement tool = EquipmentPlacementTool

    Handler Type = Equipment

    Hint: Assembly Name, Class Name and Namespace are used to lookup draw script located in a .NET assembly. Placement tool determines placement behaviour. Handler type determines how your component will be handled by Modeler. Diagram Cell Name and Cell Library will be discussed later.

    Note: Placement tool and Handler Type are described in the References section: Component Creation Setup.

    7 Click Save to apply changes.

    8 Click File > Save to save all your schemas to disk.

    Lessons learned

    • Supplemental schemas are used for storing custom attributes.

    Additional Information 22 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Create New .NET Assembly from Scratch

    Create New .NET Assembly from Scratch

    Draw script is a piece of code which instructs Modeler to draw 3D geometry.

    The draw script is implemented as a method named Create3DElements() of a .NET class, located in a namespace inside of a .NET assembly.

    The .NET assembly resides in a DLL (dynamically linked library) file, typically located in the workspace folder.

    The .NET assembly references other OpenPlant assemblies that provide building blocks for the draw script and enable it to communicate with OpenPlant Modeler.

    Modeler looks for the DLL file via $OPM_DIR_COMPONENT_ASSEMBLIES and $OPM_DIR_ASSEMBLIES variables and also within its installation location \Program Files\OpenPlant Modeler V8i\.

    Modeler first loads the .NET assembly when user executes corresponding key-in expression for the first time. The dll file is then locked and the draw script can't be changed until the Modeler is closed or until the assembly domain is forced to unload.

    Exercise:

    Note: A pre-created example .NET assembly will be described later.

    1 Open Microsoft Visual Studio.

    2 Select File > New > Project…

    3 Select Visual C# and Class Library from the Visual Studio installed templates.

    Feb-12 23 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Create New .NET Assembly from Scratch

    4 Type MyComponents in the Name field.

    5 Type C:\Development in the Location field.

    Hint: Make sure to spell the name exactly as is shown below. This is going to be your assembly name as well as the initial namespace. Both can be changed later in the development environment. Version .NET Framework 3.5 is recommended later versions or client profiles will cause Modeler to crash.

    6 Define new class MyBox in the namespace MyComponents with the end result as follows:

    Additional Information 24 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Create New .NET Assembly from Scratch

    7 Add references to following assemblies:

    • 32-bit Windows C:\Program Files\Bentley\OpenPlantModeler V8i\OpenPlantModeler\assemblies\

    • 64-bit Windows C:\Program Files (x86)\Bentley\OpenPlantModeler V8i\OpenPlantModeler\assemblies\

    • Bentley.Building.Mechanical.Api.dll

    • Bentley.Building.Mechanical.ComponentLibrary.dll

    • Bentley.Building.Mechanical.Components.dll

    • OPMCommon.dll

    • C:\Program Files\Bentley\OpenPlantModeler V8i\OpenPlantModeler\assemblies\ECFramework

    • Bentley.ECObjects.2.0.dll

    • Bentley.Geometry.2.0.dll

    • Bentley.Platform.dll

    8 Paste following code into MyBox.cs:using System.Collections.Generic;

    using Bentley.Geometry;

    using Bentley.Building.Mechanical.Components;

    using Bentley.Building.Mechanical.ComponentLibrary.Equipment;

    namespace MyComponents

    {

    public class MyBox : BaseEquipment

    {

    // minimal implementation

    public MyBox()

    {

    // Mandatory initialization of BaseEquipment instancevariables

    _app = new BMApplication();

    _fluidPorts = new List();

    }

    public override void Setup()

    {

    Feb-12 25 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Create New .NET Assembly from Scratch

    }

    public override List Create3DElements()

    {

    double length = 30;

    double width = 40;

    double height = 50;

    DPoint3d location = DPoint3d.FromXYZ(0, 0, 0);

    DVector3d direction = DVector3d.FromXYZ(1, 0, 0);

    // use predefined Plate object to define geometry of abox

    Plate box = new Plate(length, width, height, 0,location, direction);

    return box.Create3DElements();

    }

    }

    }

    9 Your window should look like this:

    Note: Namespace = MyComponents and Class name = MyBox

    10 Double-click Properties in the Solution Explorer to review your assembly name.

    Additional Information 26 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Create New .NET Assembly from Scratch

    Review that Assembly name = MyComponents.

    11 For all referenced Bentley assemblies (including OPMCommon) set the Copy Local property to False. All these referenced assemblies will be

    Feb-12 27 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Create New .NET Assembly from Scratch

    available during runtime automatically and hence don't need to be copied to the local bin directory.

    12 Press F6 to build your solution.

    13 Review that only MyComponents.dll and MyComponents.pdb files have been generated in the following folder: C:\Development\MyComponents\bin\Debug

    Note: The single dll file is necessary to deploy on production environment. The pdb file contains debugging symbols and can be left out from production.

    Additional Information 28 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Create New .NET Assembly from Scratch

    Hint: If your bind/Debug folder contains more than just the above 2 files please review that all referenced assemblies have the Copy Local property set to False (see step 11).

    If necessary, fix any build errors.

    Your solution is ready for the first run.

    Lessons learned:

    We know where to look for Assembly name, Namespace and Class Name - the parameters referred from CREATION_ATTRIBUTE.

    • MyBox .NET class inherits from BaseEquipment .NET class

    • MyBox has a constructor with some mandatory initialization

    • MyBox has a blank Setup() method

    • MyBox defines very simple draw script in its Create3DElements() method

    • The draw script uses helper Plate object (a building block) which knows how to draw a box

    Next we need to tell Modeler where to look for our new assembly

    Feb-12 29 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Publishing .NET Assembly to Local Workspace

    Publishing .NET Assembly to Local Workspace

    Exercise:

    Two options exist to make our new assembly visible to OpenPlant Modeler:

    1 Copy MyComponents.dll to one of the default locations where Modeler looks by default (defined by following variables):

    2 Change or append to the above variables the path where the MyComponents.dll file is located.

    Note: Same principle applies when publishing to a ProjectWise Managed Workspace. There are some issues with loading .NET libraries from UNC path - so avoid placing it in a shared drive.

    We will choose option 2 in our examples and ask Modeler to look into our visual studio project build ouptut folder.

    1 Open Modeler.

    2 Select Workspace > Configuration….

    3 Highlight OPM_DIR_COMPONENT_ASSEMBLIES variable.

    $OPM_DIR_ASSEMBLIES C:\Program Files\Bentley\OpenPlantModeler V8i\OpenPlantModeler\assemblies

    $OPM_DIR_COMPONENT_ASSEMBLIES C:\Documents and Settings\All Users\Application Data\Bentley\OpenPlantModeler V8i\WorkSpace\OPModeler\Assemblies

    Additional Information 30 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Publishing .NET Assembly to Local Workspace

    4 Click Edit….

    5 Change Edit Mode to Append and paste in your visual studio project output folder where the MyComponents.dll is located. e.g. "C:\Development\MyComponents\bin\Debug\".

    Warning: Make sure to include trailing back slash. If the backslash character is omitted, OpenPlant Modeler can crash.

    6 Click OK.

    Warning: Make sure to include trailing back slash. If the backslash character is omitted, OpenPlant Modeler can crash.

    Feb-12 31 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Publishing .NET Assembly to Local Workspace

    7 Click OK to close Configuration dialog.

    8 Click Yes, to confirm changes in OPmodeler.ucf configuration file - this is the place where the variable re-definition is stored.

    9 To verify if our script works and if it can be found by the Modeler, key-in: mechaddin place MY_BOX DSC=EQUIP.

    You should be able to place MyBox now.

    Note: The Preview diagram is blank and there are no Design Geometry properties available to parameterize our drawing.

    Additional Information 32 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Publishing .NET Assembly to Local Workspace

    Note: If there is a problem with configuration of assembly path - Modeler can crash:

    Note: A crash can also occur if you compile for a later version of .NET then 3.5 or any of the client profiles. To verify you have correct platform right click on the Project node in Visual Studio Solution Explorer or SharpDevelop project tree and select Properties. In the Properties pages on the Compile tab check the platform setting.

    Feb-12 33 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Parameterize Geometry

    Lessons learned

    • Modeler looks for component assemblies into several locations driven by configuration variables

    • We learned how to re-define such locations

    • Modeler will now look into our bin/Debug folder so we don't need to worry about publishing the changes whenever we modify and recompile our draw script during development.

    • Preview diagram and parametric properties are missing - this we will take care of in the next excercises

    Parameterize Geometry

    Examining our draw script reveals that the values of length; width and height are hard coded.

    To parameterize them, we need to define corresponding EC properties in My Box class and then modify our script to use those properties.

    Additionally, we will define initial values via Default Value custom attribute. And to make life easier to the users, we will put the three parameters into its own DESIGN GEOMETRY group. Also by means of custom attributes assigned to EC properties.

    Exercise:

    1 Open OpenPlant_3D schema in Class Editor and supplement it with two supplemental schemas:

    • OpenPlant_3D_Supplemental_Modelling

    • OpenPlant_3D_Supplemental_ModellingViews

    (see previous steps on how to do this)

    2 Open OpenPlant_CustomAttributes schema as well.

    Additional Information 34 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Parameterize Geometry

    3 Add three new properties to My Box class, MY_HEIGHT, MY_LENGTH and MY_WIDTH respectively, all with the same TypeName: double.

    4 Select My Height in the Properties list and click Custom Attributes… > Add/Remove…

    Feb-12 35 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Parameterize Geometry

    5 Add two custom attributes: Category and DEFAULT_VALUE.

    6 Place Category into OpenPlant_3D_Supplemental_ModellingViews.

    7 Place DEFAULT_VALUE into OpenPlant_3D_Supplemental_Modelling.

    8 Repeat last step with My Length and My Width.

    Note: You can also right-click on My Height and use copy feature to save some typing.

    9 Fill in property values of the newly added custom attributes:

    • Defaul Value

    • Value = 50

    • Category

    • Standard = 0 (always 0)

    • Name = DESIGN_GEOMETRY

    • DisplayLabel = Design Geometry

    • Priority = 400

    Additional Information 36 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Parameterize Geometry

    • Expand = True

    10 Click Save.

    11 Repeate for My Width and My Length parameters as well except to use different default value for each.

    12 Leave the Category priority for all three parameters same = 400.

    Note: It is handy to use Custom Attributes… > Copy feature to save you some typing.

    13 Save all your schemas.

    14 Modify your draw script by replacing your code with following:

    Note: Copy and paste the contents below:using System.Collections.Generic;

    using Bentley.Geometry;

    using Bentley.Building.Mechanical.Components;

    using Bentley.Building.Mechanical.ComponentLibrary.Equipment;

    namespace MyComponents

    Feb-12 37 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Parameterize Geometry

    {

    public class MyBox : BaseEquipment

    {

    // declare instance variables to hold the parameters

    protected double height;

    protected double length;

    protected double width;

    public MyBox()

    {

    // Mandatory initialization of BaseEquipment instancevariables

    _app = new BMApplication();

    _fluidPorts = new List();

    }

    public override void Setup()

    {

    // populate instance variables from EC instance propertybag

    // always access property bag in Setup for performancereasons

    bool reportMissing = true;

    length = GetPropertyAsDouble("MY_LENGTH",reportMissing);

    height = GetPropertyAsDouble("MY_HEIGHT",reportMissing);

    width = GetPropertyAsDouble("MY_WIDTH", reportMissing);

    }

    public override List Create3DElements()

    {

    // commented out, we are now using the instance variablesinstead

    // double length = 30;

    // double width = 40;

    // double height = 50;

    Additional Information 38 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Parameterize Geometry

    DPoint3d location = DPoint3d.FromXYZ(0, 0, 0);

    DVector3d direction = DVector3d.FromXYZ(1, 0, 0);

    // use predefined Plate object to define geometry of abox

    Plate box = new Plate(length, width, height, 0,location, direction);

    return box.Create3DElements();

    }

    }

    }

    15 Build your solution (press F6).

    Hint: Watch status bar - you want to see Build Succeeded.

    If you see following error message during compilation, it means the Modeler is still running and has your dll file locked, hence can't be overwritten by a new build. To ensure successful build, always exit Modeler before compiling your solution.

    Let's test our new component in Modeler.

    16 Key-in: mechaddin place MY_BOX DSC=EQUIP.

    17 Complete placing of the equipment.

    Feb-12 39 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Parameterize Geometry

    Notice our dimensional parameters are now visible in the Design Geometry group.

    18 Modify component by setting My Height = 150 and click Apply changes.

    Additional Information 40 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Parameterize Geometry

    Has your drawing changed?

    Lessons learned

    • We have removed hard coded values from our draw script and added instance variables to hold parameter values.

    • We initialized our instance variables from property bag.

    • Initialization was moved to Setup method for performance reasons. This is because the Setup is called once but the Create3DElements is re-called each time the geometry has to be re-drawn.

    • My Height parameter received a Default Value when My Box was first placed, then it stored a new value after we changed it.

    • My Box dynamically changed shape when we changed My Height dimensional parameter.

    Feb-12 41 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Debugging

    Debugging

    Exercise:

    1 Put a breakpoint in a place where you want to stop.

    2 Make sure Modeler is running.

    3 Select Debug > Attach to Process….

    4 Select OpenPlantModeler.exe process and click Attach.

    Additional Information 42 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Debugging

    5 Switch to Modeler and invoke the functionality which will lead to execute your code. The debugger will stop when the execution hits the breakpoint, letting you step through the code and inspecting variables.

    Feb-12 43 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Error Handling

    Error Handling

    During testing and especially in case of complex geometric calculation logic it pays off to add error handler trapping exceptions and sending them into the message center. Here is an example how you can do it.

    using System.Collections.Generic;

    using Bentley.Geometry;

    using Bentley.Building.Mechanical.Components;

    using Bentley.Building.Mechanical.ComponentLibrary.Equipment;

    namespace MyComponents

    {

    public class MyBox : BaseEquipment

    {

    // declare instance variables to hold the parameters

    protected double height;

    protected double length;

    protected double width;

    public MyBox()

    {

    // Mandatory initialization of BaseEquipment instancevariables

    _app = new BMApplication();

    _fluidPorts = new List();

    }

    public override void Setup()

    {

    // populate instance variables from EC instance propertybag

    // always access property bag in Setup for performancereasons

    bool reportMissing = true;

    length = GetPropertyAsDouble("MY_LENGTH",reportMissing);

    height = GetPropertyAsDouble("MY_HEIGHT",reportMissing);

    Additional Information 44 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Error Handling

    width = GetPropertyAsDouble("MY_WIDTH", reportMissing);

    }

    public override List Create3DElements()

    {

    var geometry = new List();

    try

    {

    DPoint3d location = DPoint3d.FromXYZ(0, 0, 0);

    DVector3d direction = DVector3d.FromXYZ(1, 0, 0);

    // use predefined Plate object to define geometry ofa box

    Plate box = new Plate(length, width, height, 0,location, direction);

    geometry.AddRange(box.Create3DElements());

    // simulate unexpected error

    throw newSystem.IO.InternalBufferOverflowException("Bad thing happened");

    }

    catch (System.Exception ex)

    {

    // send generic error and stacktrace to messagecenter

    (new Bentley.Building.Mechanical.Api.BMECApi())

    .SendToMessageCenter(

    Bentley.Building.Mechanical.Api.MessageCenterAction.Message_Error,

    ex.Message, ex.StackTrace);

    }

    return geometry;

    }

    }

    }

    Feb-12 45 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Preview Diagram

    When executed, the error message appears in the message center giving you the opportunity to attach the debugger and step through the code without losing this Modeler session.

    After opening the Message Center, double-click the message in the status bar to see the stack trace.

    Preview Diagram1 Launch Modeler with Empty.dgn file located in workspace folder (same

    place as PlantInstances.dgn).

    2 Add a new 2D model using File > Models and Create a new Model.

    3 Type Drawing in the Type field. Type My Box in the Name field and click OK.

    Additional Information 46 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Preview Diagram

    4 Sketch a box and name its three dimensions.

    Note: Use Top view because it is the one that will be displayed by the Placement dialog.

    5 Save the drawing as MyComponents.cel into folder Workspace\OPModeler\cells.

    6 Launch Class Editor.

    7 Open OpenPlant3D schema and supplement it with OpenPlant_3D_Supplemental_Modeling schema.

    8 Navigate to My Box and edit CREATION_ATTRIBUTE and set two missing properties:

    Diagram Cell Name = My Box

    Feb-12 47 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Preview Diagram

    Cell Library= MyComponents.cel

    9 Save all schemas.

    10 Restart Modeler so that the schema changes take effect and key-in: mechaddin place MY_BOX DSC=EQUIP.

    Diagram is now displayed in the Place Equipment dialog.

    Lessons learned

    • Preview diagram is a named model in a cell library file.

    • Modeler finds the cell using creation attribute's two properties - Diagram Cell Name and Cell Library.

    • Cell Library path is controlled by OPM_DIR_WORKSPACE_CELLS.

    Additional Information 48 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Toolbar Icon

    Toolbar Icon

    Exercise: Prepare icon

    1 Make an icon graphics of 24x24 pt resolution and save it preferably with .bmp file type.

    2 Copy eqt_tools.dgnlib file from: (Operating System Network_Root)\Bentley\OpenPlantModeler V8i\OpenPlantModeler\interfaces\ to the project workspace dgnlibs folder: (Operating System Local_Root)\Bentley\OpenPlantModeler V8i\WorkSpace\Projects\OPModeler_Imperial\DataSet\Dgnlibs\.

    3 Rename the copy of eqt_tools.dgnlib to MyComponent_tools.dgnlib.

    Exercise: Load icon file into DGNLib

    1 Launch Modeler and open the file MyComponent_tools.dgnlib created in the previous exercise.

    2 Select Work Space > Customize.

    3 Select the Icons tab.

    4 From the Current File icon, select Import Icons > From Bitmaps….

    This will open the Import BMP dialog.

    5 Type My Icon.bmp of 24x24 resolutions in the Icon Name: field.

    6 Select All Icon Sizes from the Generate: list.

    7 Click the Magnifying glass icon, next to the Generate: list to browse to the 24x24 .bmp file and click OK. This will add the selected .bmp in the icon library with the given name

    Feb-12 49 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Toolbar Icon

    Exercise: Add button to palette

    1 Select Work Space > Customize.

    2 In the Tools tab, expand the User Tools > MyComponent_tools.dgnlib.

    3 Click on the sub-node Equipment, the node is highlighted.

    4 Click a second time on the Equipment to rename the node.

    5 Change the name to My Components.

    6 If desired, delete all other tools and toolboxes that existed in MyComponent_tools.dgnlib originall as a result of copying the original eqp_tools.dgnlib..

    7 Right-click on the desired Tool Palette and click New Tool from the right-click menu.

    8 This will add new icon with Spanner graphics set as its icon. Modeler will prompt you to add an appropriate name for the tool button, give any suitable string.

    9 Enter following information in fields of Command Data.

    Key-in: MECHADDIN PLACE DSC=Piping.

    Ballon Text: Add text that you want to appear when user hovers over that icon.

    10 In General Settings click … in Icon field. This will open the icon library; select the desired icon from the list.

    11 In the Task pane navigate to the tool bar for which you just created the tool button.

    12 Drag the newly created tool button in the tool bar and drop it onto Task pane from the Tools tab.

    13 The newly added icon shows up in the tool bar.

    14 Save the file and exit Modeler.

    Additional Information 50 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Toolbar Icon

    Example - adding a sample My Box component into My Components.dgnlib.

    Feb-12 51 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Placement Points

    Placement Points

    Exercise: To add placement points:

    1 Initialize _placementPoints (member of BaseEquipment) to a new instance of List().

    2 Add relevant instances of PlacementPoint into the above list

    Changes highlighted in red.

    Note: Copy and paste the contents below:using System.Collections.Generic;

    using Bentley.Geometry;

    using Bentley.Building.Mechanical.Components;

    using Bentley.Building.Mechanical.ComponentLibrary.Equipment;

    namespace MyComponents

    {

    public class MyBox : BaseEquipment

    {

    // declare instance variables to hold the parameters

    protected double height;

    protected double length;

    protected double width;

    public MyBox()

    {

    // Mandatory initialization of BaseEquipment instancevariables

    _app = new BMApplication();

    _fluidPorts = new List();

    // initialized collection of placement points

    _placementPoints = new List();

    }

    public override void Setup()

    {

    Additional Information 52 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Placement Points

    // populate instance variables from EC instance propertybag

    // always access property bag in Setup for performancereasons

    bool reportMissing = true;

    length = GetPropertyAsDouble("MY_LENGTH",reportMissing);

    height = GetPropertyAsDouble("MY_HEIGHT",reportMissing);

    width = GetPropertyAsDouble("MY_WIDTH", reportMissing);

    }

    public override List Create3DElements()

    {

    // commented out, we are now using the instance variablesinstead

    // double length = 30;

    // double width = 40;

    // double height = 50;

    // Add 4 placement points

    // 0 - zero (original default)

    // 1 - length

    // 2 - width

    // 3 - height

    PlacementPoint point0 =

    new PlacementPoint(DPoint3d.FromXYZ(0.0, 0.0,0.0));

    point0.IsPort = false;

    base._placementPoints.Add(point0);

    PlacementPoint point1 =

    new PlacementPoint(DPoint3d.FromXYZ(length, 0.0,0.0));

    point1.IsPort = false;

    base._placementPoints.Add(point1);

    Feb-12 53 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Datum

    PlacementPoint point2 =

    new PlacementPoint(DPoint3d.FromXYZ(0.0, width / 2,height / 2));

    point2.IsPort = false;

    base._placementPoints.Add(point2);

    PlacementPoint point3 =

    new PlacementPoint(DPoint3d.FromXYZ(0.0, -width /2, height / 2));

    point3.IsPort = false;

    base._placementPoints.Add(point3);

    DPoint3d location = DPoint3d.FromXYZ(0, 0, 0);

    DVector3d direction = DVector3d.FromXYZ(1, 0, 0);

    // use predefined Plate object to define geometry of abox

    Plate box = new Plate(length, width, height, 0,location, direction);

    return box.Create3DElements();

    }

    }

    }

    Datum

    Additional Information 54 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Datum

    Equipment datum defines reference coordinates system for placing nozzles.

    Nozzles are used to connect pipes to equipment.

    Datum can also be added manually using Nozzle Manager > Datum Manager.

    Convention is to be to define and show only the Z and Y axes. It depends on which nozzle type you use on how it is positioned relative to the coordinate system (datum). For example, the Axial and Block-top types have the length of the nozzle parallel to the Z-axis, while the Radial and Tangential have the length perpendicular to the Z-axis.

    The constructor arguments are in-order location, Z-axis, Y-axis, name; the DatumStructure contains these values plus some flags. The two axes are not just directions, but the lengths may be used, for example, the Radial nozzle uses the length of the Y-axis to know the O.D. of the shell it is on, and the Block-top nozzle uses the length of the Z-axis to know where the face is for the non-port end of the nozzle.

    For your block with

    To make a datum to easily place Block-top nozzles on the top face:

    Datum to place Axial nozzles on the top face:

    bottom face at 0,0,0 length,0,0 length,width,0 0,width,0

    and top face at 0,0,height length,0,height length,width,height 0,width,height

    Location Z-axis Y-axis

    0,0,0 0,0,height 0,width,0 or length,0,0

    Location Z-axis Y-axis

    0,0,height 0,0,height+height/4 //arbitrary

    0,width,height or length,0,height

    Feb-12 55 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Mapping EC Class to Spec/Catalogue table

    To make a datum to easily place Block-top nozzles on the top face:

    Datum to place Block-top nozzles on the front face (y==0) ; nozzles in –y direction:

    Datum to place Block-top nozzles on the back face (y==width) ; nozzles in +y direction:

    To help with the turn-around time on testing, I recommend creating several variations using different names each time; it would be easy enough to remove any you did not want after you have the combination you want.

    Mapping EC Class to Spec/Catalogue table

    Exercise: To map EC Class to spec/catalog table:

    1 Open OpenPlant_3D.01.02.ecschema.xml schema in Class Editor.

    2 Supplement it with OpenPlant_3D_Supplemental_Modeling.01.02.ecschema.xml.

    3 Open OpenPlant_CustomAttributes.08.11.ecschema.xml.

    4 From the class navigation tree, navigate to desired EC Class in Supplemented OpenPlant_3D.01.02.ecschema.xml.

    5 Right-click on that class node and from the Context menu select Custom Attributes….

    Location Z-axis Y-axis

    0,0,0 0,0,height 0,width,0 or length,0,0

    Location Z-axis Y-axis

    0,width,0 0,0,0 0,width,height or length,width,0

    Location Z-axis Y-axis

    0,0,0 0,0,0 0,width,height or length,width,0

    Additional Information 56 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Mapping EC Class to Spec/Catalogue table

    6 That will launch the Custom Attribute Addition dialog. From the Available Custom Attribute list select OpenPlant_3D_Catalogue_ClassProperties, and add it the Existing Custom Attribute list by then clicking the Down Arrow button.

    7 The selected Custom Attribute will appear in the Existing Custom Attributes list, Set its location to OpenPlant_3D_Supplemental_Modeling.01.02 and click OK.

    OpenPlant_3D_Catalogue_ClassProperties

    Following fields are currently in use for OPM component mapping:

    Table: Contains the name of the database table which holds the records of that component

    Use EC Class: For rare scenario when certain EC Class uses another EC Class’s component records for component placement, the name of that EC Class needs to be defined here. The example given here is the Class Map custom attribute for PIPE_BEND EC Class. The OPM Specs doesn’t contain the PIPE_BEND records; in fact it uses the PIPE records for generated PIPE_BEND components. So here PIPE EC Class is defined under this field which will direct the OPM Query to PIPE EC Class.

    Feb-12 57 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Value Mapping

    Value Mapping

    Value Mapping is same as most of the other application. The following custom attribute is used for OPM value Mapping.

    OpenPlant_3D_Catalogue_ValueProperties

    Property mapping

    Property Mapping is same as most of the other application. Following custom attributes are used for OPM Property Mapping:

    OpenPlant_3D_Catalogue_AttributeProperties

    For properties defined under component’s EC Class

    OpenPlant_3D_Catalogue_PortAttributeProperties

    For properties defined under Fluid Port Class

    Ports & Piping

    This section describes the steps of defining and configuring the basic piping component MY_PIPE and explains the prerequisites of reading property values from spec database.

    Step1:

    Define a component script class. This class will serve as a specification for creating component geometry.

    A given component will fall under a specific Plant Discipline i.e. Piping, Equipment, Trays, HVAC, Supports etc.

    A base class represents the most generic specification for a given discipline for e.g. all piping components inherit from the PipingComponent base class which is further specialized based on the type of piping components.

    Additional Information 58 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    A basic overview of the PipingComponent class hierarchy is as follows:

    BaseComponent ->

    PipingComponent ->

    SinglePortPipingComponent

    TwoPortPipingComponent

    ThreePortPipingComponent

    FourPortPipingComponent

    Let’s define a custom pipe which we will call MyPipe inheriting from TwoPortPipingComponent:

    Step 2:

    Component geometry is created based on dimensional data defined in the spec or given by the user; the next step is to define member variables to store these dimensional values to be used throughout the life cycle of the component script. E.g. in our MyPipe example two dimensional fields are added in the following to store length and diameter values which will be used to draw the pipe.

    Feb-12 59 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    Note 2a:

    The keyword protected is a C# scope resolution operator, which has been defined for the member variables in order to make them accessible in derived classes

    Step 3:

    Components belonging to the i.e. Piping, HVAC, CableTray have Port data associated with them. Port data is required to be initialized.

    Note 3a:

    Step 3 can be skipped in case the component belongs to a portless discipline or a specific component that does not require port information.

    Port Definition:

    A Port is a specification of end condition/preparation of a given component; components such as piping components can have varying end conditions which influence modeling workflows, i.e. component connectivity, and the eventual component geometry.

    Typical data that a Port contains is end preparation, i.e. threaded, flanged, butt-weld etc. depending on the shape - round/rectangular, diameter, width, height. Specific discipline requires specific type of ports: PipingComponents use FluidPorts, TrayComponents use TrayPorts, HvacComponents use GasPorts etc.

    The number of Ports required is equal to the number of connecting/open ends of a component e.g. a Pipe has two open connecting/open ends.

    Additional Information 60 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    The Ports of a component are instantiated and added to an internal Ports Collection in the constructor of the Component Script Class, as follows:

    Step 4:

    Initialize Component Data i.e. Dimensional Data, Port Data, Placement Points etc. This is done by overriding Setup method of the base class.

    Step 4a:

    Read component dimensional information from component property bag. Here we attempt to populate our defined dimensional fields with data provided by the component's property bag, the components property bag is referred by a system level object called _bmecobject which contains the instance of the component property bag as per defined in the openplant3d schema for the given component class.

    Following is an example of member variables for holding dimensional data being populated by respective component properties.

    Step 4b:

    Note: Step 4b can be skipped for port-less components. In this step we initialize our ports, initializing ports implies setting appropriate values to port location, direction and orientation. This is done by calling portInitializationSetup method; the implementation of this method is defined in one of the specialized base classes - in this case TwoPortPipingComponent. The method comes with a number of overloads depending on the nature of

    Feb-12 61 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    the component, i.e. Pipe or Elbow are two port components, geometrically different in nature resulting in different dimensional properties to draw them.

    Note: Placement points is a collection of points on the component which can serve as a point of reference for component placement i.e. placing by the either of the outlet ends or the center of a component.

    Step 5:

    Creating the Component Geometry

    The component geometry is created in the Create3DElements method; this is done by creating a draw script object – an instance of PipeDraw in this case. The overall geometry of a Piping Component can be broken down into a number of parts i.e. basic component graphics, insulation graphics, end preparation graphics etc., each of which is created separately as shown in the following code:

    Note: Copy and paste the contents below:using System.Collections.Generic;

    using Bentley.Geometry;

    Additional Information 62 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    using Bentley.Building.Mechanical.Components;

    using Bentley.Building.Mechanical.ComponentLibrary.Common;

    usingBentley.Building.Mechanical.ComponentLibrary.Common.DrawGeometry;

    namespace MyComponents

    {

    public class MyPipe : TwoPortPipingComponent

    {

    protected double length;

    protected double diameter;

    // constructor

    public MyPipe()

    {

    // Ports collection is defined in PipingComponentsuperclass

    // Two fluid ports already added in TwoPortPipingComponent

    // You can add more ports if necessary

    // Ports.Add(new FluidPort());

    }

    public override void Setup()

    {

    // mandatory - call the base class initialization

    base.Setup();

    // Step 4a – initialize member variable length from ECProperty bag “LENGTH”

    this.length =_bmECObject.Instance["LENGTH"].DoubleValue;

    // Step 4b – initialize port data and placement pointsvia helper method inherited from TwoPortPipingComponent

    portInitializationSetup(this.length);

    }

    Feb-12 63 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    public override List Create3DElements()

    {

    // create main geometry collection

    this.elements = new List();

    // Draw script for creating basic pipe graphics

    PipeDraw pipe = new PipeDraw(length,this.mainPort,this.runPort);

    // call to create pipe graphics

    List componentGeometry =pipe.Create3DElements();

    // Note: mainPort, runPort are member variables definedin the TwoPortPipingComponent Class

    // adding graphics to main graphics collection

    if (componentGeometry != null)

    this.elements.AddRange(componentGeometry);

    // create insulation graphics

    if (insulationThickness > 0.001)

    {

    // call to create insulation graphics

    componentGeometry =pipe.CreateInsulation(insulationThickness);

    // adding graphics to main graphics collection

    if (componentGeometry != null)

    this.elements.AddRange(componentGeometry);

    }

    // create end preparation graphics

    // adds graphics to main graphics collection internally

    CreateEndPreps();

    // return main graphics collection

    Additional Information 64 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    return this.elements;

    }

    }

    }

    Exercise: Define EC Class MY_PIPE inheriting majority of the setup from PIPE class.

    1 Add MY_PIPE as subclass of PIPE.

    2 Right-click on PIPE in the tree and select Custom Attributes > Copy….

    3 Select CREATION_ATTRIBUTE and Component_Ports_Information.

    4 Right-click on My Pipe in the tree and select Paste from the context menu.

    Feb-12 65 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    5 Change parameters of CREATION_ATTRIBUTE.

    6 Add new custom attribute OpenPlant_Physical_Catalogue_Class_Map.

    7 Set the Table to PIPE.

    This will tell the Modeler to query PIPE table from the spec database.

    8 Set the Use EC Class to PIPE.

    Additional Information 66 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    This will tell the Modeler to filter the records where EC_CLASS_NAME = ‘PIPE’.

    Alternatively, you would need to add appropriate spec records with EC_CLASS_NAME = MY_PIPE in to PIPE table.

    9 Switch to Properties tab of the MY_PIPE class.

    10 Review the Length property which was inherited from Piping Component.

    Feb-12 67 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    11 Review the Nominal Diameter which was inherited and mapped to the MAIN_SIZE column of the spec database table PIPE by PropertyName of the custom attribute OpenPlant_Physical_Catalog_Property_Map.

    To test – launch Modeler

    12 In Standard Preferences for Piping Component dialog set:

    Specification: A1-OPM

    Nominal Diameter: 12

    13 Click Pipeline > New… and follow dialogs to create new pipeline by filling in desired Unit, Service and additional parameters.

    14 Key-in: mechaddin place MY_PIPE dsc=PIPING.

    Additional Information 68 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Ports & Piping

    15 Open Modify Component dialog on the newly placed pipe and review the Miscellaneous section the EC Class is MY_PIPE.

    16 Navigate to spec databases location: (Operating System Local_Root)\Projects\OPModeler_Imperial\DataSet\Spec Databases.

    17 Open the A1-OPM.mdb file in Microsoft Access to review the relevant spec records:

    Table: PIPE

    Column EC_CLASS NAME: PIPE

    Column MAIN_SIZE: 12

    Feb-12 69 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Differencing Schemas

    Differencing Schemas

    The purpose of the next exercise is to teach you how to move any EC schema changes made during develoment into standard schemas and publishing for project use. This task may also be useful for migrating any changes made to standard schemas after product upgrade.

    Exercise:

    1 Isolate all schemas containing your modifications.

    2 Perform next steps for each isolated schema separately.

    3 Open Class Editor.

    4 Select Tools > Options... > Reference Schemas Paths and remove all items from the list.

    5 Close Class Editor.

    6 Re-open Class Editor.

    7 Open the source schema which contains your changes. We'll start with OpenPlant_3D_Supplemental_Modelling.

    Additional Information 70 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Differencing Schemas

    Example - merging changes to OpenPlant_3D_Supplemental_Modelling schema.

    8 Select Tools > Schema Differencing….

    9 In the Schema Differencing dialog select Source schema (the one which contains your changes).

    10 In the Target Schema combo box Browse... and then select the desired target schema file on the disk.

    This is the schema file which doesn't yet contain any of your changes.

    11 Click Compare to invoke compare operation which can take a few seconds to execute depending on size of the schemas.

    12 Select changes you want to merge into the target schema.

    Feb-12 71 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Differencing Schemas

    13 Right-click on Multi Diameter Vessel class and select Check Sub Tree from the context menu to select all changes for this class.

    Hint: By default the tree shows all items in both source and target schemas. To easily isolate changes set the Display option to Differences.

    Note: The new items are marked in Green, deleted items are marked in Red and the changed items that exists in both source and target schemas are marked in Blue..

    14 Click Commit to confirm your changes.

    15 If desired, review all your changes were successfully committed to the Target schema by invoking Compare again.

    Additional Information 72 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Differencing Schemas

    The status of the Multi Diameter Vessel class is now Equal and the target values in the right pane are same:

    16 Close Schema Differencing Dialog.

    Feb-12 73 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Publishing to Managed Workspace

    Publishing to Managed Workspace

    Prerequisites

    • ProjectWise Administrator

    • OpenPlant Administrator

    • Managed Workspace which is published in Projectwise.

    Exercise:

    1 Create a PW Workspace/OPModeler/Assemblies folder in ProjectWise.

    2 Set variable OPM_DIR_COMPONENT_ASSEMBLIES = to the PW folder created in step 1.

    3 Save Examples.dll file into Assemblies folder

    Note: It is recommended to recompile component assembly with updated references to the currently installed Modeler version. Using components compiled for different version of Modeler is not recommended.

    Additional Information 74 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Publishing to Managed Workspace

    4 Assign Managed Workspace to PW working folder (where dgn files are located).

    5 Check-in modified Schemas into PW.

    Note: It is recommended to create new versions of existing documents.

    6 Using OpenPlant Administrator > Manage Schemas commit schema differences. This operation will migrate OpenPlant Model Server database to match class and property definitions in the new schemas.

    Note: This step ensures ability to check-in new component into OpenPlant Model Server database.

    7 Go to ProjectWise Administrator > OpenPlant Administrator > Schema Management (you might be prompted to select working directory just like in PW Explorer)

    Feb-12 75 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Publishing to Managed Workspace

    8 Switch to tab Update Server Schema.

    9 Click Select Schema and select the modified OpenPlant_3D schema, the one with your new component definitions.

    Note: Make sure to have all schemas available including BentleyBase etc.

    Note: You may be prompted to browse for Bentley_Standard_Custom_Attributes.01.02. One is also in C:\Program Files\Bentley\Class Editor V8i and actually version 01.01, but the compare function accepts it.

    10 Once compare has completed, select all differences you wish to commit.

    Hint: Expand sub-tree to review if all desired properties are checked as well.

    Hint: It is recommended to keep a separate log of all changes performed for future reference.

    Additional Information 76 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Publishing to Managed Workspace

    11 Click Commit.

    12 Wait until schema commit has completed (the user interface may appear frozen for an extended period of time).

    Note that after successful commit, there will be two new processed files created in the folder where the modified OpenPlant_3D schema was located.

    Feb-12 77 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Publishing to Managed Workspace

    My Box has been committed into database.

    13 Restart OpenPlant ModelServer - Server windows service to reload schemas into OPMS cache.

    14 Check-in custom cell file with diagrams into PW Workspace\OPModeler\cells folder. Ensure OPM_DIR_WORKSPACE_CELLS variable points to the above folder.

    Additional Information 78 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Publishing to Managed Workspace

    15 Check in custom dgnlib file with toolbar icons into PW Workspace\Projects\OPModeler_Imperial\DataSet\Dgnlibs. Ensure MS_DGNLIBLIST variable points to the above folder.

    16 Open a DGN file from ProjectWise working directory and test placing new component.

    Note: Managed workspace export appears when checking out dgn file.

    Feb-12 79 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Advanced Examples

    Advanced Examples

    This section discusses Advanced Examples accompanying this course material. Example source code and all related files are located in the Examples folder.

    In the examples folder you will find implementation of two advanced components:

    • Multi Diameter Vessel

    • Double Block and Bleed Valve

    The folder contains all required files - the .NET source code, EC schemas, dgnlibs, icon files, diagram cell files and a sample spec database.

    The C# code of the MyBox and MyPipe components used previously is also included in the Examples .NET solution folder for your convenience.

    To import advanced examples into your environment:

    • Step 1 - Build the Examples DLLs from source code

    • Step 2 - Merge EC schemas

    • Step 3 - Deploy diagram cell file

    • Step 4 - Test

    Step 1 - Build the Examples DLLs from source code

    1 Copy the Examples folder to a suitable location on the development machine (e.g. C:\Development\Examples).

    2 Open the Examples.sln file in a development environment of your choice.

    3 Compile.

    Note: If the compilation fails you may need to update reference paths to Bentley libraries located in the OpenPlant assemblies folder and its subfolders. The actual location depends on the exact installation location and windows platform.

    The default locations:

    Additional Information 80 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Advanced Examples

    32-bit windows:

    C:\Program Files\Bentley\OpenPlantModeler V8i\OpenPlantModeler\assemblies\

    64-bit windows:

    C:\Program Files (x86)\Bentley\OpenPlantModeler V8i\OpenPlantModeler\assemblies\

    4 Append workspace variable $OPM_DIR_COMPONENT_ASSEMBLIES to include path to the newly compiled Examples.dll.

    Step 2 - Merge EC schemas

    Merge the class definitions of MultiDiameterVessel and DoubleBlockAndBleedValve into your current development workspace using Bentley Class Editor.

    The source schemas are located in the following 4 files:

    Examples\Resources\schemas\

    OpenPlant_3D.01.02.ecschema.xml

    OpenPlant_3D_Supplemental_Information_3DComponent.01.02.ecschema.xml

    OpenPlant_3D_Supplemental_Modeling.01.02.ecschema.xml

    OpenPlant_3D_Supplemental_ModelingViews.01.02.ecschema.xml

    Refer to section Differencing schemas for more details on differencing schemas and merging changes into workspace schemas.

    Step 3 - Deploy diagram cell file

    1 Copy MultiDiameterVessel.cell from C:\Development\Examples\Resources\cell, to (Operating System Local_Root)\Bentley\OpenPlantModeler V8i\WorkSpace\OPModeler\cells

    Step 4 – Test

    To test Multi Diameter Vessel advanced example:

    1 Launch Open Plant Modeler.

    2 Key-in: mechaddin place MULTI_DIAMETER_VESSEL dsc=EQUIP.

    Feb-12 81 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Advanced Examples

    3 Complete placement.

    4 Change property Section 3 Diameter = 0.

    5 Observe how the number of sections used changed from 4 to 2.

    Explore on your own:

    Examine other parametric properties of the Multi Parameter Vessel. How does changing other parametric properties, e.g. individual sections and transition height and diameter as well as diameter of support ring / support skirt and lower/upper head type change the shape.

    Additional Information 82 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Advanced Examples

    What happens when you change diameters and heights of the individual sections and transitions?

    Experiment with the diameter of the support skirt and the support ring.

    Try changing upper/lower head type.

    Set insulation thickness to a non-zero value. Watch the transition between two sections – can you notice the insulation is offset vertically? Which part of the code calculates this offset?

    How many instances of Datum object do we have? Where are these defined? Add a nozzle to each using nozzle manager.

    How many placement points do we have? Try adding a new placement point at the top of the upper head.

    Examine the draw script code located in MultiDiameterVessel.cs class file and how it is related to the individual properties and dimensional calculations.

    To test the Double Block and Bleed Valve advanced example:

    1 Launch Modeler

    2 In Standard Preferences set Nominal Diameter to 10.

    3 In Standard Preferences select Specification to Select Source….

    4 In Select Spec Source dialog choose Spec Source: OpenPlant Modeler (OPM) and set Specs Location to: C:\Development\Examples\Resources\spec databases.

    5 The list of Specifications has now been refreshed with new list with a single item CS150.

    6 Select Specification = CS150.

    Feb-12 83 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Advanced Examples

    7 Key-in: mechaddin place DOUBLE_BLOCK_AND_BLEED_VALVE dsc=Piping.

    Notice the bleed valve branch port diameter is different than the main and the run port diameters and if you used default placement also the orientation of the branch pipe is facing down instead of up. Compare how this is different from standard Three Way Valve.

    Additional Information 84 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Advanced Examples

    8 Examine CS150.mdb spec records for this valve to understand the branch port property values used.

    9 Examine the EC class definition.

    • Where is the “Double Block and Bleed Valve” located in the EC Schema hierarchy?

    • Which properties are inherited?

    • Which custom attributes are used to define mappings to the table and the columns in the spec database?

    Feb-12 85 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Advanced Examples

    Additional Information 86 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Additional Information

    Joint Implementation

    Users can define different end conditions compatibility with each other and required conditions and fastener for the resulting joint in the Joint EC Class for OpenPlant3D schema.

    1 Open OpenPlant_3D.08.11.ecschema.xml schema in Class Editor and supplement it with OpenPlant_3D_Supplemental_Modeling.08.11.ecschema.xml.

    2 Navigate to the JOINT EC Class from navigation tree of supplemented OpenPlant3D schema.

    Feb-12 87 Additional Information

    Copyright © 2012 Bentley Systems, Incorporated

  • Joint Implementation

    OpenPlant_3D_JointTypeProperties_Map is defined which contains a Joint Type array. Each Joint Type element further contains the JOINT_NAME information, list of compatible end preparations, required fasteners and other properties which should be checked for the joint compatibility. It also contains IS_SPEC_DRIVEN Boolean value to determine whether the required fasteners should be queried form the spec or not.

    The user can expand and collapse the array list by clicking the + or – sign at the start of the list’s name. By right-clicking on any array element the user can get the option of deleting that particular entry from the list. The Add Element option for any array list is given on the right-click menu of Main Array field.

    Every Joint Type element contains following fields.

    JOINT_NAME: Name of the Joint, it should unique among the whole Joint Type array.

    END_PREPARATION_1: Contains the list of end preparations that are compatible with each other.

    MATCH_PROPERTY: Properties other than Nominal Diameter and End Preparation, whose values of both connecting components and fasteners should be checked for joint compatibility. Given is one such example of FLANGE_JOINT, Where FACING and RATING are defined as additional properties which should be same for the matching components and fastener inserted for this joint.

    IS_SPEC_DRIVEN: Contains Boolean values. Leaving it blank or setting to TRUE will force OPM to query the required fastener records from the specs. Setting FALSE, like in the above example for WELDS, its record won’t be queried from the spec at the time of placement.

    Additional Information 88 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Controlling EC Property view behavior

    Controlling EC Property view behavior

    EC Property viewing status in the EC Instance dialog, Element Info and spec grid is controlled by custom attributes defined for those properties modeling views supplemental schema.

    To view or edit such viewing constraints for EC Properties:

    1 Open OpenPlant3D schema in Class Editor and supplement it with OpenPlant_3D_Supplemental_ModelingViews.08.11.ecschema.xml.

    Here the example of EC Property Order Number of Piping Component EC Class is shown. It contains two Custom Attributes – Property Display Status and Category.

    Property Display Status: Used to control visibility and position, has following three fields:

    Element Info Status

    Controls the property view for Element Info dialog

    General Status

    Defines the property view behavior for EC Instance dialog in OPM

    Spec Grid Position

    Defines the EC Property Column position for Spec Grid

    Category: The category is used to categorize the properties in different group panes which are shown in EC Instance dialog. It contains following fields

    Standard

    Contains ‘0’ for all the properties

    Feb-12 89 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Component Creation Setup

    Name

    Contains the Group Pane of EC Instance dialog

    Display label

    Display string for the above defined group pane

    Description

    Description of the above defined group pane

    Priority

    Property position in the group pane

    Expand

    Contains Boolean value to allow user to expand the property in EC Instance dialog if it is of any array type

    Component Creation Setup

    Other than class mapping, information like assigning placement behavior and linking the EC Class to the script class is also defined at this level.

    1 Right-click on the Component class and launch the Custom Attribution dialog.

    2 Add CREATION_ATTRIBUTE and set its location to OpenPlant_3D_Supplemental_Modeling.08.11.

    Here is the example of CREATION_ATTRIBUTE defined for PIPE_BEND EC Class

    Following fields are required:

    Assembly Name: This is a .NET Assembly which contains the script class for the desired EC Class. For shipped components it is always “Bentley.Building.Mechanical.ComponentLibrary”

    Class Name: Name of the Script Class which handles the drawing of component geometry of the EC Class

    Additional Information 90 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Component Creation Setup

    Namespace: Namespace to which that Script class belongs too

    Placement tool: Placement tool class name which defines the required placement behavior for EC Class. (NOT required for fasteners and Seal type components)

    Handler Type: Handler class name which represents the required after placement component manipulation behavior for the EC Class . (NOT required for Fasteners and Seal type components)

    Feb-12 91 Additional InformationCopyright © 2012 Bentley Systems, Incorporated

  • Component Creation Setup

    Additional Information 92 Feb-12Copyright © 2012 Bentley Systems, Incorporated

  • Course Summary

    Course Summary

    Now you will be able to:

    • Create and configure new EC Classes for equipment and Piping from scratch.

    • Code and compile parametric 3D draw script.

    • Debug and inspect your .NET code.

    • Understand the mechanics of retrieving property values from spec based on standard preferences.

    • Add new component tool bar with custom components.

    • Add component schematic diagram into component placement dialog.

    • Publish the changes to both Local workspace or ProjectWise managed workspace.

    Feb-12 93 Course Summary

    Copyright © 2011 Bentley Systems, Incorporated

  • Course Summary

    Course Summary 94 Feb-12Copyright © 2011 Bentley Systems, Incorporated

    Course OverviewCourse DescriptionTarget AudiencePrerequisitesCourse ObjectivesModules IncludedSystem RequirementsSoftware RequirementsImportant Notes:

    Additional InformationModule OverviewModule PrerequisitesModule ObjectivesBest practice to developing scriptsLocal WorkspaceBase workflowLaunching ModelerPlace standard componentKey-inPlace Non-existent ComponentAdd EC ClassAdd CREATION_ATTRIBUTE to Link EC Class to .NET ClassCreate New .NET Assembly from ScratchPublishing .NET Assembly to Local WorkspaceParameterize GeometryDebuggingError HandlingPreview DiagramToolbar IconPlacement PointsDatumMapping EC Class to Spec/Catalogue tableValue MappingProperty mappingPorts & PipingDifferencing SchemasPublishing to Managed WorkspaceAdvanced Examples

    Additional InformationJoint ImplementationControlling EC Property view behaviorComponent Creation Setup

    Course SummaryCourse Summary