4 - Plugin Basics
4 - Plugin Basics
Plug-in Basics
What is a Plugin?
Architecture of Plugin
Implementation
4
Plug-in Types
§ PluginBase
– Like a generic component (Stairs, ladders, truss, etc.)
– Input can be freely defined
§ Any number or type of objects
§ Any number of points
– Can be dependant or non dependant on input.
§ ConnectionBase
– Details (base plate, lifting hooks, etc.)
§ One part & one point
– Connections (clip angle, bracing, welded joints, etc.)
§ One or more secondary parts
Characteristics of Tekla plugins
§ A custom entity in the model (component)
6
Benefits of using plugins
§ Plugins are an extremely powerful way to customize Tekla
Structures
7
Accessing plugins
§ Component Catalog
§ Installed
§ Downloaded
8
Issues to consider before starting
§ Unlike Custom Components, plugins need programming
skills, preferably C#
9
What is a Plugin?
Architecture of Plugin
Implementation
§ Running a plugin
§ Modifying a plugin
– Via user interface or by dependent input object
11
Inserting new plugin into model
§ New Plugin is started
– Constructor method runs
– Input prompted from user
§ Applied values taken from dialog
§ Plugin Run() when input complete
– Both the StructuresData and the Input are stored to the Tekla model database
PLUGIN
User UI (Dialog) .
StructuresData
12
User Interface Data Changed
§ User modifies Plugin UI attributes
– New values are read from dialog
– Dialog data passed to Run code
– Plugin Run() executes with new data
PLUGIN
User UI (Dialog) .
StructuresData
13
Plugin automatically re-runs, input was changed
PLUGIN
User UI (Dialog) .
StructuresData
14
Plugin Updates when needed automatically
§ Plugin works like any system connection: If input objects are
modified or user clicks ’modify’ on the dialog, it re-executes
§ In general, modify works without any extra work
§ Tekla system executes Run() method with modified
parameters (DefineInput() is never re-executed)
§ Plugin is executed just as it was added to the model
– System automatically takes care of modifying existing parts instead
of creating new ones
15
Input and Data are one-way
§ Plugin Run() cannot communicate via the UI
§ Plugin cannot change the content of the StructuresData
stored in the model (e.g. make default values explicit)
§ Plugin is not allowed to modify input objects
– Can lead to an infinite loop
PLUGIN
User UI (Dialog) .
StructuresData
16
Default values and storage
§ Example
– If attribute P1 in the dialog is left blank (default)
– Then default hard coded value is used
> If(IsDefaultValue(P1))
> P1 = 10;
PLUGIN
User UI (Dialog) .
StructuresData
17
Plugin Architecture Summary
§ Two separate sources of input
1. Input objects and points from user selection
2. Dialog Attributes (UI)
– Both are one-way only
– Stored to plugin instance in model database
§ DefineInput() asks user to pick points or objects to interact
with from model
§ Run() code
– does work of plugin
– cannot ask for user input
18
What is a Plugin?
Architecture of Plugin
Implementation
20
Tekla Structures Plugin Fundamentals
§ All plugins need to inherit from Tekla provided base class
21
Available Plugin Types
PluginBase ConnectionBase
§ Like a generic component § Connections (clip angle,
(Stairs, ladders, truss, etc.) bracing, welded joints, etc.)
§ Input can be freely defined – Main part and one or more
– Any number or type of secondary parts
objects § Details (base plate, lifting
– Any number of points hooks, etc.)
§ Can be dependent or non- – Main part and one point
dependent on input
23
Plugin required attribute definitions
[Plugin(“PluginName1")]
- The name in the catalog - Must be unique
[PluginUserInterface(“PluginName1.MainF
orm”)]
- Points to the Form/INP definition of the UI
24
User Meeting 2012 / Iiro Ojala
25
Basic requirements of ConnectionBase
§ StructuresData
– Defines the data that can be passed from the UI
§ Constructor
– Initializes the connection
– Takes the currently applied StructuresData
§ Class attributes
– Define the name, UI, number of secondaries, collision type, auto up direction
§ Base class has one method to implement
– Run()
§ Executes after input has been received
§ Contains plugin’s ”business logic”
§ Input is defined by plugin attributes, and it is managed by Tekla
Structures
26
Connection required attribute definitions
[Plugin("ConnectionName1")]
- The name in the catalog - Must be unique
[PluginUserInterface(“ConnectionName1.MainForm”)]
- Points to the Form/INP definition of the UI
[SecondaryType(ConnectionBase.SecondaryType)]
- The number of secondaries required
- Setting number of secondaries to zero makes it a detail
[AutoDirectionType(AutoDirectionTypeEnum)]
- Auto up direction type
[PositionType(PositionTypeEnum)]
- Connection origin type*
37
Case: Layout Point in Depth
38
Layout Point and Layout Line
§ Included in Tekla Structures installation
§ Purpose is to help modeling field layout inside Tekla model
§ Implemented as Plugin
§ Allows user to create layout points in the Tekla model
§ Layout points can in turn be used as input to Layout Lines
39
Open Applications & components
§ Plugins
§ LayoutPoint and
LayoutLine
40
Layout Point
41
Layout Point
42
Layout Point
43
Layout Point
45
Layout Point
46
Layout Point
47
Layout Point
48
Layout Point
50
Layout Point – Case summary
§ Plugin input definition
– DefineInput() in PluginBase and attributes in ConnectionBase
51
Layout Point – Case summary
§ Utilizes Tekla Plugins and Tekla Model APIs
§ Only a few hundred lines of code
§ Very simple yet powerful plugin
§ Fits a specific need
52
Plugin Basics
Non-dependent plug-ins
Objective
§ Understand the basics of Non-dependent plug-ins
– Definition
– How to execute
§ Understand where to use of Non-dependent plug-ins
§ Difference between Applications and Plug-ins.
How non-dependent plug-ins work?
§ Plug-in dialog is opened from
component catalog and
executed from dialog
§ Values can be applied from
dialog normally
§ Plug-in instance is deleted
after execution
§ Plug-in dialog cannot be
opened from created objects
§ Created objects are saved to
database as native objects
Where to use non-dependent plug-ins?
§ Can be used in tools where a lot of model information needs to
be fetched or set
§ Data is transferred in-process through API, remoting not used
– 20x faster execution when compared to applications
§ Typically used in
– import and export functionality
– Status-checking tools
§ Also useful in tools where model information needs to be
consistent
– Tekla Structures UI is “frozen” during plug-in execution
– External applications cannot modify data during execution
Setup
§ Virtually the same as normal model plug-in
§ Has Run and define input override
§ Receives data the same way from user interface
/// <summary>
/// The plug-in is updated when the input is a point and the point is moved or when the input is an object and the object
/// changes. The plug-in is executed when the input is an object and its properties are changed in the drawing editor.
/// This mode is the default which is used if the update mode is not defined in the plug-in source.
/// </summary>
INPUT_CHANGED = 1,
/// <summary>
/// The plug-in is updated also when a drawing is opened.
/// The plug-in is executed when the input is changed or during drawing opening.
/// </summary>
DRAWING_OPENED = 2
65 [Date] [Subject / Author, edit by clicking Insert > Header & Footer]
Tekla Open API
Dialog basics
§ Tekla Open API: Plug-ins & Dialogs
Objective
§ Understand the basics of Dialogs
– Attribute binding.
– Use of Distance/DistanceList
§ Understand the use of UIControls
– How the controls work.
§ Difference between Applications and Plug-ins.
§ Difference between INP and Forms dialogs.