SmartPlant P&ID Visual Basic Guide
SmartPlant P&ID Visual Basic Guide
V4.3
AUTOMATION
PROGRAMMING
USING
VISUAL BASIC
COURSE GUIDE
SmartPlant P&ID Automation Programming
1. OBJECTIVES
Visual Basic is an extension of the BASIC programming language utilizing the object-oriented
technology.
OLE (Object Linking and Embedding) Automation further specifies interfaces that
manipulate an application’s objects from outside of the application.
[Link] structures
2
SmartPlant P&ID Automation Programming
Do …Loop While
Do…Loop Until
Do While …Loop
Do Until …Loop
For … Next
IF … THEN
[Link] concatenation
[Link] feature
Place the cursor on a keyword and press the F1 key to obtain help on the
keyword
The Err object and its properties: Number, Description, Source, Clear, Raise.
3
SmartPlant P&ID Automation Programming
Select File->Make->…
4.1. Toolbox
4
SmartPlant P&ID Automation Programming
The Object Browser can be opened from the Standard Toolbar or from the View command on
the menu. The Object Browser is used to examine the methods and properties of the classes
in object libraries.
The Immediate, Locals, and Watch Windows can be opened from the Debug Toolbar or from
the View command on the menu. These windows are used to examine the values of
variables and objects at run time.
4.6. References
5
SmartPlant P&ID Automation Programming
4.7. Components
The Project/Components… command pulls up a dialog to select the ActiveX components that
can be included into the current project. ActiveX components can be used to provide user-
interface and code level functionalities to the project.
Set compatibility.
5.1. Controls
Controls can be added to the project by dragging onto a form from the Toolbox.
5.2. Forms
5.3. Procedures
Always use the keywords Option Explicit at the top of every module. This will
ensure that variables are always defined before they are used.
6
SmartPlant P&ID Automation Programming
5.5. DataTypes
Variants hold all datatypes but not objects. A variant can have a NULL value,
indicating that it is undefined.
6.1. Project
A Project consists of all of the form modules, standard modules, class modules,
controls, references, and settings required to compile and run the application.
7
SmartPlant P&ID Automation Programming
7. OBJECT-ORIENTED CONCEPTS
7.1. Object
An object is a collection of data with related functions and subroutines that can be grouped as
a single unit.
7.2. Class
A class is a template for an object. It contains the structure and definitions of all
of the parts of an object.
A class is terminated when the object instance of the class is set to nothing. Eg:
set obj1 = Nothing
The name of the class can be edited in the Property Box for the class module.
This name can be different from the filename under which the class module is saved.
Methods and Properties of a class are those variables and procedures that
cannot be accessed other than within the context of an object instance of the class.
The methods and properties of a class are accessed using the dot (.) extension
to the class name. For instance, if the class Object1 has a property called Name and
obj1 is an object instance of that class, then the property can be accessed using the
syntax [Link].
8
SmartPlant P&ID Automation Programming
The Get procedure returns the value of the property and is called when the code
is reading the value of the property such as in [Link] [Link]
The Let procedure is called by VB when the property value is being assigned a
value in the code. Eg. [Link] = “Object 1”
A Set procedure is just like the Let procedure, except that it is used associate an
object variable to an object. In this case the Set keyword must be used. Eg. set obj1
= New Object1
Sample Code:
Public Property Let Name(vdata As String)
strname = vdata
End Property
Events of a control are suffixed into the name of the control with an underbar (_).
Eg. Command1_Click() is the Event method for the Click event of the Command1
command button.
8. CREATING CLASSES
Class modules contain code that define the properties and methods of the class.
Classes can be created using the Class Builder Utility under the Add-in Manager.
9
SmartPlant P&ID Automation Programming
Properties and Methods can be added using the Class Builder Utility or they can
be manually edited into the class module.
9. LAB
10. REVIEW
10
SmartPlant P&ID Automation Programming
1. OBJECTIVES
2. INTRODUCTION
A client application is code that accesses the properties and methods of other Automation
objects.
The Object Variable must be declared using the ProgID of the object. The ProgID is made up
of the ProjectName and the ClassName concatenated with the dot (.) symbol. Eg.
“[Link]”
Standard applications, such as MS Word and MS Excel, can provide Automation objects that
can be accessed by client applications.
Client applications get information about Automation objects through the type libraries
associated with the Automation object. Type libraries provide information about the
Interfaces supported by the object, descriptions of the properties, methods, and events
provided by the object, the return types and parameter types of the methods and events, etc.
This information for Active-X components can be viewed through the Object Browser.
The structure of the inter-relationships of objects within the type library is depicted by the
Object Models.
11
SmartPlant P&ID Automation Programming
5. LAB
Optional Lab 4: Write VB client application to access Microsoft Excel’s Automation objects.
6. REVIEW
12
SmartPlant P&ID Automation Programming
1. OBJECTIVES
Active-X server components are libraries of objects that can be used by client components.
Create functions and properties (defined in the abstract class) in the new class.
Compile the component or run the VB project to register the class for debugging.
5. LAB
6. REVIEW
13
SmartPlant P&ID Automation Programming
1. OBJECTIVES
Active-X server components with an interface in the Visual Basic (6.0) development
environment.
Active-X server components are libraries of objects that can be used by client components.
3. INTERFACES
Interfaces are abstract classes. Abstract classes act as templates because they provide
function and property definitions without any implementations.
Interfaces allow objects to grow in functionality without breaking the earlier functionalities, as
long as they continue to implement the original interfaces.
Create a class module with the name of the abstract class and interface.
Compile the code or run the VB project to register the class for debugging .
14
SmartPlant P&ID Automation Programming
Create an Active-X dll project that references the abstract class created above.
Use the ‘Implements’ keyword followed by the name of the abstract class inside
the implementation class module. This class then implements the interface described by
the abstract class.
Implement the functions and properties (defined in the abstract class) in the new
class.
Compile the component or run the VB project to register the class for debugging.
Create a standard executable which references the abstract class and the
implementation class.
Set the abstract class variables to point to the existing implementation class
objects.
The functionalities available at each object depends on its class definition, even
though they point to the same object.
5. LAB
6. REVIEW
15
SmartPlant P&ID Automation Programming
1. OBJECTIVE
Every software works with data using methods or routines. Data and methods can be
grouped to form self-contained objects that interact with other objects.
A class is a template for an object. Multiple objects of a given class can be used in a project.
A project may also include a number of different classes. These classes can be related to
one another. The relationship among the classes represents the Data Model.
The Static Data Model describes the nature and inter-relationships of the various classes in a
project. The Data Model can be represented as a Class Diagram using Unified Modeling
Language (UML). UML is an emerging language for creating models of object-oriented
computer software.
16
SmartPlant P&ID Automation Programming
The topmost compartment contains the name of the class. Typically, the second
compartment lists the attributes of the class, and the third compartment lists the
operations. Normally, only relevant attributes and operations are listed in these
compartments for space considerations.
3.2. Relationships
Object classes in the Data Model are normally related to other object classes.
The direction of the open arrow indicates the direction of the navigation. The
object class that maintains the information about the relationship is at the base of the
arrow.
Instances of both objects must exist before the relationship can be created.
In the inheritance relationship, the arrow is at the parent object, which is the
superclass.
The child object, the sub-class, derives from the parent class and inherits all of
the attributes and operations of the parent class.
The sub-class is a more specific kind of the superclass. The derived classes
retain pointers to their parent classes.
Diamonds indicate Parent-Child relationships. The entity with the diamond is the
Parent.
The child exists only if the parent exists. For example, a Nozzle must have a
parent Equipment. If the parent Equipment is deleted, the child Nozzle cannot exist.
3.2.4. Text
The text on the relationship line shows the nature of the relationship.
17
SmartPlant P&ID Automation Programming
3.2.5. Numbers
Numbers at the ends of the relationship line indicate “multiplicity” or the number
of instances of the respective object class that can exist in the relationship. For
instance, the numbers between ModelItem and Representation indicate that one
ModelItem may be related to (associated with) multiple (0…*) Representations.
Some ModelItems do not have any representations (0), while some can have multiple
representations (*).
4. REVIEW
18
SmartPlant P&ID Automation Programming
1. OBJECTIVES
interpret the Logical Model Automation classes and properties from the Data Model
2. INTRODUCTION
The Logical Model Automation (Llama) is primarily an object model based on the SmartPlant
P&ID DataModel. In order to facilitate proper use of Automation, Llama also incorporates some
non-DataModel items.
Each object class in the DataModel has two Visual Basic (VB) classes. The first
represents the object class while the second represents a collection of the object class.
The names of these classes are prefixed by an “LM”. The LM stands for the Logical
Model. For example, the PipeRun object class in the DataModel has two classes,
namely LMPipeRun and LMPipeRuns, in VB.
Llama does not provide classes for the *Join objects. These objects contain
connection informaton for a many-to-many relationship between two object classes. For
instance, the PlantItemGroupJoin object class holds connection information between the
PlantItem and PlantItemGroup object classes, which are related through a many-to-many
relationship. Llama provides this information in the same way that it supports
relationships. This will be discussed in the section on Relationships.
Certain relationships shown in the Data Model are not implemented in SPPID.
For instance, the relationship between Nozzle and PipeRun and the many-to-many
relationships indicated by the PipeRunJoin and SignalRunJoin tables are currently not
implemented.
3.2. Attributes
19
SmartPlant P&ID Automation Programming
Although many objects may use similar attributes (e.g. SP_ID), the attributes of
an object are unique.
Attributes from the DataModel are implemented in three different ways in Llama,
depending on the datatypes of the attribute. These are the simple datatypes, the
enumerated datatypes, and the unitted datatypes.
The simple datatype attributes, such as string, date, long, etc, are implemented
as standard Properties of the VB class.
The Let and Get functions are typically defined for the Property, enabling the VB
user to both assign the value and to read the value.
The enumerated attributes are codelisted attributes. Each codelist has a number
(an integer part) and a name (a string part) and these are listed in the ‘Enumerations’
table in the DataDictionary. The members of each codelist are listed in the ‘codelists’
table in the DataDictionary. They have a set of predefined values with corresponding
indices for each valid value. The values and the indices together form the codelist
associated with the attribute.
In Llama, the enumerated attributes are named after the codelists that they
represent.
Each enumerated attribute has two Properties associated with it in Llama. One
has the name of the attribute, and it can be used to either get or set the name (string
part) of the value. The other has the name of the attribute suffixed with the word
“Index”, and can be used to get or set the integer part (index) of the value. The index
zero (0) indicates a null value.
[Link] Attributes
They are composed of a numeric value and a text string depicting the unit of
measure. The numeric value is an arbitrary number selected by the user, but the unit
of measure must be recognized by SmartPlant P&ID as one of the defined formats.
In Llama, the unitted attribute has two Properties associated with it. One has the
name of the attribute, and it is the concatenation of the floating point value and the
unit of measure as a single string. It can be used to set and get the value of the
attribute in string form. The other property has the name of the attribute suffixed with
20
SmartPlant P&ID Automation Programming
the word “SI” and it yields the numeric value converted into the SI units for that
quantity. This latter function is read-only and has only the Get part of the property.
3.3. ItemAttribution
The relationship between objects allow objects to own attributes that are unique
to other objects through various relationships. These derived attributes are part of the
‘Item Attributions’ of that item.
An association relationship between two items can permit one or more attributes
of one class to be Item Attributes of the other. These Item Attributes have to be explicitly
added in order for the attribute to be available from the object. The relationship between
Case and ModelItem allows Equipment to have some Case attributes in its
ItemAttributions list because of the ItemAttributions created between the two classes.
However, other object classes that inherit from ModelItem do not have to own the same
Case attributes and therefore do not have these attributes as part of their itemAttributions
list.
The ItemAttribution name is generally based on the path used to navigate to the
property from a given item. However, this format is not a requirement. The only
requirement is that the name must be unique for a given object class.
Item Attributions not directly owned by the item are maintained in memory for
performance reasons. Starting V3.0, first time user tries to access these Item Attributions
will make these Item Attributions available for the object, no special trigger is needed. In
addition, if user get the object using PIDDatasource, then all Item Attributions will be in
the collection by default.
21
SmartPlant P&ID Automation Programming
3.4.
3.5. Relationships
[Link]-to-Many Relationship
In the item on the many end of the relationship, there is a property that returns
the unique item that it is related to. In the above example, the LMNozzle has a
property that returns the EquipmentObject that it is related to.
[Link] Relationship
[Link]-to-Many Relationships
22
SmartPlant P&ID Automation Programming
[Link] Relationships
Llama provides a property that returns a collection of the ‘many’ object in the
group relationship. Although some parent-child relationships have a one-to-one
relationship or even a one-to-none relationship, a collection is still provided. For
example, the PipingComp and InlineComp have a parent-child aggregation
relationship with multiplicity of 0..1. This implies that an InlineComp can have at most
one PipingComp parent and the PipingComp can have at most one InlineComp child.
Although the latter condition suggests a single InlineComp for a PipingComp, Llama
still supports a property that returns a collection of LMInlineComps for a given
PipeRun. This collection may contain only one object, consistent with the multiplicity
of the relationship.
In addition to the object classes provided in the DataModel, Llama provides some additional
classes to enable the use of Automation.
4.1. LMADatasource
The three properties IPile, Pile, and PIDMgr have non-Llama return types and
can be used to get the connections to the Data Coordinator and PIDObjectManager or to
23
SmartPlant P&ID Automation Programming
set the connections to existing connections. The typical Llama user will not have to use
any of these properties. These are for advanced uses.
4.2. Labs
4.3. LMAItem
Every LMAItem represents the object class it was converted from. Typically, one
would use the ItemType to determine the type of item to ‘get’ from the datasource. For
instance, LMVessel as an LMAItem will yield an ItemType of ‘Vessel’ while the same
vessel item when retrieved as an LMEquipment and then converted into LMAItem will
yield an ItemType of ‘Equipment’. However, this is not TRUE anymore since V4. In V4,
all model item object will be obtained in its concrete level. For example, even retrieved as
n LMEquipment, its ItemType is “Vessel”. In addition, the object will have all
ItemAttributions collection as its concrete object.
4.4. LMAAttribute
Additional properties such as Index and SIValue are applicable for enumerated
(codelisted) and unitted (formatted) attributes, respectively.
4.5. Labs
24
SmartPlant P&ID Automation Programming
Lab 7: Rollback.
Lab 8: Propagation.
4.6. LMACriterion
The LMACriterion is an object class that is typically used with the LMAFilter class.
A criterion relates an attribute with a value. The criterion can be fully defined by
setting values for at least three properties, namely SourceAttributeName, ValueAttribute,
and Operator.
The ValueAttribute is the value of the attribute, it also can be a string containing a
symbol such as “%”,”_” etc.
The Operator indicates the relationship between the attribute and its value. The
operator is a string containing a symbol such as “=”, “<”, “>=”, “like”, “is” etc.
The Conjunctive must be set to True if this LMACriterion must be AND-ed with
other LMACriterions.
4.7. LMAFilter
25
SmartPlant P&ID Automation Programming
If a Criterion is deleted from the list, the counter key is renumbered but the list
maintains the same sequence.
4.8. LMAEnumAttList
4.9. LMAEnumeratedAttribute
5. GENERAL ISSUES
Property Count: returns the number of items in the collection. For an empty
collection, the Count is zero.
Property Item(ID as long): returns an item of the type that this collection holds.
The argument is the IndexKey of the item. The IndexKey is generally the SP_ID of the
item. If the IndexKey is wrong, the returned item is a Nothing.
Property Nth(index as long): selects the item in the sequence that it is stored in
the collection.
26
SmartPlant P&ID Automation Programming
Property Datasource: returns the Datasource that was used to create the
collection. This is important when a number of datasources are in use, each pointing to
different plants or databases.
Property TypeName As String: Returns the item type name of the items in the
collection.
Sub Remove(ID as long): removes the item with the given ID, if it exists in the
collection.
Sub AddCollection(Items As …): Add all items from the indicated collection into
the current collection.
Function Add([Item As …]) As …: Adds an item to the collection. Note that the
argument and the return value are of the added Llama object.
6. LABS
Lab 14: Access items using filters with criterion on Select List Data.
7. REVIEW
27
SmartPlant P&ID Automation Programming
1. OBJECTIVES
the general structure of the SmartPlant P&ID Data Model and its implementation in the Llama
object model
highlights the relationships between the classes that need additional attention
2. INTRODUCTION
The objects exposed through Llama span all the three schemas used in the database. Objects in
each grouping may come from different schemas. However, the object model relationships allow
the user to access the related objects and obtain the appropriate properties without being
concerned about the schema they belong to. Therefore, the most important task for the user of
Automation is fully understand the various relationships between objects. This chapter addresses
some objects and relationships that requires special attention from the user.
3. MODEL DATA
The Model Data maintains the engineering data. It is centered around the ModelItem and the
PlantItem, which is also a ModelItem. Refer to the Data Model diagram for the relationships
between the various objects. This section describes only the specially noteworthy and the not-so-
obvious characteristics of the objects.
3.1. ModelItem
The ModelItem can own one or more instances of Alias, History, Event, Note, Source, and
Status. In addition, it can own one or more Representations from the Drawing Data Model.
Currently the software creates History records of HistoryType ‘Creation’ and ‘Last
Modification’. The user should not modify any of the History records maintained by the
system nor create new ones of these types. However, the user can create new History
records of a different type after creating new types in the datadictionary, if necessary. The
Automation user can also create new instances of Alias, Event, Note, Source, and Status.
28
SmartPlant P&ID Automation Programming
In addition, a ModelItem can own one or more Cases. These Cases are maintained by the
software using the information provided in the DataDictionary and the ItemAttributions. The
Automation user should not attempt to add new Cases, CaseProcesses, or CaseControls
through code.
The ModelItem is the superclass from which all other Model Data classes are derived. The
immediate subclasses of the ModelItem are the ItemNote, PipingPoint, PlantItem,
SignalPoint, and OPC. Of these, the most significant is the PlantItem.
3.2. Labs
29
SmartPlant P&ID Automation Programming
3.3. PlantItem
Most items that are placed on drawings can be traced back to PlantItem. Subclasses of the
PlantItem are Equipment, Nozzle, PipingComp, Instrument, Pipeline, Piperun, SignalLine,
SignalRun, and PlantItemGroup.
Returns the PlantItem that this current PlantItem is a Part Of. Examples are implied
items, TEMA ends, and trays. An implied item is related to its parent item through this
relationship. It also has a PartOf type = ‘Implied’. A TEMA end is a part of the TEMA
Shell that it is placed on and has a PartOf type = ‘Composite’. Although a tray is a
legitimate part of the vessel it is placed on, it does not have a PartOf type value. The
value is NULL for a tray.
30
SmartPlant P&ID Automation Programming
[Link]
Optional Lab 10: Find Implied Items and Modify Their Property
31
SmartPlant P&ID Automation Programming
32
SmartPlant P&ID Automation Programming
[Link] – InlineComp
Every PipingComp has an associated InlineComp. The PipingComp owns its associated
InlineComp. However, only the InlineComp has the information about the PipeRun that
the PipingComp resides on.
[Link] – InlineComp
[Link]
33
SmartPlant P&ID Automation Programming
4. DRAWING DATA
The Drawing Data Model maintains the graphical representation data. It is centered around the
Drawing and the Representation objects.
34
SmartPlant P&ID Automation Programming
4.1. Drawing
Drawing object can own one or more History, Status and Note. Currently the software creates
History records of HistoryType ‘Creation’ and ‘Last Modification’. The user should not modify
any of the History records maintained by the system nor create new ones of these types.
35
SmartPlant P&ID Automation Programming
4.2. Representation
4.3. LabelPersist
For labels on Symbol, the label is labeling the Symbol. However, for labels on PipeRun,
actually the label is labeling the Connector.
4.3.1. Labs
4.4. Symbol
36
SmartPlant P&ID Automation Programming
Symbol, and Branch. ‘Gap’ stands for a gapping symbol placed at the junction of crossing
runs. An ‘OPC’ type representation is placed for OPC ModelItems. Typically, most other
items have a Symbol representation of RepresentationType, ‘Symbol’. A branch point on a
PipeRun or a SignalRun produces a Symbol of RepresentationType, ‘Branch’. The ‘Branch’
symbol behaves just like a regular symbol.
4.4.1.Connect1Connectors
4.4.2.Connect2Connectors
4.4.3. ConnectorVertices
A collection of Connector Vertex that holds graphic information for the Connector, such
as X, Y Coordinates of the Connector. Pay special attention, X, Y Coordinates are not
necessary always stored in the Connector Vertex, sometimes, depending on how the
Connector is drawn, the Symbol connected with the Connector holds such information.
4.5. Connector
Each connector has two end points, namely the End1 and End2. The ends are named 1 and
2 in the direction that the connector was drawn. Each connector can be attached to a symbol
on each of the two ends.
This is the symbol representation to which the End1 of this current connector is attached.
This is the symbol representation to which the End2 of this current connector is attached.
37
SmartPlant P&ID Automation Programming
4.6. BoundedShape
4.7. Labs
5.1. Relationship
(1) Two graphics are connected. Example: PipeRun connected to Valve, Nozzle on a Vessel.
(2) When a symbol is placed that has piping points or signal points.
38
SmartPlant P&ID Automation Programming
Relationship Model
5.2. Labs
5.3. PlantGroup
PlantGroup is a superclass with eight subclasses, namely Site, Plant, Unit, BusinessSector,
Level, PlantSystem, SubSystem and Area. These are designated by PlantGroupTypes
enumerated list in the DataDictionary. Unlike all other objects in the SPPID data model, new
subclasses can be added to PlantGroups. These classes are persisted as tables with a
‘SPM’ prefix after the prefix ‘T_’. For example, a user-defined PlantGroup SubArea
corresponding table is T_SPMSubArea. These objects can be obtained as generic LMAItems.
For instance, if SubArea is a user-defined PlantGroup that was included into a hierarchy and
used in a plant structure, then the following code can be used to access the SubArea that has
an ID=”SP_ID”:
Dim objItem As LMAItem
Set objItem = [Link]("SPMSubArea", "SP_ID")
The attributes of the SubArea will need to be obtained through the Attributes collection
because they are user-defined.
ParentID returns the ID of the Parent PlantGroup of the current PlantGroup. It returns a
negative 1 (-1) if it is the top-most item in the hierarchy. The ParentType is a number
describing the type of the Parent PlantGroup.
[Link]
[Link]
A collection of PlantItems that have been associated with this PlantGroup. One example
is when an Equipment Vessel is associated with a Unit. The Equipment would then
appear in the Unit’s PlantItems collection.
39
SmartPlant P&ID Automation Programming
[Link]
[Link]
Plant Hierarchy
5.4. Workshare
Workshare may be set up to share SPPID data among multiple locations or to have a
Task/Master Plant. Workshare entities are created in PLANT schema. LLAMA is aware of the
workshare. For example, if user tries to modify a property of an item that read-only because
of workshare, the modification will not be persisted to database. However, there is no public
interface exposed in LLAMA that user can check such as ownership of a drawing, or user’s
access right.
[Link]
Every plant, by default, is a workshare site. User can create multiple satellite workshare
sites in the plant.
40
SmartPlant P&ID Automation Programming
[Link]
This is a join table between T_WSSite table and T_Drawing table. Through this table,
drawing knows who is it owner workshare site, and workshare site knows how many
drawings belongs to it.
[Link]
A plant may have multiple workshare sites, but it can have only one active workshare
site.
[Link]
A table contains plant item group information that related to a workshare site.
[Link]
[Link]
[Link]
41
SmartPlant P&ID Automation Programming
Workshare Model
5.5. As-Build/Project
[Link]
Every plant, by default, is The Plant. Then, User can create multiple projects in the plant.
[Link]
The current in-use project is the active project. User can access active project through
[Link] function. It can be The Plant or projects.
[Link] Status
Project status is a select list data with following lists: Active, Completed, Merged,
Finished, Cancelled, Terminated, None, Deleted. The Plant status is None. Projects can
have different statuses.
[Link] Status
In As-Build/Project environment, an item can have different claim status: Not Claimed,
Claimed by active project, and Claimed by Others.
[Link]
42
SmartPlant P&ID Automation Programming
Project Model
Since V4, all model item object will be obtained in its concrete level. For example, even
retrieved as n LMEquipment, its ItemType is “Vessel”. In addition, the object will have all
ItemAttributions collection as its concrete object.
43
SmartPlant P&ID Automation Programming
1. OBJECTIVES
2. PLAICE LIBRARY
DrawingID: SP_ID of drawing, the item will be created in its stockpile. If user leaves it blank,
by default, value is 0, which means plant stockpile. If you user specify a valid drawing SP_ID,
the item will be created in that drawing’s stockpile.
44
SmartPlant P&ID Automation Programming
TargetItem is specified, given X, Y coordinates may be ignored, software will locate a new X,
Y coordinates for the symbol to be located on the edge of TargetItem, if PIDSnapToTarget is
set to TRUE)
Points(): a dynamic array, specifies the X, Y coordinates for Label to be placed on drawing
45
SmartPlant P&ID Automation Programming
SurvivorItem: When two piperuns auto joined, one piperun will disappear while the other will
survive, the survived one is the SurvivorItem.
46
SmartPlant P&ID Automation Programming
[Link]
47
SmartPlant P&ID Automation Programming
2.16. Datasource
2.17. PIDSnapToTarget
2.18. SetCopyPropertiesFlag
Property specifies the properties to be copied or not as defined in the Rule across the Items
that are connected.
2.18.1. Labs
48
SmartPlant P&ID Automation Programming
2.19. Datasource
(when specifies the OriginalItem and DestinationItem, the first point’s and last point’s X, Y
coordinates will be ignored)
(When placing a connector to a symbol, how to control which connect point on symbol the
connector should be connected? Instead of using OriginIndex and DestinationIndex,
49
SmartPlant P&ID Automation Programming
specifying the X, Y coordinate for connector point you wish to connect with in Points(), which
will make the connector to connect the connect point of the symbol)
3. MISC.
When placing a piping component on a piperun connector, the original connector is given an
ItemStatus of ‘Delete – Pending’ or ItemStatusIndex = 4 and two new connectors are created.
When placing the next item on the connector, you cannot use the reference to the original
connector because it is no longer valid. We have to find the two new connectors and then
use their references. This can be achieved by looking at the symbol placed and finding the
item1connectors or item2connectors.
When place a Gap on a piperun, the symbol does not break the original connector either. It
creates two more new connects and sits on the top of the piperun. When user select not to
see the Gap, the Gap along with two connectors it created will go to hidden layer and original
connector is showing.
4. LABS
50
SmartPlant P&ID Automation Programming
1. OBJECTIVES
2.1. [Link]
DocumentTypeValue: Optional argument, select list value for document type, default value is
631 stands for P&Ids
DocumentCategoryValue: Optional argument, select list value for document category, default
value is 6 stands for Piping Documents
BVisible: Optional argument, Boolean value as True or False for the visibility of drawing when
opening, default as True
2.2. [Link]
51
SmartPlant P&ID Automation Programming
Visible: Optional argument, Boolean value as True or False for the visibility of drawing when
opening, default as True
2.3. [Link]
SaveFile: Boolean value as True or False to save drawing when closing drawing.
3. LABS
52
SmartPlant P&ID Automation Programming
1. OBJECTIVES
2. ILMFOREIGNCALC INTERFACE
The ILMForeignCalc Interface supports four functions that are called by SmartPlant P&ID at
specific events. This interface is supplied in the LMForeignCalc library. IMPLEMENTS
ILMFOREIGNCALC statement incorporates this interface into the Active-X component. The
functions are described below:
2.1. DoCalculate
It is activated only if the ProgID of the class has been entered into the Calculation
ID field of the property in the DataDictionary Manager.
SPPID triggers a call to the function when the user clicks on the ellipsis button on
the Property Grid next to the relevant property.
2.2. DoValidateItem
It is activated only if the ProgID of the class has been entered into the Validation
Program field of the Database Item Type in the DataDictionary Manager.
SPPID triggers a call to the function when the user place a new item, copy and
paste and existing item, and delete and item to/from drawing
53
SmartPlant P&ID Automation Programming
SPPID triggers a call to the function when the user de-selects from the item after
changing some property associated with the item.
The various contexts for the triggering are listed by the enumerated variable
LMForeignCalc.ENUM_LMAValidateContext, which has values of LMAValidateCreate,
LMAValidateCopy, LMAValidateDelete, LMAValidateModify and LMAValidateFiltered**.
The call is made to this function generally after every relationship has been
created and the rules have been executed.
2.3. DoValidateProperty
It is activated only if the ProgID has been entered into Validation ID field of the
property in the DataDictionary Manager.
SPPID triggers a call to the function when the user de-selects from the relevant
property after having modified it.
The call is made to this method before SPPID accepts the user’s entry into the
memory.
2.4. DoValidatePropertyNoUI
It is activated only if the ProgID has been entered into Validation ID field of the
property in the DataDictionary Manager.
SPPID triggers a call to this function when a rule modifies the property, such as
at placement time.
3.1. LMADataSource
54
SmartPlant P&ID Automation Programming
3.2. LMAItems
3.3. PropertyName
4. SPECIAL ISSUES
In order to update the value seen through the Property Grid, it is necessary to set the value of
the ‘Value’ variable and to return a TRUE for the Boolean return value of the ILMForeignCalc
functions. If the return value is FALSE (default), then it is assumed that the operation was not
a success and the old values are retained in the property grid.
A Commit command must be issued to the object in question if the changes to its properties
other than the property being validated are to be made persistent.
When user uses automation program to update a property, if the property has a validation
ProgID in its validation ProgID field, the validation will be automatically called up. For
example, when user update the Vessel’s prefix to “P” and commit the change, then validation
will be fired up to generate a new item tag for Vessel if the property TagPrefix has a validation
ProgID in its validation ProgID field.
5. LABS
55
SmartPlant P&ID Automation Programming
56
SmartPlant P&ID Automation Programming
1. OBJECTIVES
the special issues relevant to use LMAutomationUtil to get from/to information for Piperun.
2. IMPORTANT METHODS
2.1. RunsNavigation
2.2. RunsNavigationAll
57
SmartPlant P&ID Automation Programming
BucketType: data type as LONG, 1 means From, 2 means To, 3 means BiDir
Connected_FlowDirection: data type as LONG, code list index value of FlowDirection of the
piperun that is reported as from/to item
Connected_OPC_DrawingNumber: data type as string, if From/to item is OPC, and this OPC
has pair OPC on a drawing, then the Drawing Number of that drawing where its pair is sitting
on.
Equipment_ItemTag: data type as string, if from/to item is NOZZLE, then the itemtag of the
Equipment the Nozzle is on.
Equipment_SP_ID: data type as string, if from/to item is NOZZLE, then the SP_ID of the
Equipment the Nozzle is on.
PipeRun_FlowDirection: data type as LONG, code list index value of FlowDirection of the
piperun that is running from/to report
PipeRun_ID: data type as string, SP_ID of FlowDirection of the piperun that is running from/to
report
3. LABS
58