You are on page 1of 73

AVEVA Marine

(12.1)

TRAINING GUIDE
PML for Marine Drafting

TM-2401

www.aveva.com
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

www.aveva.com
© Copyright 1974 to current year. 2
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

Revision Log
Date Revision Description of Revision Author Reviewed Approved
15/06/2012 0.1 Issued for Review MZA

Updates
In general, all headings containing updated or new material will be highlighted. However, highlighting has
not been employed at Revision 1.0 as this is the intial release of this training guide.

Suggestion / Problems
If you have a suggestion about this manual or the system to which it refers, please report it to AVEVA
Training & Product Support (TPS) at tps@aveva.com

This manual provides documentation relating to products to which you may not have access or which may
not be licensed to you. For further information on which products are licensed to you please refer to your
licence conditions.

Visit our website at http://www.aveva.com

Disclaimer

1.1 AVEVA does not warrant that the use of the AVEVA software will be uninterrupted, error-free or free
from viruses.

1.2 AVEVA shall not be liable for: loss of profits; loss of business; depletion of goodwill and/or similar losses;
loss of anticipated savings; loss of goods; loss of contract; loss of use; loss or corruption of data or
information; any special, indirect, consequential or pure economic loss, costs, damages, charges or
expenses which may be suffered by the user, including any loss suffered by the user resulting from the
inaccuracy or invalidity of any data created by the AVEVA software, irrespective of whether such losses are
suffered directly or indirectly, or arise in contract, tort (including negligence) or otherwise.

1.3 AVEVA shall have no liability in contract, tort (including negligence), or otherwise, arising in connection
with the performance of the AVEVA software where the faulty performance of the AVEVA software results
from a user's modification of the AVEVA software. User's rights to modify the AVEVA software are strictly
limited to those set out in the Customisation Manual.

1.4 AVEVA shall not be liable for any breach or infringement of a third party's intellectual property rights
where such breach results from a user's modification of the AVEVA software or associated documentation.

1.5 AVEVA's total liability in contract, tort (including negligence), or otherwise, arising in connection with the
performance of the AVEVA software shall be limited to 100% of the licence fees paid in the year in which the
user's claim is brought.

1.6 Clauses 1.1 to 1.5 shall apply to the fullest extent permissible at law.
www.aveva.com
© Copyright 1974 to current year. 3
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

1.7. In the event of any conflict between the above clauses and the analogous clauses in the software
licence under which the AVEVA software was purchased, the clauses in the software licence shall take
precedence.

Trademarks

AVEVA and Tribon are registered trademarks of AVEVA Solutions Limited or its subsidiaries. Unauthorised
use of the AVEVA or Tribon trademarks is strictly forbidden.

AVEVA product/software names are trademarks or registered trademarks of AVEVA Solutions Limited or its
subsidiaries, registered in the UK, Europe and other countries (worldwide).

The copyright, trademark rights, or other intellectual property rights in any other product or software, its
name or logo belongs to its respective owner.

Copyright

Copyright and all other intellectual property rights in this manual and the associated software, and every part
of it (including source code, object code, any data contained in it, the manual and any other documentation
supplied with it) belongs to, or is validly licensed by, AVEVA Solutions Limited or its subsidiaries.

All rights are reserved to AVEVA Solutions Limited and its subsidiaries. The information contained in this
document is commercially sensitive, and shall not be copied, reproduced, stored in a retrieval system, or
transmitted without the prior written permission of AVEVA Solutions Limited. Where such permission is
granted, it expressly requires that this copyright notice, and the above disclaimer, is prominently displayed at
the beginning of every copy that is made.

The manual and associated documentation may not be adapted, reproduced, or copied, in any material or
electronic form, without the prior written permission of AVEVA Solutions Limited. Subject to the user's rights,
as set out in the customisation manuals to amend PML software files contained in the PDMSUI and
PDMSLIB folders and any configuration files, the user may not reverse engineer, decompile, copy, or adapt
the software. Neither the whole, nor part of the software described in this publication may be incorporated
into any third-party software, product, machine, or system without the prior written permission of AVEVA
Solutions Limited, save as permitted by law. Any such unauthorised action is strictly prohibited, and may
give rise to civil liabilities and criminal prosecution.

The AVEVA software described in this guide is to be installed and operated strictly in accordance with the
terms and conditions of the respective software licences, and in accordance with the relevant User
Documentation. Unauthorised or unlicensed use of the software is strictly prohibited.

Copyright 1974 to current year. AVEVA Solutions Limited and its subsidiaries. All rights reserved. AVEVA
shall not be liable for any breach or infringement of a third party's intellectual property rights where such
breach results from a user's modification of the AVEVA software or associated documentation.

AVEVA Solutions Limited, High Cross, Madingley Road, Cambridge, CB3 0HB, United Kingdom.

www.aveva.com
© Copyright 1974 to current year. 4
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Contents

1 Introduction .............................................................................................................................................. 7
1.1 Aim..................................................................................................................................................... 7
1.2 Objectives ......................................................................................................................................... 7
1.3 Prerequisites .................................................................................................................................... 7
1.4 Course Structure .............................................................................................................................. 7
1.5 Using this Guide............................................................................................................................... 7
2 Basic Programming Interface ................................................................................................................. 8
2.1 MarAPI assembly, documentation and method testing ............................................................... 8
2.2 Messages .......................................................................................................................................... 9
2.2.1 Confirm ....................................................................................................................................... 9
2.2.2 No confirm ................................................................................................................................ 10
2.2.3 Answer question ....................................................................................................................... 10
2.2.4 System buttons......................................................................................................................... 10
2.3 Basic requests................................................................................................................................ 11
2.3.1 String ........................................................................................................................................ 11
2.3.2 Integer ...................................................................................................................................... 12
2.3.3 Real .......................................................................................................................................... 12
2.3.4 Question and answer ............................................................................................................... 13
2.4 Point request .................................................................................................................................. 13
2.5 Coordinate translation ................................................................................................................... 14
Exercise 1 ....................................................................................................................................................... 16
2.5.1 String selection ......................................................................................................................... 17
2.5.2 Color selection.......................................................................................................................... 18
2.5.3 Symbol selection ...................................................................................................................... 19
3 Exploring the Product Information Model ........................................................................................... 20
3.1 Accessing Aveva Marine environment variable ......................................................................... 20
3.2 Data Extraction ............................................................................................................................... 20
3.3 Listing objects in data bases ........................................................................................................ 22
3.4 Query dabacon objects ................................................................................................................. 23
Excercie 2 ....................................................................................................................................................... 24
4 PML draft functionality .......................................................................................................................... 25
4.1 Drawing functions .......................................................................................................................... 25
4.1.1 Current drawing ........................................................................................................................ 25
4.1.2 Store, delete, export darwing ................................................................................................... 26
4.1.3 Activating a drawing ................................................................................................................. 28
4.1.4 Housekeeping functions ........................................................................................................... 29
4.1.5 Layer handling functions .......................................................................................................... 30
4.1.6 Visual area functions ................................................................................................................ 30
4.1.7 Document references ............................................................................................................... 31
4.2 Element handles............................................................................................................................. 31
4.2.1 Type of elements identified by the handle ............................................................................... 31
4.2.2 Obtaining element handles ...................................................................................................... 32
4.2.3 Retrieving element's information from the handle .................................................................... 35
4.2.3.1 Model ................................................................................................................................ 35
4.2.3.2 Geometry .......................................................................................................................... 36
4.2.3.3 Text................................................................................................................................... 37
4.2.3.4 Symbol .............................................................................................................................. 37
Exercise 3 ....................................................................................................................................................... 38
4.3 View Functions ............................................................................................................................... 39
4.3.1 Creating or identifying the view ................................................................................................ 39
4.3.2 Transforming the view .............................................................................................................. 40
4.3.2.1 Move view......................................................................................................................... 40
4.3.2.2 Change view scale ........................................................................................................... 40
4.3.2.3 Reflect view ...................................................................................................................... 40
4.3.3 View projection ......................................................................................................................... 41
4.3.4 Symbolic views ......................................................................................................................... 42
4.3.5 View slice depth .......................................................................................................................
www.aveva.com 43
4.4 Model handling methods ............................................................................................................... 43
5
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.4.1 Drawing model objects ............................................................................................................. 43


4.4.2 Identifying and collecting model objects .................................................................................. 44
4.4.3 Deleting model objects ............................................................................................................. 45
4.4.4 Modifying model object modal properties ................................................................................ 46
4.5 Basic Geometry Entities ................................................................................................................ 46
4.5.1 Modal properties....................................................................................................................... 46
4.5.2 Creation of basic geometry entities .......................................................................................... 47
4.5.3 Entity properties ....................................................................................................................... 48
4.5.4 Highlighting elements ............................................................................................................... 49
Exercise 4 ....................................................................................................................................................... 51
4.6 Texts ................................................................................................................................................ 52
4.6.1 Modal properties....................................................................................................................... 52
4.6.2 Text Creation ............................................................................................................................ 52
4.7 Symbols .......................................................................................................................................... 53
4.7.1 Modal properties....................................................................................................................... 53
4.7.2 Symbols creation ...................................................................................................................... 54
4.8 Drawing components..................................................................................................................... 54
4.8.1 Hatching ................................................................................................................................... 54
4.8.1.1 Modal properties and adding hatching to the contour ...................................................... 54
4.8.2 Notes and position numbers .................................................................................................... 56
4.8.2.1 Modal properties ............................................................................................................... 56
4.8.2.2 Creating notes and position numbers .............................................................................. 56
4.8.3 Dimensioning............................................................................................................................ 57
4.8.3.1 2D dimensioning components .......................................................................................... 57
4.8.3.2 3D dimensioning components .......................................................................................... 60
4.8.4 Other drawing components ...................................................................................................... 61
4.8.4.1 Clouds (based on rectangles or general polygons).......................................................... 61
4.8.4.2 General restriction symbols .............................................................................................. 62
4.8.4.3 Crosses ............................................................................................................................ 62
4.8.4.4 Rulers ............................................................................................................................... 62
4.9 Marine Drafting default values ...................................................................................................... 63
4.10 Subpicture managing methods .................................................................................................... 63
4.11 Drawing element handling ............................................................................................................ 64
4.12 Shading functions .......................................................................................................................... 66
4.13 Dabacon references ....................................................................................................................... 67
5 Training exercises solution .................................................................................................................. 68
5.1 Exercise 1 ....................................................................................................................................... 68
5.2 Exercise 2 ....................................................................................................................................... 69
5.3 Exercise 3 ....................................................................................................................................... 70
5.4 Exercise 4 ....................................................................................................................................... 72

www.aveva.com
© Copyright 1974 to current year. 6
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Chapter 1

1 Introduction

This training guide is designed to give an introduction to the AVEVA Marine Programmable Macro
Language for Marine Drafting. There is no intention to teach software programming but only provide
instruction on how to customize the system using Programmable Macro Language (PML) in Marine
Drafting.

1.1 Aim
The aim is that the trainee will:

• Understand how PML can be used to customize Marine Drafting


• Understand how to use basic drafting functionality

1.2 Objectives
At the end of this training, participants will have:

• Knowledge of how marine draft functionality might be used in scripts

1.3 Prerequisites
The participants must have:

• Completed an AVEVA Marine Marine Drafting training or have a familiarity with AVEVA Marine
Marine Drafting
• Completed the PML: Macros & Functions Course or have familiarity with PML.
• Basic understanding of dabacon organization, attributes, query database elements.

1.4 Course Structure


Training will consist of oral and visual presentations, demonstrations, worked examples and set exercises.
Each trainee will be provided with some example files to support this guide. Each workstation will have a
training project, populated with model objects. This will be used by the trainees to practice their methods,
and complete the set exercises.

1.5 Using this Guide


Certain text styles are used to indicate special situations throughout this document, here is a summary;

Menu pull downs and button press actions are indicated by bold dark turquoise text.

Information the user has to key-in will be in bold red text.

 Additional information
 Reference to other documentation will be separate

System prompts should be bold and italic in inverted commas i.e. 'Choose function'

www.aveva.com
Example files or inputs will be in the bold courier new font with colors and styles used as before.

7
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Chapter 2

2 Basic Programming Interface

The following chapter describes the functions that have been created as the basic programming interface.
These include abilities to:

• obtain input data from the user,


• interactively define co-ordinates, and translate them between the available co-ordinate systems,
• manage the application’s window,

The methods have been split into two namespaces: Aveva.Marine.Utility (utilities) and Aveva.Marine.Ui
(user interface).

Since they often work together, instead of studying these namespaces separately, we will concentrate on
the typical patterns of their co-operation.

 This manual is intended to give only a basic understanding of the purpose and usage of these
classes and methods.

2.1 MarAPI assembly, documentation and method testing

MarAPI documentation is delivered within standard Aveva Marine installation. File NETmarAPI.chm is stored
in the Documentation folder. All methods parameters are described (order, parameter type, optional
parameters, values if omitted), see example below:

Before MarAPI assembly can be used, it should be imported. All PML programs should start from following
lines:

import 'marapi'
handle( 1000, 0 )
-- This error means that marapi has already been imported,
-- ignore this error and continue.
endhandle
'…'
www.aveva.com
8
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

Methods (name, spelling, parameter type) can be tested online by typing in the Command Window. See
below example, how check available methods and parameters for class MarUi():

In all the examples in the Training Guide will be assumed, that the proper namespace is used. To keep the
examples short, sometimes it will be marked the missing parts of the code by ellipsis ‘...’

2.2 Messages

The discussion will start with presentation of the available utility and user interface functionality by
considering the methods of displaying messages to the user. In order to access this functionality, it is
necessary to import Aveva.Marine.Utility and Aveva.Marine.Ui by including the following lines code:

using namespace ‘Aveva.Marine.Utility’


!marUtil = object MarUtil()
using namespace ‘Aveva.Marine.Ui’
!marUi = object MarUi()

The Aveva.Marine.Ui namespace provides methods for displaying messages on the screen.

2.2.1 Confirm

In order to display a dialog box containing an informational message, the MessageConfirm() method
should be used:

'…'
!block = 'F213'
!marUi.MessageConfirm('Hull block ' + !block + ' does not exist!')
'…'

www.aveva.com
© Copyright 1974 to current year. 9
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

2.2.2 No confirm

To display a message not requiring an acknowledgement, it is possible to use the method


MessageNoconfirm() :

'…'
!block = 'F213'
!marUi.MessageNoConfirm('Hull block ' + !block + ' does not exist!')
'…'

The message is displayed in the Message Window of the running application without interrupting the
program's execution. Method is used for displaying informational messages and other output from a
program. During the program's development it’s necessary often include additional messages, informing the
programmer about the program's status, values of some expressions, etc.

2.2.3 Answer question

The last message displaying method is AnswerReqPML(), which is used for asking the user a question.

'…'
!res = !marUi.AnswerReqPML('Bulkhead generation', 'Bulkead panel generated.
Continue?')
if (!res eq !marUtil.YesPML()) then
!marUi.MessageConfirm('Prepare data for next panel.')
endif
'…'

The first argument is the dialog box title, the second is the message itself. The user can click on one of the
following buttons:

Yes – YesPML() No - NoPML()


Options - OptionsPML() Cancel - CancelPML() QUIT – QuitPML()

Each of the buttons has a corresponding identification code (defined by the above method from
Aveva.Marine.Ui namespace) which is returned, when the user clicks the appropriate button. By using the
if statement programmer can write appropriate actions to be taken, when the user clicks the given button.

2.2.4 System buttons

The Aveva.Marine.Util namespace also contains the methods returning the identification codes for various
other buttons present in the AVEVA Marine environment (e.g. on the Control toolbar):

OK – OkPML() OPERATION COMPLETE –


UNDO – UndoPML() OperationCompletePML()
ALL – AllPML() EXIT FUNCTION -
REJECT – RejectPML() (identical to Cancel) ExitFunctionPML (identical to
QUIT) www.aveva.com
SUCCESS – SuccessPML()
© Copyright 1974 to current year. FAILURE – FailurePML() 10
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

2.3 Basic requests

2.3.1 String

One of the common parts of every program is the process of getting data from the user. The basic requests
are those that ask for string and numerical data. In the example below the user is prompted for the name of
the hull block:

'…'
!block = ''
!res = !marUi.StringReqPML('Block name', !block)
if (!res eq !marUtil.OkPML()) then
!block = !block.UpCase()
endif
'…'

The first argument of the StringReqPML() method is the message displayed in the dialog box. The
second, argument is the value returned by method.

The same method can take three arguments:

'…'
!block = ''
!res = !marUi.StringReqPML('Block name', !block, ’F206’)
if (!res eq !marUtil.OkPML()) then
!block = !block.UpCase()
endif
'…'

Third argument is the default value. The user can immediately accept it by clicking the OK button. Of course,
the user can change the value before clicking the OK button.

The result returned from the StringReqPML() method is a status code (OkPML(), CancelPML() etc ) of
the assigned to the parameter string. In the example above program will verify first, if the user has given the
block name (OK button clicked), and then block name will be assigned to variable !block, converting it to
uppercase for safety, as the user might have typed the block name using lowercase characters.

For simplicity, example above does not check, if the user has clicked Options, Cancel, or any other button;
all user responses other than OK are considered as the "No data available" answer. Of course, real
program can take the other possible user responses into account by adding some more elseif blocks.

www.aveva.com
© Copyright 1974 to current year. 11
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

2.3.2 Integer
Now, let's get the number of lines per page in a report (an integer number) using the IntReq() method.

'…'
!numb = REAL()
!res = !marUi.IntReq('Lines per page', !numb)
if (!res eq !marUtil.OkPML()) then
'…'

Integers are not fully supported by PML language, and required value must be predefined as real. The
method IntReq() discards digits after the decimal point thus returning an integer. For example, if a user
keys in 23.9, the method will return 23.

You can observe a similar pattern as for the function StringReqPML() displaying a dialog box, analysing
the button's identification code, and if it indicates, that the OK button has been clicked – getting the value.

The same method can be used with three arguments, the third argument being a default value:

'…'
!numb = REAL()
!res = !marUi.IntReq('Lines per page', !numb, 25)
if (!res eq !marUtil.OkPML()) then
'…'

2.3.3 Real

The third method in this group is RealReqPML(), which prompts the user for a floating point value
'…'
!numb = REAL()
!res = !marUi.RealReqPML('Panel X coordinate’, !numb)
if (!res eq !marUtil.OkPML()) then
'…'

This time no default value appears in the dialog box, because it has not been provided as an argument to
the method. The user has to key in some value for the X coordinate. The pattern of using this method is
exactly the same as for IntReq() and the method can be used with three arguments.

www.aveva.com
© Copyright 1974 to current year. 12
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

2.3.4 Question and answer

The methods presents a box with a question and lets the user give the answer.

2.4 Point request

In this section we will concentrate on the functions that prompt the user to indicate points on the drawing or
in the global co-ordinate system. AVEVA Marine handles points using MarPointPlanar() (2D point) and
MarPoint() (3D point) classes – make sure you are familiar with their definition. The first example to be
studied is that a 2D point request:

'…'
using namespace 'Aveva.Marine.Geometry'
!point = object MarPointPlanar()

!res = !marUi.PointPlanarReqPML('Indicate point', !point)


if (!res eq !marUtil.OkPML()) then
!marUi.MessageNoConfirm('X = ' + STRING(!point.X()))
!marUi.MessageNoConfirm('Y = ' + STRING(!point.Y()))
endif
'…'

In the above code example the user is prompted to indicate a point, then the status of the variable !res is
checked to see if it is equal to OkPML() finally the co-ordinates of the point are displayed.

The obtained co-ordinates are expressed in the drawing co-ordinate system with point (0, 0) at the origin of
the drawing form. The PointPlanarReqPML() method by default displays a cross-hair cursor and sets the
Cursor point indication mode. If other settings are desired, we must supply them to the function in a properly
configured MarStatPointPlanarReq() class instance (third argument). It is also possible to handle line
locking buttons by providing appropriate settings in a properly configured MarButtonState() class
instance (fourth argument). The picture below demonstrates the available cursor types:

A – CrossHair (default)
B – RubberBand
C – RubberRectangle
D – RubberCircle
E - DragCursor

The code below shows the use of the RubberBand cursor type:

'…'
using namespace 'Aveva.Marine.Geometry'
!point = object MarPointPlanar()
www.aveva.com
© Copyright 1974 to current year. 13
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

using namespace 'Aveva.Marine.Drafting'


!cursor = object MarCursorType()
!curpoint = object MarPointPlanar(0,0)
!cursor.SetRubberBand(!curpoint)

!status = object MarStatPointPlanarReq()


!status.Cursor(!cursor)

!res = !marUi.PointPlanarReqPML('Indicate point', !point, !status)


if (!res eq !marUtil.OkPML()) then
!marUi.MessageConfirm('X = '+STRING(!point.X())+',Y = '+STRING(!point.Y()))
endif
'…'

 See the documentation of the MarStatPointPlanarReq() class for the available point indication
modes, and the class MarCursorType() for the available cursor types.

The co-ordinates in the drawing's co-ordinate system are important for placing elements on the drawing, and
sizing drawing elements. If the indicated point lies on the model view, we can translate it to the 3D
coordinate system using the co-ordinate translation functions described in the next section 2.4. The user can
be prompted to indicate a 3D point directly:

'…'
using namespace 'Aveva.Marine.Geometry'
!point = object MarPoint()

!res = !marUi.PointReqPML('Indicate point', !point)


if (!res eq !marUtil.OkPML()) then
!marUi.MessageNoConfirm('X = ' + STRING(!point.X()))
!marUi.MessageNoConfirm('Y = ' + STRING(!point.Y()))
!marUi.MessageNoConfirm('Z = ' + STRING(!point.Z()))
endif
'…'

The simple example above does not set any special settings – all settings
take default values. In this case the
PointReqPML() method expects the user to indicate an event point and
does not impose any locking. If is necessary to behave differently,
appropriate attributes of the settings (MarStatPointReq() class) variable
should be set-up.

2.5 Coordinate translation

In modelling applications we work with different kinds of co-ordinate systems:


• drawing co-ordinate system, (U, V)
• global co-ordinate system, (X, Y, Z)
• panel co-ordinate system (U, V, W)
www.aveva.com
© Copyright 1974 to current year. 14
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

PML customization provides translating between these co-ordinate systems. The example below shows
a translation from the drawing co-ordinate system to the global co-ordinate system. The translated !point
lies on the panel, whose name is provided in the call:

'…'
!point = object MarPointPlanar()
!outPoint = object MarPoint()

!res = !marUi.PointPlanarReqPML('Indicate point', !point)


if (!res eq !marUtil.OkPML()) then
!panel = 'F206-DK2'
!coor = !marUtil.TraCoordShip(!point, !panel, !outPoint)
if (!coor) then
!marUi.MessageConfirm('X=' + STRING(!outPoint.X()) + ', Y=' +
STRING(!outPoint.Y()) + ', Z=' + STRING(!outPoint.Z()))
endif
endif
'…'

If the name of a panel is given, the point is calculated in the plane of the panel. If the name is empty, the
plane of the view closest to the point given is used.

 WARNING! This function should be used on principal plane views only, and basically we can trust
only the values of the co-ordinates along the axes of that view. The co-ordinate along the axis
perpendicular to the view's plane may not be correct! This is especially important, if you DON'T
provide the panel's name.

The TraCoordShip() method returns resulting point (MarPoint() type) and type of the result value (true
or false).
eva.com
If the co-ordinates in the panel's co-ordinate system are expected, just replace TraCoordShip() with
TraCoordPan() and be sure to provide the appropriate panel's name as the third argument. The output
is also point (MarPoint() type) and type of the result value (true or false).

The MarDrafting() class provides the method PointTranform(), performing the opposite translation
from the ship's co-ordinate system to the drawing co-ordinate system.

Within the MarUtil() class there are two methods that carry out translations between the global
coordinate system, and the local co-ordinate system on the X, Y and Z axes (frames, horizontal and vertical
longitudinal positions):

'…'
!value = 0
!off = 0
!marUTIL.CoordToPos(1, 124500, !value, !off)
if (!off gt 0) then
!marUi.MessageConfirm('X=FR' + STRING(!value) + '+' + STRING(!off))
elseif (!off lt 0) then
!marUi.MessageConfirm('X=FR' + STRING(!value) + STRING(!off))
else
!marUi.MessageConfirm('X=FR' + STRING(!value))
endif
'…'

www.aveva.com
© Copyright 1974 to current year. 15
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

The first argument in the CoordToPos() method is the axis index (1 for X, 2 for Y, and 3 for Z axis). The
second argument is the co-ordinate in the global co-ordinate system to be translated. The result is a frame
or longitudinal number (!value) and offset (!off).

The opposite translation is done using the PosToCoord() method:

'…'
!value = 0
!marUTIL.PosToCoord(1, 155, !value)
!marUi.MessageConfirm('X = ' + STRING(!value))
'…'

The first argument is the axis index, the second is the logical coordinate (FR155 in this case) to be
translated. The result is the translated coordinated in the global coordinate system.

Exercise 1

Create a new PML function called exercise1 (do not forget use command ‘pml rehash all’ before function
first test).

Get from the user the frame number range (from FR-4 to FR222; use different formatted requests).

Create list (array) containing the frame table showing the frame number and the corresponding X coordinate
(in meters).

Save frame table as CSV formatted file in the C:\TEMP directory.

Display on screen X coordinate of the frame 125 (MessageConfirm method).

Display in the Message Window X coordinate of the frame 200 (MessageNoConfirm method).

www.aveva.com
© Copyright 1974 to current year. 16
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

2.5.1 String selection

Examples of selections are the pop-up menus, where the user selects an item by clicking a button, and the
dialog boxes giving a choice of panel symmetry settings, or the pipes from the given module. PML
customization provides methods for presenting selections to the user, and allowing the user to make a
choice. The list of alternatives should be provided as the list of strings:

'…'
!res = REAL()
!choice = ARRAY()
!choice.append('P')
!choice.append('S')
!choice.append('SP')
!choice.append('SBP')

!marUi.ChoiceSelect('Panel generation', 'Select panel symmetry', !choice, !res)


if (!res eq 1) then
!marUi.MessageConfirm('Selected ' + !choice[!res])
elseif (!res eq 2) then
!marUi.MessageConfirm('Selected ' + !choice[!res])
elseif (!res eq 3) then
!marUi.MessageConfirm('Selected ' + !choice[!res])
else
!marUi.MessageConfirm('Selected ' + !choice[!res])
endif
'…'

The ChoiceSelect() method displays a dialog box with buttons having the alternatives as captions. The
user makes a choice by clicking the appropriate button. The arguments of the function are: the title of the
dialog box, the prompt, and a list of alternatives (strings). The result is the index of the chosen alternative.
This function cannot handle more than 20 alternatives. If you need to present a choice from more than 20
items, use the method StringSelect(). The above example rewritten to use this function looks as
follows:

'…'
!res = REAL()
!choice = ARRAY()
!choice.append('P')
!choice.append('S')
!choice.append('SP')
!choice.append('SBP')

if (!marUi.StringSelect('Panel generation', 'Select panel symmetry', 'Selected',


!choice, !res) eq !marUtil.OkPML()) then
if (!res eq 1) then
!marUi.MessageConfirm('Selected ' + !choice[!res])
elseif (!res eq 2) then
!marUi.MessageConfirm('Selected ' + !choice[!res])
elseif (!res eq 3) then
!marUi.MessageConfirm('Selected ' + !choice[!res])
else
!marUi.MessageConfirm('Selected ' + !choice[!res])
endif
endif
'…'

The difference is that the StringSelect() method displays the items not as buttons, but in a list control,
and in order to choose one of them, the user has to click first an item, then the OK button. There is also an
additional argument in the function call – the header, which is provided between the window's title and the
prompt. It is displayed above the alternatives. The number of alternatives is limited only by the available
memory. The differences between these functions are shown on the picture below:
www.aveva.com
© Copyright 1974 to current year. 17
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

2.5.2 Color selection

AVEVA Marine PML implementation allows also select a color, using the ColourSelectPML() method.
Colors are managed by the MarColour() method of Aveva.Marine.Drafting, which has to be imported to
the program:

'…'
using namespace 'Aveva.Marine.Drafting'
!marCol = object MarColour()

!marUi.ColourSelectPML('Colour selection', !marCol)


!marUi.MessageConfirm('Selected colour: ' + !marCol.ColourString())
'…'

The function displays a list of bars in the available colors. By clicking a bar, the corresponding color is
selected.

 WARNING: The use of this function DOES NOT mean that the selected color becomes the current
modal color!

Color might be set without user selection by key in color name:

'…'
using namespace 'Aveva.Marine.Drafting'
!marCol = object MarColour()
!marCol.ColourString('Black')

!marUi.MessageConfirm('Selected colour: ' + !marCol.ColourString())


'…'

 See the documentation for full list of available colors.


www.aveva.com
© Copyright 1974 to current year. 18
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

2.5.3 Symbol selection

The last method giving the user a choice is SymbolSelect(), which presents a list of symbols to choose
from a menu of all symbols in a given list. This list may contain symbols from any existing symbol font. Non-
existing symbols in the list will appear as blanks entries in the menu, thus alerting the user of incorrect input
values

'…'
!font = 9
!symb = 0
!marUi.SymbolSelect('Symbol selection', !font, !symb)
!marUi.MessageConfirm('Selected symbol from font 9: ' + STRING(!symb))
'…'

or

'…'
using namespace 'Aveva.Marine.Drafting'
!marSymb = object MarSymbollist()
!marSymb.AddSymbol(9, 1)
!marSymb.AddSymbol(9, 2)
!marSymb.AddSymbol(8, 4)
!font = 0
!symb = 0
!marUi.SymbolSelect('Symbol selection', !marSymb, !font, !symb)
!marUi.MessageConfirm('Selected font: ' + STRING(!font))
!marUi.MessageConfirm('Selected symbol: ' + STRING(!symb))
'…'
www.aveva.com
The first variant displays all symbols from the given font. The second variant employs the class
MarSymbollist() to collect symbols from various fonts to be displayed for selection. In this case, returned
are font (!font) and symbol (!symb) numbers (the first variant does not include the font number as return
value). Additionally, the variant with the MarSymbollist() class instance displays the provided prompt in
the message window of the application, not inside the dialogue box.

www.aveva.com
© Copyright 1974 to current year. 19
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Chapter 3

3 Exploring the Product Information Model

AVEVA Marine system stores the information in the PIM (Product Information Model). It is often used by
customize programs to determine proper attributes of modeled items, and to choose the right algorithm path
to follow. In order to make it possible, AVEVA Marine provides four groups of functions:

• accessing the environment variables,


• using Data Extraction engine to query the Product Information Model (Tribon backwards
compatibility),
• listing objects in data bases
• query dabacon objects meeting certain criteria

3.1 Accessing Aveva Marine environment variable

PML customization offers the possibility to read and set the values of environment variables:

'…'
!oldSymbDir = !marUtil.TBEnvironmentGet('SBB_SYMBDIR')
!marUi.MessageConfirm('SBB_SYMBDIR = ' + !oldSymbDir)
!marUtil.TBEnvironmentSet('SBB_SYMBDIR', 'C:\MySymbols')
!marUi.MessageConfirm('SBB_SYMBDIR = ' +
!marUtil.TBEnvironmentGet('SBB_SYMBDIR'))
-- restore original SBB_SYMBDIR
!marUtil.TBEnvironmentSet('SBB_SYMBDIR', !oldSymbDir)
'…'

The method TBEnvironmentGet() returns the value of the environment variable passed as an argument,
or raises the exception, if the variable is not found. The function TBEnvironmentGet() sets the value of
the environment variable.

 WARNING! The value of the AVEVA Marine environment variable is changed for the current
process only.

3.2 Data Extraction

Data Extraction is a tool that retrieves the information stored in various AVEVA Marine data bases. It
accepts commands from the user and returns the results. The commands consist of tokens separated by a
dot ('.') character. The available information is tree-structured, and each token in the command string
corresponds to the specific node in this information tree.

Each token is defined by a keyword, followed sometimes by an argument in parentheses. The argument can
be:

• a number BOUNDARY(1)
• a range BOUNDARY(1:4) – boundaries from 1 to 4
• a list of numbers BOUNDARY(1,3) – boundaries no. 1 and 3 only
• a string PANEL('F206-DK2')
• a wildcard PANEL(*) – all panel names
• a string with wildcards PANEL('F206-'*) – all panel names beginning with 'F206-'

www.aveva.com
20
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

 Full description of the syntax of the Data Extraction commands can be found in the Data Extraction
User's Guide.
Below are some examples of the Data Extraction commands:

• HULL.BLOCK(*).NAME – the names of all hull blocks


• HULL.BLOCK('F206').PANEL(*).WEIGHT – weights of all panels from the hull block 'F206'
• HULL.PANEL('F206-DK2').BOUNDARY(1:100).CORNER – co-ordinates of all boundary corners of
the panel 'ER2-VX01341'. There won't be 100 boundaries in this panel, so by specifying an upper
limit of 100 we can be rather sure, that we catch all of them. After the last corner, Data Extraction
will simply stop printing any further results. Alternatively, we can first get the value of
HULL.PANEL('F206-DK2').NBOUNDARY, which is an actual number of boundaries.

 Instead of using the Data Extraction User's Guide it is possible to find interactively the form of the
desired Data Extraction command using the Query program (SX700). At each level of the
information tree, a '.HELP' token can be used to find out, which tokens are available at the next
tree level.
The access to Data Extraction engine is provided by the Aveva.Marine.DataExtraction namespace, which
has to be imported to the program. The example below shows a typical pattern of using Data Extraction to
obtain a single value.

'…'
using namespace 'Aveva.Marine.DataExtraction'
!marDex = object MarDex()

!cmd = |HULL.PANEL('F206-DK2').PLATE(1).NAME(1)|
!res = !marDex.ExtractPML(!cmd)
if (!res eq 0) then
!res = !marDex.NextResultPML()
if (!res eq 3) then
!platename = !marDex.GetString()
endif
endif
'…'

First Aveva.Marine.DataExtraction namespace is imported and construct the Data Extraction command
string. Then Data Extraction is performed by calling the ExtractPML() method. If the result is ZERO, then
there was no error during Data Extraction. Getting the value is a 2-stage process: first, "access" the data
item using the NextResultPML() method, then getting that value, using an appropriate GetXXX()
method (GetString() for string-type data). The value returned by NextResult() method indicates the
data type of the data item to be retrieved and the GetXXX() method to be called:
GetXXX()
NextResultPML() Data type method Comments
1 integer GetIntPML()
2 real GetReal()
3 string GetString() [X, Y, Z]
real vector [Xmin, Ymin, Zmin, Xmax, Ymax,
4 3D GetReavec3D() Zmax]
5 box GetBox()
real vector
6 2D GetReavec2D()

subtracting 10 from the result gives


> 10 vector nD GetIndexedreal() the number of elements in the vector

empty tree part - no data available


end of result tree - no MORE data
-1 available www.aveva.com
© Copyright 1974 to current year. 21
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

If the Data Extraction command string contains wildcards, it is expected many data to be retrieved. Then
pattern must be changed accordingly:

'…'
using namespace 'Aveva.Marine.DataExtraction'
!marDex = object MarDex()

!names = ARRAY()
!cmd = |HULL.BLOCK(*).NAME|
!res = !marDex.ExtractPML(!cmd)
if (!res eq 0) then
do
!res = !marDex.NextResultPML()
if (!res eq 3) then
!name = !marDex.GetString()
!names.append(!name)
else
break
endif
enddo
endif
!blo = REAL()
!marUi.StringSelect('Hull production blocks', 'Select block', '', !names, !blo)
'…'

Here can be seen, that the do loop is added. It may also understand better the meaning of the
NextResultPML() method: it "accesses" the NEXT data item, and returns the appropriate data type,
telling if the next data item is available or not.

IMPORTANT!
When the method NextResultPML() returns 0, it DOES NOT MEAN the end of extraction yet. For
interpretation of the data types returned from this method, it should apply the following rules:
• data type > 0 Data IS AVAILABLE for the current item, which can be found by analysing the
arguments of the current Data Extraction command string, returned by the GetCommandString()
method.
• Use the corresponding GetXXX() method (see table on previous page) to retrieve the value.
Extraction IS NOT terminated yet, and the next data type should be fetched using
NextResultPML() method.
• data type = 0 Data IS NOT AVAILABLE for the current item, which can be found by analysing the
arguments of the current Data Extraction command string, returned by the GetCommandString()
method.
• Extraction IS NOT terminated yet, and the next data type should be fetched using
NextResultPML() method.
• data type = –1 No more data available. The extraction IS terminated.

 It is not possible to run multiple Data Extraction queries at the same time. If need to get various
kinds of data, requiring different Data Extraction command strings, run these extractions one-by-
one, storing the results in an appropriated data structure.

3.3 Listing objects in data bases

Data Extraction engine provides a very limited support for limiting directly the result set to the items meeting
certain criteria. In fact, wildcards can be only used and index ranges in the arguments of Data Extraction
command strings. It is impossible, for example, to ask objects created in the given time interval, having the
given minimum size, or having an appropriate Object Code. Often it’s need to extract large amount of data
in order to process them and select those meeting predefined criteria by analysing their properties. PML
customization supports querying AVEVA Marine data bases through the MarDataBase() class. Currently it
exports only one method – ObjectListGetPML(), which uses MarObjectCriteria() class argument
www.aveva.com
© Copyright 1974 to current year. 22
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

for specifying the selection criteria and returns a list of MarObject() class, describing the objects meeting
these criteria.

'…'
using namespace 'Aveva.Marine.Utility'
!marDB = object MarDataBase()

!criteria = object MarObjectCriteria()


!criteria.SetNamePML('F206*')
!res = !marDB.ObjectListGetPML(!criteria, 'SB_PLDB')
do !x values !res
!panel = !x.name()
$P $!panel
enddo
'…'

In the example above, PML script will display in the Command Window (do loop) all objects name start
from string ‘F206’ stored in data bank assigned to ‘SB_PLDB’ variable.

3.4 Query dabacon objects

Above described methods to extract information from PIM are valid only for marine hull objects. A very
powerfull feature of the AVEVA Marine database is the ability to collect and evaluate data according to rules.
Collection rules and syntax are detailed describe in the TM-2263 AVEVA Marine Programmable Macro
Language training manual. In this chapter will be presented method only usage for hull objects.

Dabacon data bases collection and evaluation is recommended method of Product Information
Model exploring.

'…'
!collection = object COLLECTION()
!collection.type('BLOCK')
!res = !collection.results()
!sres = object BLOCK(|!res[!evalIndex].NAMN|)
!blist = !res.evaluate(!sres)

!blo = REAL()
!marUi.StringSelect('Hull production blocks', 'Select block', '', !blist, !blo)
'…'

Example above query data bases, collect all objects type BLOCK, evaluate collected objects using object
attribute name (NAMN attribute is a object name without ‘/’ at beginning). All hull production block names are
returned as array !blist.

Example below collect all hull blocks, but names should start from letter ‘F’, expression filter should be
added additional to the code:

'…'
!collection = object COLLECTION()
!collection.type('BLOCK')
!expression = object EXPRESSION(|MATCHWILD(ATTRIB NAMN, 'F*')|)
!collection.filter(!expression)
!res = !collection.results()
!sres = object BLOCK(|!res[!evalIndex].namn|)
!blolist = !res.evaluate(!sres)

!blo = REAL()
!marUi.StringSelect('Hull production blocks', 'Select block', '', !blolist,
!blo)
'…'
www.aveva.com
© Copyright 1974 to current year. 23
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

Excercie 2

Create a new PML function called exercise2.

Collect all hull blocks and display them as list (StringSelect() method)

Select block F206 from list and collect all plane panels inside selected block.

Display panels list (StringSelect() method) in the loop as long user do not click Cancel button, get
panel weight and display on screen.

www.aveva.com
© Copyright 1974 to current year. 24
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Chapter 4

4 PML draft functionality

PML for marine customization contains methods for many different purposes. There are methods for
creating a new drawing, placing text in drawing, creating geometric entities or drawing components,
highlighting, subpicture and model objects handling, etc. The methods described belong to the following
categories:
• Drawing • Symbols
functions • Notes and
• Element position
handle numbers
f ti G l

In order to make use of these methods the program must include the statements:

using namespace 'Aveva.Marine.Drafting'


!marDraft = object MARDRAFTING()

4.1 Drawing functions

This section describes the methods in the MarDrafting() class that handle the drawing as a whole. The
default drawing databank is defined by the AVEVA Marine environment variable SB_PDB.

4.1.1 Current drawing

 WARNING: There can be only one drawing active at any time! Therefore before creating a new
drawing or opening an existing one, first the current drawing must be closed!

In order to check if there is a current drawing, developed program can call the method

DwgCurrent()

This method returns true if a drawing is current, and false if no drawing is current. Some methods require a
drawing to be current, while the other will complain, if a drawing is current. If the current status does not
meet the requirement of a function, it will raise an exception.

If a drawing is current, program is able to get its name and the name of its drawing form, using the methods:

DwgNameGet()
FormNameGet()

If the PML program wants to create a new drawing or open an existing one, the current drawing must be
closed first using the method

DwgClose()

www.aveva.com
25
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
if (!marDraft.DwgCurrent()) then
!dwgName = !marDraft.DwgNameGet()
!marUi.MessageConfirm(!dwgName)
!dwgForm = !marDraft.FormNameGet()
!marUi.MessageConfirm(!dwgForm)
!marDraft.DwgClose()
else
!marUi.MessageConfirm('Drawing is not current')
endif
'…'

4.1.2 Store, delete, export drawing

The above method closes the current drawing without storing, which is usually undesirable. To store the
drawing the MarDrafting() class provides two methods:

DwgSave()

stores the current drawing under the current name, overwriting a possibly existing previous version of the
drawing

DwgSaveAs(NewName, Database)

stores the current drawing under the name given as a parameter. The optional Database parameter can be
either string ('SB_ASSPDB' - automatic assembly drawings) or integer (8 – hull weight and centre of gravity
drawings).

 See documentation for full list of available databanks and numbers

 Saving the drawing does not close it.


 An already existing version in the data bank will be overwritten
'…'
if (!marDraft.DwgCurrent()) then
!dwgName = !marDraft.DwgNameGet()
!marDraft.DwgSave()
!marUi.MessageConfirm('Drawing ' + !dwgName + ' stored')
else
!marUi.MessageConfirm('Drawing is not current')
endif
'…'

The latter will fail, if the drawing NewName exists in the data base, when this function is called. It may want
to check first the existence of the given drawing, and possibly to delete it from the data base, before
calling DwgSaveAs(). In such case, the method should be used:

DwgExist(dwgName, dwgType)

which checks, if the drawing dwgName exist on the data base specified by the optional dwgType argument
(default: standard drawing data base). The result is either true (exists), or false (does not exist). Then, if it’s
decided to remove the drawing from the data base, the method should be used:

DwgDelete(dwgName, dwgType)

If no exception is raised, then the given drawing is removed from the data base, and it can safely use its
name again, when storing drawing with the DwgSave() method.

www.aveva.com
© Copyright 1974 to current year. 26
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
!dwgName = 'F206-12345-003'
if (!marDraft.DwgExist(!dwgName)) then
!marUi.MessageConfirm('Drawing name already exist in database')
!marDraft.DwgDelete(!dwgName)
!marUi.MessageConfirm('Drawing is deleted')
!marDraft.DwgSaveAs(!dwgName + 'PML_Training')
else
!marUi.MessageConfirm('Drawing do not exist in database')
!marDraft.DwgSaveAs(!dwgName + 'PML_Training')
endif
'…'

In order to exchange drawings with other systems, AVEVA Marine provides appropriate functions for
exporting and importing the drawings into the DXF format. AVEVA Marine Detailed Design and AVEVA
Marine Marine Drafting are able to produce either 2D or faceted 3D DXF format files. The method given
below stores the current drawing in the 2D DXF format. The DXF file name (path) is given as an argument.

DwgExport(path)

'…'
if (!marDraft.DwgCurrent()) then
!dwgName = !marDraft.DwgNameGet()
!marDraft.DwgDxfExport('c:\temp\' + !dwgName + '.dxf')
!marUi.MessageConfirm('Drawing exported: ' + !dwgName + '.dxf')
else
!marUi.MessageConfirm('Drawing is not current')
endif
'…'

System provides a limited (export only) support for the faceted 3D DXF format. The PML API contains an
appropriate function for this purpose:

DwgDxf3dExport(path, viewSubviewList, detailLevel)


www.aveva.com
where path is the file name of the resulting 3D DXF file, viewSubviewList is a list of MarElementHandle()
class instances identifying the views or subviews being handled, and detailLevel is an optional integer
number, determining the exported image detail level:
1 – low detail
2 – medium detail
3 – high detail (default)
4 – extra high detail

The views or subviews, identified by the handles stored in the viewSubviewList parameter, are exported to
the faceted 3D DXF format.

DwgWmfExport(fileName)

The above method exports the current drawing to the Windows metafile, whose name (path) is provided as
the argument. The given file must not exist, or an exception will be raised.

PML is also able to print the current drawing using the Windows printing services. In order to print the
drawing, the program must set up an instance of the MarPrintOptions() class, and pass it to the
method:

DwgPrint(options)

where the options parameter defines important features of the printout, like: the selected printer, page
orientation, number of copies, scaling, scope of the drawing to be printed, printer name, etc.

www.aveva.com
© Copyright 1974 to current year. 27
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.1.3 Activating a drawing

If it have made sure, that no drawing is current (either by using DwgClose() explicitly, or checking the
status with DwgCurrent()), another drawing can be activated or created a new one. In order to open an
existing drawing the method can be used:

DwgOpen(dwgName, dwgType, openMode, dwgRevision, envelopeMode)

where dwgName is the name of the drawing to be opened and made current. All remaining arguments are
optional, and have the following meaning:
dwgType drawing type (logical data base name, default: "SB_PDB", or special drawing type constants – see
the documentation)
openMode 0 – read only or 1 – read-write (default)
dwgRevision (TDM) drawing revision name. Empty string – latest revision (default),
envelopeMode 0 - no envelope (default), 1 - initial envelope, or 2 - permanent envelope

If optional arguments are not used, the latest revision of the drawing will be opened from the standard
drawing data base, in the read-write mode, and without envelopes. By using the optional arguments, it can,
for example, open the assembly drawing, or request a specific revision of the drawing. If the given drawing
does not exist on the data base, an exception will be raised. In order to avoid it, first the method
DwgExist() should be called.

'…'
!dwgName = 'F206-12345-003'

if (!marDraft.DwgCurrent()) then
!marDraft.DwgClose()
if (!marDraft.DwgExist(!dwgName)) then
!marDraft.DwgOpen(!dwgName)
else
!marUi.MessageConfirm('Drawing do not exist in database')
endif
endif
'…'

It is possible to create a new drawing using the function

DwgNew(dwgName, formName, dwgType)


.aveva.com
where in addition to the drawing name you can provide optionally the name of the drawing form (default – no
drawing form), and the drawing type specification)

The drawing is initialized according to the arguments, and made current. If the drawing dwgName exists on
the databank, when this method is called, an exception is raised. Again, it may use the method
DwgExist() to check the existence of the given drawing on the databank. Then if it’s decided to remove
the existing drawing, the method DwgDelete() should be used as first. Both methods are described in
previous section.

'…'
!dwgName = 'F206-PMLTEST'

if (!marDraft.DwgCurrent()) then
!marDraft.DwgClose()
if (!marDraft.DwgExist(!dwgName)) then
!marUi.MessageConfirm('Drawing already exist')
else
!marDraft.DwgNew(!dwgName, 'A3-AVEVA')
endif
endif
'…'
www.aveva.com
© Copyright 1974 to current year. 28
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

Finally, the new drawing can be initialised from a 2D DXF file using the import facility.

DwgDxfImport(fileName, dwgName)

which reads the DXF file filename and creates drawing named dwgName.

4.1.4 Housekeeping functions

The following methods perform some housekeeping work on the current drawing:
DwgPack() – packs the current drawing
DwgPurgePML() – removes empty subpictures
DwgReferenceShow(show, views) – expands of collapses drawing references in the current drawing

The show argument is a Boolean value: True causes the expansion, False – collapsing of drawing
references. The optional views argument is a list of handles (MarElementHandle()) to the views to be
expanded or collapsed. If omitted, all drawing references will be considered.

'…'
if (!marDraft.DwgCurrent()) then
!marDraft.DwgPurgePML()
!marDraft.DwgSave()
else
!marUi.MessageConfirm('Drawing not current')
endif
'…'

During the work on the ship's model, it happens quite often, that a drawing does not show an up-to-date
information on the model views. In such cases, AVEVA Marine applications provide the validating
functionality, which detects the model objects, present on the model views, that do not exist anymore in the
model or are outdated. PML supports this functionality through the method

DwgValidate(OutOfDate, NotFound)

which fills up the lists OutOfDate and NotFound with MarModel() class instances. The OutOfDate list
contains all model objects, that still exist in the model, but have been updated, after the drawing views have
been created or exchanged from the model. These objects should be redrawn to make the views up-to-date.
On the other hand, the NotFound list contains all model objects, that do not exist anymore in the model,
and should be removed from the views.

'…'
!OutOfDate = ARRAY()
!NotFound = ARRAY()

if (!marDraft.DwgCurrent()) then
!marDraft.DwgValidate(!OutOfDate, !NotFound)
do !x value !OutOfDate
!name = !x.name()
!marUi.MessageNoConfirm('Object changed after view is created: ' + !name)
enddo
do !x value !NotFound
!name = !x.name()
!marUi.MessageNoConfirm('Object deleted: ' + !name + ', update views!')
enddo
else
!marUi.MessageConfirm('Drawing not current')
endif
'…'
www.aveva.com
© Copyright 1974 to current year. 29
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.1.5 Layer handling functions

AVEVA Marine applications can work in one of two modes, regarding the drawing layers: show selected
layers or hide selected layers. The two functions given below, return the current setting of the layer
treatment mode:

DwgLayersIsShown ()
DwgLayersIsHidden ()

They return true, if the given layer treatment mode is active, otherwise false. In order to get the list of the
selected layers (to be shown or hidden, respectively), use the functions:
www.aveva.com
DwgLayersShwonGetPML()
DwgLayersHiddenGetPML ()

The actual showing and hiding of layers is done by the functions:

LayerShow(layer)
LayerHide(layer)

The last two methods accept either a single instance of the Layer() class, or a list of such instances. If the
corresponding layer treatment mode has not yet been selected, these functions select this mode, resetting
the list of selected layers to the ones provided as the argument. If the corresponding layer treatment mode
has already been selected, the layers provided as the argument are simply added to the list of selected
layers. In order to show all layers (and reset the layer treatment mode to show), use the method:

LayerShowAll()

4.1.6 Visual area functions

When the drawing is current, PML is able to show only a portion of the drawing by using the zooming
method:

'…'
using namespace 'Aveva.Marine.Geometry'

!p1 = object MarPointPlanar(0,0)


!p2 = object MarPointPlanar(250,250)
!marRec = object MarRectanglePlanar(!p1, !p2)
!marDraft.DwgZoom(!marRec)
'…'

where !marRec is the MarRectanglePlanar() class instance, defining the axis-parallel rectangle to
zoom the drawing's display to. The current zooming rectangle can be retrieved using the method
ZoomExtentGet() :

'…'
!marRec = !marDraft.ZoomExtentGet()
'…'

where !marRec is an initialised MarRectanglePlanar() class instance, that is updated with the co-
ordinates of the zooming rectangle. This function also returns !marRec as the result.

 If the drawing is empty, the returned !marRec will be also empty. This can be tested using the call to
!marRec.IsEmpty().

Finally, the whole drawing can be redrawn using the method:

DwgRepaint() www.aveva.com
© Copyright 1974 to current year. 30
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
using namespace 'Aveva.Marine.Geometry'
!p1 = object MarPointPlanar(0,0)
!p2 = object MarPointPlanar(250,250)
!marRec = object MarRectanglePlanar(!p1, !p2)
!marDraft.DwgZoom(!marRec)
!marDraft.DwgRepaint()
'…'

4.1.7 Document references

Document references are the links to other drawings or external files. PML supports this concept through
the MarDocumentReference() class. It handles such attributes of a document reference, as:

• Type ('unknown', 'drawing', 'file', 'document')


• Document (document name)
• Description (document description)
• Purpose (for 'drawing' references, it should contain the numerical code of the drawing data base –
see the documentation for details)

Document references can be attached virtually to any object in the system. In the case of drawings, PML
provides the following functions handling the document references attached to the current drawing:

DocumentReferenceGetPML()
www.aveva.com
get a list of document references associated with the current drawing

DocumentReferenceAdd(docRef)

add a document reference to the current drawing

DocumentReferenceRemove(docRef)

remove a document reference from the active drawing.

4.2 Element handles

The drawing's structure is hierarchical. The topmost elements are views, which are composed from
subviews. The subviews are then composed from components, which in turn are built from various geometry
elements. Each drawing element is uniquely identified by a numerical id, called the element's handle. PML
customisation uses handles for identifying the drawing element, on which the operation is performed.

The element handles are represented as instances of the MarElementHandle() class.

4.2.1 Type of elements identified by the handle

This class currently manages only one element attribute – the numerical id (the handle). The class itself
does not have an information about the type of element that the handle is referring to. Fortunately, this
information is contained in the object referred by the handle. For identifying the object type, PML provides
a set of methods, returning true, if the object is of the right type, or false, if it is not. All the functions specified
below take an MarElementHandle() class instance as a parameter.

ElementIsView(handle) a view
ElementIsSubpicture(handle) a subpicture (any kind)
ElementIsSubview(handle) a subview (any kind, in a view)
ElementIsComponent(handle) a component (any kind, in a subview)
ElementIsNesting(handle) a subpicture being a nesting subview or a component belonging to it

www.aveva.com
© Copyright 1974 to current year. 31
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

ElementIsBurningSketch(handle) a subpicture being a burning sketch subview or a component


belonging to it
ElementIsDetailSketch(handle) a subpicture being a detail sketch subview or a component
belonging to it
ElementIsNote(handle) a note component
ElementIsPosno(handle) a position number component
ElementIsDimension(handle) a dimensioning component
ElementIsHatch(handle) a hatching component
ElementIsContour(handle) any 2D contour element
ElementIsText(handle) a text element
ElementIsSymbol(handle) a symbol element
ElementIsBodyplan(handle) a bodyplan view
ElementIsCurpanel(handle) a curved panel view
ElementIsDetailView(handle) a detail view
ElementIsDevplaView(handle) a developed plate view
ElementIsDevstiView(handle) a developed stiffener view
ElementIsGeneralView(handle) a general view
ElementIsShellxView(handle) a shell expansion view
ElementIsSymbolicView(handle) a symbolic view
ElementIsTemplView(handle) a template view

Note that the element categories recognized by these functions are not separate. Every note, position
number, dimension, and hatching is a component. Every nesting, burning sketch, detail sketch is a subview.
Every component, subview, and view is a subpicture, etc. The picture below illustrates these relations.

4.2.2 Obtaining element handles

The element handles are required for manipulating the elements. The program can obtain the handles using
one of the three methods given below:

1. By creating the object.


Various object creating methods return always a handle to the newly created entity. If the object is created
explicitly by the program, its handle is directly available at the object's creation stage.

2. By identifying the object.


The program can identify (detect) any object located in the neighborhood of a point in the drawing (defined
as the MarPointPlanar() class instance). Subpictures can be also identified by its name. If the
identification is successful, the handle is returned.

3. By capturing objects in the given region.


www.aveva.com
The program can collect the objects of the given kind, located inside (or outside) the given region. The

© Copyright 1974 to current year. 32


AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

region is defined as the MarCaptureRegionPlanar() class instance. It is not only a simple closed
contour, but can also decide, whether the objects are collected inside or outside the contour, and whether
the objects crossing the contour's boundary should be taken into account, or not. If the capturing is
successful, the
program receives a list of handles to the objects caught by the given region.

The objects creating methods are described in various places in this chapter. The reader should find there
the detailed information about how the given object is created.
The object identifying methods, however, look similar. The first group of identification methods takes a
single parameter being the MarPointPlanar() class instance (denoting the point, around which the
detection is done), and returns the element's handle.

SubviewIdentify(point) subviews
ComponentIdentify(point) components
DimIdentify(point) dimensioning components
NoteIdentify(point) note components
PosnoIdentify(point) position number components
hatchIdentify(point) hatch components
GeometryIdentify(point) geometries
ContourIdentify(point) contours
TextIdentify(point) text elements
SymbolIdentify(point) symbols
PointIdentify(point) points
ViewIdentify(point, PictWinExt) views

The method ViewIdentify() accepts an optional, second argument, being an instance of the
MarPictWinExt() class, which modifies the method of the view identification:

1. If MarPictWinExt() is initialised to "Small" (the default), system selects first view, for which
the axis-parallel rectangle circumscribing the view, and enlarged symmetrically by 10%, contains the
given indication point. Then system finds the geometry, belonging to one of these views, closest to
the indication point. The result is the handle of the view containing this geometry.

2. If PictWinExt() is initialised to "Big", the procedure is similar to the one described above, but
the rectangle is enlarged symmetrically by 50%.

3. If PictWinExt() is initialised to "Infinite", system does not check the view windows at all, so
all geometries in the drawing are considered.

 WARNING! The settings of "Infinite" should be used sparingly, as it may take a significant amount of
time to check distances to ALL geometries on a big drawing.
'…'
!resultCodes = object MARUTIL()
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
do !n from 1 to 10
if (!pointResult eq !resultCodes.rejectPML()) then
!marUi.messageNoConfirm('Script aborted!')
break
else
!viewHandle = !marDraft.viewIdentify(!point)
handle ANY
!marUi.messageNoConfirm('View not found!')
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
endhandle
endif
enddo
$P $!viewHandle
!marDraft.DwgRepaint()
'…' www.aveva.com
© Copyright 1974 to current year. 33
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

PML code presented above, prompt user to indicate a view and, if view is found, return (and print in
Command Window) handle to this view. If view is not found program prompt user again, but not more as 10
times. User can interrupt program execution, using keyboard Esc button.
The views, subviews, and components can be named. Therefore, three more identification methods can be
used:

ViewIdentify(name) views
SubviewIdentify(name) subviews
ComponentIdentify(name) components

and the most general one:

ElementIdentify(name) any named subpicture

If there are more objects with the same name, only the first one is identified.

 It should be noted, that the method ModelIdentify(), introduced in section XXXX, does not belong to
the above family of functions, because its parameters and returned value are quite different.

'…'
!viewHandle = !marDraft.viewIdentify('SECTION_FR190')
handle ANY
!marUi.messageConfirm('View not found!')
endhandle
'…'

The object's capturing methods also share some common properties.


All take a MarCaptureRegionPlanar() class as a parameter, and return a list, whose first element is the
number of handles found, and the remaining ones are the MarElementHandle() class instances being
the handles to the captured objects.

 When no object is captured, these methods raise an exception instead of returning a single-element
list [0] indicating that the number of captured objects is ZERO.

ViewCapturePML(region) views
SubviewCapturePML(region) subviews
ComponentCapturePML(region) components
ModelCapturePML(region) model objects
DimCapturePML(region) dimensioning components
NoteCapturePML(region) note components
PosnoCapturePML(region) position number components
HatchCapturePML(region) hatch components
GeometryCapturePML(region) geometries
ContourCapturePML(region) contours
TextCapturePML(region) text elements
SymbolCapturePML(region) symbols
PointCapture(region) points

 WARNING: While capturing the objects, only the visible layers are considered.
The region argument defines a closed contour and special properties of handling the captured object's
location with respect to the contour's boundary. The most important methods are listed below:
region.SetRectangle(rect) defines a rectangular region
region.SetContour(cont) defines an arbitrary closed contour as the region's boundary
region.SetInside() objects INSIDE the region will be captured
region.SetOutside() objects OUTSIDE the region will be captured
region.SetCut() objects crossing the region's boundary WILL be captured
region.SetNoCut() objects crossing the region's boundary WILL NOT be captured
www.aveva.com
© Copyright 1974 to current year. 34
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

Some other methods also return element handles (e.g. ModelHandleGetPML()). See the appropriate
definition in the User's Guide for details.

Example below show, how capture a view inside predefined rectangle:

'…'
using namespace 'Aveva.Marine.Ui'
!marUi = object MarUi()
using namespace 'Aveva.Marine.Drafting'
!marDraft = object MarDrafting()
using namespace 'Aveva.Marine.Geometry'

!p1 = object MarPointPlanar(-200,-200)


!p2 = object MarPointPlanar(600,600)
!marRec = object MarRectanglePlanar(!p1, !p2)
!region = object MarCaptureRegionPlanar()
!region.SetRectangle(!marRec)
!region.SetInside()
!region.SetCut()

!status = 1
!viewHandle = !marDraft.ViewCapturePML(!region)
handle ANY
!status = 0
endhandle
if (!status eq 1) then
!marUi.messageConfirm('View captured!')
else
!marUi.messageConfirm('View not found inside defined capture rectangle!')
!marUi.messageNoConfirm('Change rectangle or capture rectangle properties...')
endif
'…'

4.2.3 Retrieving element's information from the handle

Various kinds of drawing elements are represented by the appropriate classes. The following methods return
the information about the element referred to by a handle passed as an argument. The information is stored
in the attributes of the appropriate class instance representing the investigated element, and additionally, the
class instance is returned as the result.

4.2.3.1 Model

Selection at subpicture level:

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate panel...', !point)
do !n from 1 to 10
if (!pointResult eq !resultCodes.rejectPML()) then
!marUi.messageNoConfirm('Script aborted!')
break
else
!viewHandle = !marDraft.subviewIdentify(!point)
handle ANY
!marUi.messageNoConfirm('Panel not found!')
!pointResult = !marUi.pointPlanarReqPML('Indicate panel...', !point)
endhandle
endif
www.aveva.com
© Copyright 1974 to current year. 35
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

enddo

!mod = !marDraft.modelPropertiesGet(!viewHandle)
!marUi.messageConfirm('Selected panel: ' + !mod.name())
'…'

The method ModelPropertiesGet() stores the model information in the !mod parameter (MarModel()
class). If !viewHandle refers to the model's part, you may use also the attributes !mod.Name An
exception is raised, if the given handle does not identify a model object.

Selection at component level:

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate component...', !point)

do !n from 1 to 10
if (!pointResult eq !resultCodes.rejectPML()) then
!marUi.messageNoConfirm('Script aborted!')
break
else
!viewHandle = !marDraft.componentIdentify(!point)
handle ANY
!marUi.messageNoConfirm('Panel not found!')
!pointResult = !marUi.pointPlanarReqPML('Indicate component...', !point)
endhandle
endif
enddo

!mod = !marDraft.modelPropertiesGet(!viewHandle)
!marUi.messageConfirm('Selected: ' + !mod.name() + ', ' + !mod.PartType() + ': '
+ STRING(!mod.partIDPML()))
'…'

The method ModelPropertiesGet() stores the model information in the !mod parameter (MarModel()
class). If !viewHandle refers to the model's part, you may use also the attributes !mod.Name (name of
the selected element), !mod.PartType and !mod.partIDPML

4.2.3.2 Geometry

The next code returns the contour's definition from a handle. It will handle any kind of geometries, that can
be expressed as contours (e.g. straight line segments, arcs, circles, rectangles, squares, polylines).

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate contour...', !point)

!viewHandle = !marDraft.contourIdentify(!point)

!contour = !marDraft.contourPropertiesGet(!viewHandle)
!marUi.messageConfirm('Contour length = ' + STRING(!contour.Length()))
'…'

The method ContourPropertiesGet() stores the contour information in the !contour parameter,
which is MarContourPlanar() class instance.

www.aveva.com
© Copyright 1974 to current year. 36
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.2.3.3 Text

The method TextPropertiesGet() stores the text attributes into the MarText() class instance:

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate text...', !point)

!viewHandle = !marDraft.textIdentify(!point)

!text = !marDraft.textPropertiesGet(!viewHandle)
!marUi.messageConfirm('Selected text: ' + !text.String())
'…'

4.2.3.4 Symbol
In a similar way, we can get symbol properties, using the method SymbolPropertiesGet().
This method uses the MarSymbol() class instance to store the information:

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate symbol...', !point)

!viewHandle = !marDraft.symbolIdentify(!point)

!symbol = !marDraft.symbolPropertiesGet(!viewHandle)
!marUi.messageConfirm('Symbol font: ' + STRING(!symbol.FontIdPML()) + ', Number:
' + STRING(!symbol.SymbolIdPML()))
'…'

The Aveva.Marine.Drafting namespace contains more element handling methods using element handles
described here.

www.aveva.com
© Copyright 1974 to current year. 37
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

Exercise 3

Create a new PML function called exercise3. Function should be parameterized:


• Filter by model type of the indicated element (plane panel, curved panel etc)
• Filter by part type of the indicated element (planar plate, stiffener, flange etc)
• Information about returned result
• Message displayed

User should indicate interactive on screen model element (predefined model and part type)

Function should return:


• Panel name, if part type not predefined
• Panel name AND indicated component ID, if part type predefined

Call function as showed below:

q var !!exercise3('plane panel', 'stiffener', 2, 'Indicate panel stiffener')

Function should return similar to:

<ARRAY>
[1] <REAL> 2
[2] <STRING> 'F206-Z4500-01'
[3] <REAL> 6003

www.aveva.com
© Copyright 1974 to current year. 38
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.3 View Functions

The Aveva.Marine.Drafting namespace provides a set of functions dealing with model (symbolic views are
managed using dedicated methods) views.

Additional using namespace 'Aveva.Marine.Geometry' statement may be necessary if the selected


method uses other class instances as parameters (MarVector(), MarPoint(), and
MarPointPlanar())

4.3.1 Creating or identifying the view

All views in the drawing are uniquely identified by a handle (MarElementHandle() class instance). The
handle can be obtained either when the program itself creates the view, or by identifying an existing view by
its name, or by an identification point.

Handle when view is created:

'…'
using namespace 'Aveva.Marine.Geometry'
!vecU = object MarVector(0, -1, 0)
!vecV = object MarVector(0, 0, 1)

!viewHandle = !marDraft.ViewNew('PMLVIEW', !vecU, !vecV)


'…'

In the above example, the method ViewNew() returns a handle to a new view 'PMLVIEW', with the U and V
vectors defining the projection of a frame view with the viewer looking fore. The U and V vectors are optional
arguments. If omitted, the X and Y axis direction vectors will be used. The new view is always created in the
scale 1:1, with the origin at the position (0, 0) in the drawing form. Usually the view is then scaled and
displaced appropriately.

U and V vectors are located on the view's plane. U points to the right, V points up. Their cross-
product U × V indicates the direction towards the viewer. These vectors should be expressed in the
global coordinate system.

If user work on a view, that already exists in the drawing, its necessary to obtain its handle by using the
ViewIdentify() or ViewCapture() methods, described in section 4.2.2.

All the remaining view methods require a proper view handle as their first parameter. If the passed view
handle is not valid, an exception will be raised.

 WARNING: The view functions often use 2D points (MarPointPlanar() class) and 2D vectors
(MarVectorPlanar() class). They are always expressed in the drawing form co-ordinate system
(scale 1:1, origin at lower left corner of the drawing form, U-axis pointing to the right, V-axis pointing
up), not in the given view's co-ordinate system!
www.aveva.com
© Copyright 1974 to current year. 39
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.3.2 Transforming the view

The views can be displaced, scaled, reflected and rotated.

4.3.2.1 Move view

The method ViewMove() moves a view by a !vector:

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.viewIdentify(!point)

!p1 = object MarPointPlanar(0,0)


!p2 = object MarPointPlanar(800,800)
!vector = object MarVectorPlanar()
!vector.SetFromPoints(!p1, !p2)

!marDraft.ViewMove(!handle, !vector)
!marDraft.DwgRepaint()
'…'

4.3.2.2 Change view scale

The method ViewScale() scales a view around a given centre. !handle is Handle to the view, !factor
is the scale factor (relative)

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.viewIdentify(!point)
!factor = 0.5
!marDraft.ViewScale(!handle, !factor)
'…'

Third argument !centre (not shown in example above) is optional. If omitted, defaults to the centre of the
axis-parallel rectangle circumscribing the view's contents.

4.3.2.3 Reflect view

The reflection of the view with respect to the U or V axes can be done with the method shown below:

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.viewIdentify(!point)
!reflect = 1
!marDraft.ViewReflect(!handle, !reflect)
'…'

The !reflect argument can be either 1 (reflection in the U-axis passing through the centre), or 2
(reflection in the V-axis passing through the centre).

 The third argument !centre is optional. If omitted, defaults to the centre of the axis-parallel rectangle
circumscribing the view's contents.
www.aveva.com
© Copyright 1974 to current year. 40
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.3.3 View projection

The final result of a sequence of view transformations is defined as a MarTransformation() object,


which can be obtained using the method ViewProjectionGet()

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.viewIdentify(!point)

!trans = !marDraft.ViewProjectionGet(!handle)
!origin = object MarPoint(!trans.matrix41(), !trans.matrix42(),
!trans.matrix43())
!marUi.messageConfirm('X = ' + STRING(!origin.X()) + ', Y = ' +
STRING(!origin.Y()) + ', Z = ' + STRING(!origin.Z()))
'…'

In the above example, it’s additionally derived the location of the origin of the view's co-ordinate system. In a
similar manner, can obtained the U, V, and W vectors of this co-ordinate system.

It is possible to change the projection of an existing view by providing new U and V vectors, and calling the
method ViewProjectionSet(). Similar consideration should be taken, regarding these vectors, like for
the method ViewNew().

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.viewIdentify(!point)

!trans = !marDraft.ViewProjectionGet(!handle)
!vecU = object MarVector(!trans.matrix11(), !trans.matrix21(),
!trans.matrix31())
!vecV = object MarVector(!trans.matrix12(), !trans.matrix22(),
!trans.matrix32())
!vecU.BlankProduct(-1.0)
!marDraft.ViewProjectionSet(!handle, !vecU, !vecV, 0)
!marDraft.DwgRepaint()
'…'

!vecU.BlankProduct(-1.0) - vector U becomes -U, we change the looking direction

The last, optional argument is an integer, determining the draw codes to be used. The value 0 means, that
draw codes stored in the model subviews should be used. The value 1 means, that default draw codes
should be used. If omitted, defaults to 1.

For symbolic views (see section 4.3.4) there is another method for retrieving the model's transformation
matrix:

ViewSymbolicModelTra()

which is used exactly in the same way, as the method ViewProjectionGet().

www.aveva.com
© Copyright 1974 to current year. 41
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.3.4 Symbolic views

It is possible to create symbolic view using PML program:

'…'
using namespace 'Aveva.Marine.Drafting'
!marDraft = object MARDRAFTING()

using namespace 'Aveva.Marine.Geometry'


!locPoint = object MarPoint(152000, 0, 0)
!vecU = object MarVector(0, 1, 0)
!vecV = object MarVector(0, 0, 1)
!boxOri = object MarPoint(151000, -20000, 0)
!box = object MarBox(!boxOri, !vecU, !vecV, 40000, 40000, 20000)
!forw = 100
!backw = 100
!name = 'PMLSYMBOLICVIEW'
!handle = !marDraft.ViewSymbolicNew(!name, !locPoint, !vecU, !vecV, !forw,
!backw, !box)
'…'

The above example creates the symbolic view in the X plane with the cutting plate passing through
!locPoint, slice depths !forw and !backw, and the given restriction !box (X: 151000 - 153000, Y: -
20000 - 20000, Z: 0 - 40000).

The method ViewSymbolicNew() creates a new symbolic view in the drawing, and returns its handle as
the MarElementHandle() class instance. Model items or their parts located outside the !box will not be
drawn, when using the method ModelDraw(). The box location and dimensions are specified in the ship's
co-ordinate system. The U and V vectors must not be parallel, and their crossproduct (U × V) defines the
direction towards the viewer. If the current drawing already contains a view with the same name, as given by
the !name parameter (if not empty), an exception is raised.

A better control on the creation of the symbolic view can be achieved by using the instance of the
MarSymbolicView() class (Aveva.Marine.Drafting.MarInterpretationObject namespace) instead of
providing all the arguments shown above.

'…'
using namespace 'Aveva.Marine.Geometry'
using namespace 'Aveva.Marine.Drafting.MarInterpretationObject'

!viewOpt = object MarSymbolicView()


!viewOpt.ViewName('PMLSYMBOLICVIEW')
!viewOpt.SetPlaneByX(152000)
!viewOpt.AutomaticSelectionPML(1)
!viewOpt.ShellCurvesPML()

!handle = !marDraft.ViewSymbolicNew(!viewOpt)
'…'

 WARNING: After creation, the symbolic view is not shown in the drawing. Add the following
fragment of code to make it appear in the drawing.

'…'
!trans = object MarTransformationPlanar()
!marDraft.ElementTransform(!handle, !trans)
'…'

Applying an identity transformation to a drawing element makes it appear in the drawing (the element is
redrawn). See section 4.11 for a description of the function MarElementTransform().www.aveva.com

© Copyright 1974 to current year. 42


AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.3.5 View slice depth

It is possible to obtain the values of the slice depths for a symbolic view (also for a sliced model view) using
the method:

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.viewIdentify(!point)

!code = REAL()
!fslice = REAL()
!bslice = REAL()

!marDraft.ViewSlicedepthGet(!handle, !code, !fslice, !bslice)


!marUi.messageNoConfirm(STRING(!code))
!marUi.messageNoConfirm(STRING(!fslice))
!marUi.messageNoConfirm(STRING(!bslice))
'…'

The method returns as follow:


!code - 0 - no slice depth returned; 1 - slice depth returned for model view; 2 - forward and backward slice
depth returned for symbolic view
!fslice, !bslice - forward and backward slice depths

The slicing planes can be retrieved using the method ViewSlicePlanesGetPML()

'…'
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.viewIdentify(!point)
!slices = !marDraft.ViewSlicePlanesGetPML(!handle)
$P $!slices[1]
'…'

The result is a array of two MarPlane() class instances, that have the information about the plane (the
origin point and the normal vector).

4.4 Model handling methods

In all model handling methods a MarModel() class is used.

4.4.1 Drawing model objects

Model object can be drawn on the views using the method ModelDraw().

'…'
!vecU = object MarVector(0, 1, 0)
!vecV = object MarVector(1, 0, 0)
!handle = !marDraft.ViewNew('PMLDRAWMODEL', !vecU, !vecV)
!model = object MarModel()
!model.Type('plane panel')
!model.Name('F206-DK2')
!model.PartIdPML(0)
!marDraft.ModelDraw(!model, !handle)
'…'
www.aveva.com
© Copyright 1974 to current year. 43
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

!model object or its part is drawn. In order to draw the whole model, provide the MarModel() class
instance with the correct Type() and Name() properties, and with PartIdPML() set to 0 (default). If the
PartIdPML() propertie is not zero, only the given part of the model is drawn.

 In the case of plane panels, the parts like the holes and cutouts cannot be drawn separately.
4.4.2 Identifying and collecting model objects

The method ModelIdentify() looks around the given !point, and identifies the closest model object,
filling the provided !model argument with the information about the identified model object.

!modelSubView will contain handle to subview, !modelComponent handle to closest to indicated point
component. These handles can be used, for example for highlighting the given model or its component
before asking for confirmation, removing the given model from the drawing, etc.

'…'
!point = object MarPointPlanar()
!model = object MarModel()
!modelSubView = object MarElementHandle()
!modelComponent = object MarElementHandle()
!pointResult = !marUi.pointPlanarReqPML('Indicate panel...', !point)
!marDraft.ModelIdentify(!point, !model, !modelSubView, !modelComponent)
!marUi.messageNoConfirm(!model.Name())
'…'

The method ModelCapture(), mentioned in section 4.2.2, returns the list of handles to model objects
captured in the !region given as an argument.

'…'
!p1 = object MarPointPlanar(-200,-200)
!p2 = object MarPointPlanar(600,600)
!marRec = object MarRectanglePlanar(!p1, !p2)
!region = object MarCaptureRegionPlanar()
!region.SetRectangle(!marRec)
!region.SetInside()
!region.SetCut()
!status = 1
!viewHandle = !marDraft.ModelCapturePML(!region)
handle ANY
!status = 0
endhandle
if (!status eq 1) then
!marUi.messageConfirm('Model captured!')
else
!marUi.messageConfirm('Model not found inside defined capture rectangle!')
endif
do !x value !viewHandle
!model = !marDraft.modelPropertiesGet(!x)
!marUi.messageNoConfirm('Captured: ' + !model.Name())
enddo
'…'

 WARNING: Notice, that this method returns a list of handles, not MarModel() class!
Fortunately, the program can get an information about each handle in the list by calling the method
ModelPropertiesGet(), described in section 4.2.3.1

www.aveva.com
© Copyright 1974 to current year. 44
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

AVEVA Marine PML customization provides also the reverse operation. It is possible to get handles of all
subviews (components) containing the given model (its part) by calling the method ModelHandleGet(),
providing the MarModel() class instance as an argument.

If PartIdPML() is zero, the method returns the list !res of all handles to the subviews containing the
given model. If PartIdPML() is not zero, the resulting list contains all handles to the component
subpictures containing the given part.

The example below removes the given !model (plane panel F260-DK2) from all views, using the method
ElementDelete().

'…'
!model = object MarModel()
!model.Type('plane panel')
!model.Name('F206-DK2')

!res = !marDraft.ModelHandleGetPML(!model)

do !x value !res
!marDraft.ElementDelete(!x)
enddo
'…'

The example below removes the given !model (plane panel F260-DK2, stiffener ID=6003) from all views

'…'
!model = object MarModel()
!model.Type('plane panel')
!model.Name('F206-DK2')
!model.PartIDPML(6003)

!res = !marDraft.ModelHandleGetPML(!model)

do !x value !res
!marDraft.ElementDelete(!x)
enddo
'…'

4.4.3 Deleting model objects

There is a simpler way to remove model objects from the drawing. In order to remove the given model object
from the view (or from the whole drawing), the method ModelDelete() should be used. The above
example could be replaced by lines:

'…'
!model = object MarModel()
!model.Type('plane panel')
!model.Name('F206-DK2')

!marDraft.ModelDelete(!model)
'…'

If you want to remove a model object from the given view only, provide the view handle as the second
argument - then the other occurrences of the given model object will not be removed:

'…'
!point = object MarPointPlanar()
!pointResult = !marUI.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.ViewIdentify(!point)
www.aveva.com
© Copyright 1974 to current year. 45
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

!model = object MarModel()


!model.Type('plane panel')
!model.Name('F206-DK2')

!marDraft.ModelDelete(!model, !handle)
'…'

4.4.4 Modifying model object modal properties

Each subview containing a model object has the following properties: the color, and the layer. They can be
changed using the methods:

ModelColourSet(model, color, viewHandle)


ModelLayerSet(model, layer, viewHandle)

where model is a MarModel() class, describing the model object itself, color is the MarColour() class,
describing its new color, layer is the MarLayer class instance describing its new layer, and viewHandle is the
handle to the view, on which the given update should be made. viewHandle is an optional argument, and
the change will be made to ALL views, if this argument is omitted.

'…'
!model = object MarModel()
!model.Type('plane panel')
!model.Name('F206-DK2')

!colour = object MarColour('Black')

!point = object MarPointPlanar()


!pointResult = !marUI.pointPlanarReqPML('Indicate view...', !point)
!viewHandle = !marDraft.ViewIdentify(!point)

!marDraft.ModelColourSet(!model, !colour, !viewHandle)


'…'

4.5 Basic Geometry Entities

The methods in this section provide the means of creating the basic geometry elements in the current
drawing, highlighting them, and setting the general modal properties of these elements. The PML
customization provides methods for setting and reading the modal properties such as: color, line type, layer.

Every geometry element, when created, obtains an associated handle (MarElementHandle() class
instance), which is used then for all manipulation of the given element. All geometry elements are drawn
using current values of the modal properties.

4.5.1 Modal properties

The modal properties are handled by a family of methods, reading the current values and setting new ones.
The example below manages the modal color, !oriColour retrieve and store current color:

'…'
!oriColour = !marDraft.ColourGet()
!newColour = object MarColour('Magenta')
!marDraft.ColourSet(!newColour)
'…'
ww.aveva.com www.aveva.com
© Copyright 1974 to current year. 46
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

and this one – the modal line type

'…'
!oriLine = !marDraft.LinetypeGet()
!newLine = object MarLinetype('DashedWide')
!marDraft.LinetypeSet(!newLine)
'…'

The methods below manage the display settings of various line types (line thickness, patterns, etc.). They
use an instance of the MarLineTypeDisplaySettings() class.

'…'
!lineSettings = !marDraft.LineTypeDisplaySettingsGet()
!dashedWidth = !lineSettings.DashedAndSolidWidth()
!lineSettings.DashedAndSolidWidth(!dashedWidth * 2)
!marDraft.LineTypeDisplaySettingsSet(!lineSettings)
'…'

The last modal attribute is the layer. The example below shows the methods managing the modal layer.

'…'
!oriLayer = !marDraft.LayerGet()
!newLayer = object MarLayer(999)
!marDraft.LayerSet(!newLayer)
'…'

4.5.2 Creation of basic geometry entities

The functions listed below draw the basic geometry entities given as an argument, and return the handle to
the created entity as the MarElementHandle() class instance. The entity is PERMANENT, i.e. it will stay
in the drawing until removed explicitly. All geometric entities are drawn using current values of the general
modal properties.

Marine.Geometry namespace
Method Geometric entities class
ArcNew(arc) arcs MarArcPlanar
CircleNew(arc) circles MarCirclePlanar
ConicNew(conic) conic segments MarConicPlanar
ContourNew(contour) contours MarContourPlanar
EllipseNew(ellipse) ellipses MarEllipsePlanar
LineNew(line) line segments MarRlinePlanar
PointNew(point) points MarPointPlanar
RectangleNew(rectangle) rectangles MarRectanglePlanar
RectangleNew(rect, radius) rectangles rounded corners MarRectanglePlanar
SplineNew(points) spline curves MarPolygonPlanar

The ArcNew() method raises an exception 'Mar_AmplitudeTooBig', if the amplitude defined in the
MarArcPlanar() class instance is too big (greater than half of the distance between the arc's endpoints).

The same does the method ContourNew(), when one of the contour arc segments has an amplitude too
big.

The RectangleNew() method draws the axis-parallel rectangle, optionally with rounded corners, if the
radius argument is provided.

The SplineNew() method draws the spline curve without any tangent restrictions at the node points.
www.aveva.com
© Copyright 1974 to current year. 47
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
!p1 = object MarPointPlanar(100,50)
!p2 = object MarPointPlanar(200,50)
!arc1 = object MarArcPlanar(!p1, !p2, 50)
!arc2 = object MarArcPlanar(!p1, !p2, -50)

if (!marDraft.DwgCurrent()) then
!arcHandle = !marDraft.ArcNew(!arc1)
!arcHandle = !marDraft.ArcNew(!arc2)
else
!marDraft.MessageConfirm('Open drawing / Create a new drawing')
endif
'…'

Thanks to the use of DwgCurrent() method in example above, it’s make sure that there is a current
drawing.

 The circle radius, if keyed in by the user, does NOT take into account the scale factor of the given
view, but uses the scale 1:1. The program must handle the proper scaling by itself.

 All created entities are attached to the current subpicture. See the methods in section 4.10, which
allows create subpictures and set the current subpicture for adding new geometry entities.

4.5.3 Entity properties

The geometry elements, whose creation is described in the last section, are drawn using the current values
of modal attributes: color, line type, and layer. Fortunately, there is a way to retrieve this information from
already existing elements, and update it. In the examples below, !handle refers to the drawing element,
whose properties are manipulated. This is how it’s possible manipulate element layer (identify drawing
geometry).

'…'
!point = object MarPointPlanar()
!pointResult = !marUI.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.GeometryIdentify(!point)

!layer = !marDraft.ElementLayerGet(!handle)
!newLayer = object MarLayer(888)
!marDraft.ElementLayerSet(!handle, !newLayer)
'…'

... color ...

'…'
!point = object MarPointPlanar()
!pointResult = !marUI.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.GeometryIdentify(!point)

!layer = !marDraft.ElementColourGet(!handle)
!newColour = object MarColour('Red')
!marDraft.ElementColourSet(!handle, !newColour)
'…'

... and line type ...

'…'
!point = object MarPointPlanar()
!pointResult = !marUI.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.GeometryIdentify(!point) www.aveva.com
© Copyright 1974 to current year. 48
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

!layer = !marDraft.ElementLinetypeGet(!handle)
!newLine = object MarLinetype('Dashed')
!marDraft.ElementLinetypeSet(!handle, !newLine
'…'

 The methods given here can be used not only with handles referring to the basic geometry entities,
but also to other drawing elements, like: texts, symbols, notes, position number, hatchings,
dimensions, views, subviews, components, etc.

4.5.4 Highlighting elements

AVEVA Marine system uses highlighting of the drawing entities for indication of the selected entity
(transformations, deletions, etc.). The same possibility is available to the PML programmer through the
highlighting methods described below:

Marine.Geometry namespace
Method Geometric entities class
ArcHighlight(arc) arcs MarArcPlanar
CircleHighlight(arc) circles MarCirclePlanar
ConicHighlight(conic) conic segments MarConicPlanar
ContourHighlight(contour) contours MarContourPlanar
EllipseHighlight(ellipse) ellipses MarEllipsePlanar
LineHighlight(line) line segments MarRlinePlanar
PointHighlight(point) points MarPointPlanar
RectangleHighlight(rectangle) rectangles MarRectanglePlanar
SplineHighlight(points) spline curves MarPolygonPlanar

where object is an instance of the corresponding geometry class, containing the definition of the entity to
draw highlighted. All the above methods draw a new highlighted entity and return an
MarElementHandle() class instance. This handle should be saved, because it is required, when
highlighting is turned off. Turning off the highlight removes the entity from the drawing.

 Note, that contrary to the XXXNew() methods, which draw PERMANENT basic geometry entities,
the highlighting functions draw TEMPORARY basic geometry entities, which disappear
automatically from the drawing, when their highlight is turned off.

The method PointHighlight() accepts an optional second argument, which determines the point's
shape: the value of 1 causes a small cross to be drawn, whereas other values (default) draw the point as a
small circle.

Additionally there is a method, which highlights arbitrary drawing’s elements, given their handles, not
definition. The argument can be either a single MarElementHandle() class instance, or a list of such
elements.

ElementHighlight(handle)
ElementHighlight(handleList)

The examples below highlights a model object identified by the ModelIdentify() method, which
provides the handle to the subpicture of the indicated model object.

'…'
do
!point = object MarPointPlanar()
!model = object MarModel()
!modelSubView = object MarElementHandle() www.aveva.com
© Copyright 1974 to current year. 49
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

!modelComponent = object MarElementHandle()


!pointResult = !marUI.pointPlanarReqPML('Indicate panel...', !point)
!marDraft.ModelIdentify(!point, !model, !modelSubView, !modelComponent)
!highlightHandle = !marDraft.ElementHighlight(!modelSubView)
!res = !marUi.AnswerReqPML('Panel selection', 'Selected: ' + !model.Name())
if (!res eq !marUtil.YesPML()) then
!marUi.MessageNoConfirm('Selected: ' + !model.Name())
!marDraft.HighlightOff(!highlightHandle)
break
elseif (!res eq !marUtil.NoPML()) then
!marDraft.HighlightOff(!highlightHandle)
endif
enddo
'…'

This method highlights an already existing entity identified by its handle (MarElementHandle() class),
and returns the highlight's handle, which must be used for turning the highlight off. In this case, however,
turning off the highlight does not remove the entity from the drawing, because the entity had existed already
before it has been highlighted, but rather it causes the entity to be redrawn in its normal
colors.

 The method ElementHighlight() can be used for highlighting not only basic geometric entities, but in
fact every drawing item identifiable by a handle (model items and their parts, views, texts, symbols,
notes, position numbers, hatch patterns, etc.)

When highlighting is to be turned off, there is a general function to do this.

HighlightOff(handle)
www.aveva.com
This method turns off the highlighting of the given entity defined by its highlight's handle. To turn the
highlight from ALL highlighted items, call:

HighlightOff(0)

The entities highlighted using the method ElementHighlight() are simply redrawn in their normal
colors, whereas all other highlighted entities disappear from the drawing.

www.aveva.com
© Copyright 1974 to current year. 50
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

Exercise 4

Open function created in exercise 3.

Add lines for selected element highlight.

www.aveva.com
© Copyright 1974 to current year. 51
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.6 Texts

The PML program can easily create text in the current drawing with full control over such text modal
properties as height, rotation and slanting angle, aspect ratio, text & vector font numbers, and interline
spacing factor. The current general modal properties like the color, line type, and layer are also taken into
account.

4.6.1 Modal properties

The text drawing elements have the following modal properties: text height, rotation angle, slanting angle,
aspect ratio, font number (both ASCII and Vector), and or multi-line texts – the inter-line spacing. For every
text modal attribute, there is a pair of functions: one setting the new value of the attribute (set), and another
– reading the current value of the attribute (get).

'…'
!height = !marDraft.TextHeightGet()
!marDraft.TextHeightSet(5.0)
!rotation = !marDraft.TextRotationGet()
!marDraft.TextRotationSet(30)
!aspect = !marDraft.TextAspectGet()
!marDraft.TextAspectSet(0.8)
!slanting = !marDraft.TextSlantGet()
!marDraft.TextSlantSet(70)
!ascii = !marDraft.TextAsciiFontGetPML()
!marDraft.TextAsciiFontSetPML(101)
!ilsp = !marDraft.TextIlspGet()
!marDraft.TextIlspSet(1.5)
'…'

Text height is given in the 1:1 scale (text size on the un-scaled print-out). Angles are given in degrees.
Aspect ratio of 1.0 means the standard proportions of the letters. Larger values mean the wider text, lower
values – narrower text. Vector fonts are used in multi-byte languages (e.g. Japanese). Inter-line spacing
factor values can be negative – then the consecutive lines of text will be positioned in the opposite direction
(upwards).

 To select a TrueType font (e.g. Arial) for drawing text elements, use the method DefaultValueSet()
and set the TEXT_FONT Drafting default to the proper font name.

Note, that the text height represents the height of the capital letter (e.g. 'M'). This does not take into account
the additional space occupied by characters drawn below the text baseline (e.g. 'p', 'j', 'q', etc.).

4.6.2 Text Creation

In a similar way as the basic geometric entities, the PML program can create text in the drawing. The text is
created using the current values of the modal text properties. Multi-line texts also to be handled by the
program.

'…'
!text = 'This is an example
of a multi-line
text'
!point = object MarPointPlanar(50, 50)
!marDraft.TextNew(!text, !point)
'…'

or www.aveva.com
© Copyright 1974 to current year. 52
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
!text = object MarText('Example text')
!point = object MarPointPlanar(50, 50)
!text.Position(!point)
!marDraft.TextNew(!text)
'…'

 The MarText() class handles the attributes of the given text drawing element, including the string
and position on the drawing.

The TextNew() method creates a new text element in the current drawing, and returns its handle as the
MarElementHandle() class instance.

The use of the MarText() class allows us the obtain easily the length of the text. This can be useful for
determining the column width of a table placed in the drawing, sizing the rectangle to be drawn around the
text, etc.

'…'
!text = object MarText('Example text')
!p1 = object MarPointPlanar(50, 50)
!text.Position(!p1)
!textLength = !marDraft.TextLength(!text)
!textHandle = !marDraft.TextNew(!text)
!p2 = object MarPointPlanar(!p1.X() + !textLength + 2,!p1.Y() +!text.Height()+2)
!p1 = object MarPointPlanar(!p1.X() - 1, !p1.Y() - 1)
!rectangle = object MarRectanglePlanar(!p1, !p2)
!handle = !marDraft.RectangleNew(!rectangle)
'…'

 For multi-line text elements, the method TextLength() returns the length of the FIRST text line, also
when one of the next text lines is longer than the first. For computing the width of the multi-line text
element we have to split the text into single lines, calculate their lengths, and select the biggest one.

If current drawing contains the drawing rules (e.g. $2102), it is possible to set the text for these rule text
elements, as shown below:

!handle = RuleTextNew("Ronaldinio", 2102)

4.7 Symbols

The PML program is able to put symbols in the drawing, and control their height and rotation angle.

4.7.1 Modal properties

The examples below demonstrate, how to control the symbol's height:

'…'
!symbHeight = !marDraft.SymbolHeightGet()
!marDraft.SymbolHeightSet(2.0 * !symbHeight)
'…'

and rotation angle:’


www.aveva.com
© Copyright 1974 to current year. 53
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
!symbRotation = !marDraft.SymbolRotationGet()
!marDraft.SymbolRotationSet(45.0)
'…'

Symbol height is the symbol size on the printout (un-scaled). Rotation angle is expressed in degrees.

4.7.2 Symbols creation

AVEVA Marine PML customization provides the method SymbolNew(), which draws a new symbol in the
drawing and returns its handle. Possible ways of using this function are shown below:

'…'
!p1 = object MarPointPlanar(60, 60)
!fontNb = 8
!symbolNb = 46
!handle = !marDraft.SymbolNew(!fontNb, !symbolNb, !p1)
'…'

or

'…'
!p1 = object MarPointPlanar(70, 70)
!fontNb = 8
!symbolNb = 46
!symbol = object MarSymbol(!fontNb, !symbolNb)
!symbol.Position(!p1)
!symbol.Rotation(60)
!handle = !marDraft.SymbolNew(!symbol)
'…'

The first variant uses the current settings of modal attributes, whereas the second one uses the attributes
stored in the MarSymbol() class instance (rotation angle, height, visibility, reflection, etc.)

4.8 Drawing components

AVEVA Marine supports creating four kinds of drawing components: hatchings, notes, position numbers,
and dimensions. All these components are created as level 3 subpictures attached to the closest subview.

4.8.1 Hatching
The modal hatch pattern can be defined in three ways, as in any AVEVA Marine application:

• as one of the standard hatch patterns,


• as the angle and distance between the hatch pattern lines,
• as the hatch pattern from the Standard Hatch Pattern Book

4.8.1.1 Modal properties and adding hatching to the contour

The only modal property specific to hatching elements is the hatching pattern. Of course, the hatching
methods take also the current modal color, line type and layer into consideration. The function shown
below sets one of the standard hatch patterns

StdHatchPatternSet(type)

where type takes one of the following values:


www.aveva.com
© Copyright 1974 to current year. 54
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

1 – single line hatching (HATCH_ANG_PAT1)


2 – single line hatching (HATCH_ANG_PAT2)
3 – cross hatching (HATCH_ANG_CROSS)

'…'
!point = object MarPointPlanar()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.GeometryIdentify(!point)

!marDraft.StdHatchPatternSet(3)
!hatchHandle = !marDraft.HatchNew(!handle)
'…'

If other inclination angles or distances between the lines are required, method can be used:

HatchPatternSet(angle, distance)

where user provide proper values for the line inclination angle (in degrees) and the distance between the
lines (in mm).

'…'
!point = object MarPointPlanar()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!handle = !marDraft.GeometryIdentify(!point)

!marDraft.HatchPatternSet(55, 3)
!hatchHandle = !marDraft.HatchNew(!handle)
'…'

AVEVA Marine supports the standard book of hatching patterns, where we can store subpictures to be used
as hatching patterns. When calling the method

UserdefHatchPatternSet(page, detail)

we have to provide the proper page and pattern number from the Standard Hatch Pattern Book.

The part of the given hatch pattern can be removed by providing original hatching handle and the island's
contour or its handle.

'…'
!p1 = object MarPointPlanar()
!pointResult = !marUi.pointPlanarReqPML('Indicate geometry...', !p1)
!handleGeo = !marDraft.GeometryIdentify(!p1)
!handleHatch = !marDraft.HatchNew(!handleGeo)

!p2 = object MarPointPlanar()


!pointResult = !marUi.pointPlanarReqPML('Indicate island geometry...', !p2)
!handleIsland = !marDraft.GeometryIdentify(!p2)

!handle = !marDraft.HatchIslandNew(!handleHatch, !handleIsland)


'…'

The method HatchIslandNew() removes the part of the given hatch pattern that lies inside a given
island, defined by a closed 2D contour, or its handle, and returns the handle to the modified hatch pattern
component as the MarElementHandle() class.

www.aveva.com
© Copyright 1974 to current year. 55
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.8.2 Notes and position numbers

The Aveva.Marine.Drafting namespace provides methods for creating notes and position numbers, as well
as for defining the modal properties of their symbols.

4.8.2.1 Modal properties

'…'
!noteSymbol = !marDraft.NoteSymbolGetPML()
!marDraft.NoteSymbolSetPML(33)
!posnoSymbol = !marDraft.PosnoSymbolGetPML()
!marDraft.PosnoSymbolSetPML(62)
'…'

Symbols used for notes and position numbers are restricted to the system font 21. The valid note symbols
are in a range 31 – 60 (or –1 to suppress the note symbol). For position numbers, symbols in the range 61-
80 can be used.

'…'
!oldHeight = !marDraft.PosnoHeightGet()
!marDraft.PosnoHeightSet(!oldHeight * 2)
'…'

 If the given symbol does not fall in the right range, the exception is raised. AVEVA Marine provides
an alternative symbol font for note and position number symbols (font #41). It will be used instead of
the system font 21, if the Drafting default keywords NOTE_SYMB_EXTENDED_RANGE or
POSNO_SYMB_EXTENDED_RANGE are set. Then the interval 1-400 is foreseen for note symbols,
401-500 for note "start" symbols, 501-600 for note "end" symbols, and 601-999 for position number
symbols.

4.8.2.2 Creating notes and position numbers

The methods given below create notes and position numbers using current values of the modal properties.

'…'
!point = object MarPointPlanar(0,0)
!line = object MarPolygonPlanar(!point)
!point.SetCoordinates(20,30)
!line.AddPoint(!point)
!point.Move(10,0)
!line.AddPoint(!point)
!handle = !marDraft.NoteNew('Note text', !line)
'…'

In order to put a position number instead of a note, just replace the last line with the following one

'…'
!handle = !marDraft.PosnoNew('56', !line)
'…'

It is possible to move the reference symbol of an existing note or position number to the new position using
the method ReferenceMove()

'…'
!p1 = object MarPointPlanar()
!pointResult = !marUi.pointPlanarReqPML('Indicate position number...', !p1)
!handle = !marDraft.PosnoIdentify(!p1)
www.aveva.com
© Copyright 1974 to current year. 56
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

!point = object MarPointPlanar(250,100)


!marDraft.ReferenceMove(!handle, !point)
'…'

4.8.3 Dimensioning

This section describes the methods used to create dimensioning components.

The Aveva.Marine.Drafting namespace provides the methods creating linear, angle, radius and diameter
dimensioning components. The current values of the Marine Drafting defaults are taken into account.
These methods take ‘geometric’ class instances as parameters (MarPointPlanar(),
MarVectorPlanar(), MarPoint(), MarVector(), etc.), and return a handle to the created component
as an MarElementHandle() class.

4.8.3.1 2D dimensioning components

2D linear dimensions are created, as shown below:

!p = object MarPointPlanar(x1, y1)


!points = object MarPolygonPlanar(!p)
!p = object MarPointPlanar(x2, y2)
!points.AddPoint(!p) #… add more measure points, if necessary
!direction = object MarVectorPlanar(1, 0) #example: horizontal dimension
!position = object MarPointPlanar(measureX, measureY)
!handle = !marDraft.DimLinearNew(!points, 1, !direction, !position)

The MarPolygonPlanar() class instance points is a collection of measure points; direction determines,
whether the dimension is horizontal (1, 0), vertical (0, 1), or parallel (other – parallel to the dimension line);
position defines the location of the measuring line. The second argument determines the type of a
dimension:
1 – normal,
2 – chain,
3 – staircase

The method creates the linear 2D dimensioning component, given the set of measure points. The dimension
line will be parallel to direction vector, and will pass through the position point.

'…'
!p1 = object MarPointPlanar(10,10)
!points = object MarPolygonPlanar(!p1)
!p2 = object MarPointPlanar(100,10)
!points.AddPoint(!p2)

!direction = object MarVectorPlanar(1, 0)


!position = object MarPointPlanar(55,5)
!point = object MarPointPlanar(250,100)

!handle = !marDraft.DimLinearNew(!points, 1, !direction, !position)


'…'

In a similar way, can be defined and drawn an angle dimension

!p0 = object MarPointPlanar(x0, y0)


!p1 = object MarPointPlanar (x1, y1)
!line1 = object MarRlinePlanar(!p0, !p1) #first arm of the angle
!p2 = object MarPointPlanar (x2, y2)
!line2 = object MarRlinePlanar (p0, p2) #second arm of the angle
!arcPos = object MarPointPlanar (arcPosX, arcPosY) #measure arc location
!textPos = object MarPointPlanar (textPosX, textPosY) #measure text location www.aveva.com
© Copyright 1974 to current year. 57
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

!handle = !marDraft.DimAngleNew(!line1, !line2, !arcPos, !textPos)

The method creates the 2D angular dimensioning component, given two non-parallel lines. If line1 and
line2 are parallel, an exception is raised.

'…'
!p0 = object MarPointPlanar(10,10)
!p1 = object MarPointPlanar(100,10)
!line1 = object MarRlinePlanar(!p0, !p1)
!p2 = object MarPointPlanar(100,60)
!line2 = object MarRlinePlanar(!p0, !p2)
!arcPos = object MarPointPlanar(70,20)
!textPos = object MarPointPlanar(75,30)

!handle = !marDraft.DimAngleNew(!line1, !line2, !arcPos, !textPos)


'…'

The method DimDiameterNew() creates the diameter-dimensioning component, given either a circle or
an arc. By specifying both pos1 and pos2 can be created a ‘knuckled’ dimensioning component, whose
reference line passes through pos1 and then, horizontally, through pos2.

www.aveva.com
© Copyright 1974 to current year. 58
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
!p1 = object MarPointPlanar(100,50)
!p2 = object MarPointPlanar(200,50)
!arc1 = object MarArcPlanar(!p1, !p2, 50)
!arc2 = object MarArcPlanar(!p1, !p2, -50)

if (!marDraft.DwgCurrent()) then
!arcHandle = !marDraft.ArcNew(!arc1)
!arcHandle = !marDraft.ArcNew(!arc2)
else
!marDraft.MessageConfirm('Open drawing / Create a new drawing')
endif
!pos1 = object MarPointPlanar(180,80)
!pos2 = object MarPointPlanar(200,100)

!dimHandle = !marDraft.DimDiameterNew(!arc2, !pos1, !pos2)


'…'

The pos2 (or both pos2 and pos1) parameter can be omitted and the method takes the default location of
the reference line (straight, not ‘knuckled’).

'…'
!p1 = object MarPointPlanar(100,50)
!p2 = object MarPointPlanar(200,50)
!arc1 = object MarArcPlanar(!p1, !p2, 50)
!arc2 = object MarArcPlanar(!p1, !p2, -50)

if (!marDraft.DwgCurrent()) then
!arcHandle = !marDraft.ArcNew(!arc1)
!arcHandle = !marDraft.ArcNew(!arc2)
else
!marDraft.MessageConfirm('Open drawing / Create a new drawing')
endif

!dimHandle = !marDraft.DimDiameterNew(!arc2)
'…'

 A more detailed description can be found in the AVEVA Marine User’s Guide.

In a similar way, can be created radius-dimensioning components:

handle = !marDraft.DimRadiusNew(circle, pos1, pos2)

or

handle = !marDraft.DimRadiusNew (arc, pos1, pos2)

The pos1 and pos2 points are used in a similar way as in the previous method.

www.aveva.com
© Copyright 1974 to current year. 59
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
!p1 = object MarPointPlanar(100,50)
!p2 = object MarPointPlanar(200,50)
!arc1 = object MarArcPlanar(!p1, !p2, 50)
!arc2 = object MarArcPlanar(!p1, !p2, -50)

if (!marDraft.DwgCurrent()) then
!arcHandle = !marDraft.ArcNew(!arc1)
!arcHandle = !marDraft.ArcNew(!arc2)
else
!marDraft.MessageConfirm('Open drawing / Create a new drawing')
endif
!pos1 = object MarPointPlanar(180,80)
!pos2 = object MarPointPlanar(200,100)

!dimHandle = !marDraft.DimRadiusNew(!arc2, !pos1, !pos2)


'…'

4.8.3.2 3D dimensioning components

PML customization is able also to create 3D dimensioning components. The method below creates and
draws the 3D point co-ordinates dimension.

handle = !marDraft.DimPoint3D(point3D, locPoint2D, height, rotation, annotation, modelSubview)

where the coordinates of the point point3D are displayed in the drawing at the point locPoint2D. The
dimension is created with the given text height and rotation. If not empty, the given annotation is added to
the dimension. The argument modelSubview is optional. If given, defines the handle to the model subview,
where the dimension is placed.

Next method creates and draws the 3D linear dimension.


www.aveva.com
handle = !marDraft.DimLinearNew(points, type, projDir, locPoint2D, witnDir, modelSubview, basepoint)

where the arguments have the following meaning:


points (MarPolygon) list of 3D measure points
type (integer) type of measure:
1 – normal,
2 – chain,
3 – staircase

projDir (MarVector) projection direction vector


locPoint2D (MarPointPlanar) location in the drawing, where the dimension should be placed
witnDir (MarVector) direction vector for witness lines
modelSubview (optional) handle to the model subview, to which the dimension component will be attached
basepoint (integer, optional) zero-based index of the measure point used to define the dimension element
plane (default: first point)

 If !modelSubview is not provided, the appropriate parent subpicture is chosen automatically.


The last method in this section creates a 3D dimensioning component, consisting of distances from the first
object to the second one, along the third. This is used to measure distances along the shell model objects
(longitudinals, transversals, hull curves, seams and stiffeners), which have to intersect the same surface.

!handleList = !marDraft.DimShellNew(viewHandle, from, along, to, type, colour)

The following arguments have to be provided:


viewHandle handle to the model view containing the objects to be measured
www.aveva.com
© Copyright 1974 to current year. 60
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

from, along, to array of Model class instances, describing groups of model objects. The measure will be
calculated from the from group along the along group to the to group.
type (integer) type of measure:
0 – only the dimension text will be created,
1 – dimension text with the arrow at the end point and circle at the start point,
2 – the above, including the dimension trace
colour (Colour) the color of the dimension

This method returns a array of handles to the created dimensioning components. Dimensions are created
individually for each triple of objects from the groups from, to, and along.

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate object to measure from...',
!point)
!viewHandle = !marDraft.subviewIdentify(!point)
!from[1] = !marDraft.modelPropertiesGet(!viewHandle)

!point = object MARPOINTPLANAR()


!pointResult = !marUi.pointPlanarReqPML('Indicate object to measure to...',
!point)
!viewHandle = !marDraft.subviewIdentify(!point)
!to[1] = !marDraft.modelPropertiesGet(!viewHandle)

!point = object MARPOINTPLANAR()


!pointResult = !marUi.pointPlanarReqPML('Indicate object to measure along...',
!point)
!viewHandle = !marDraft.subviewIdentify(!point)
!along[1] = !marDraft.modelPropertiesGet(!viewHandle)

!point = object MARPOINTPLANAR()


!pointResult = !marUi.pointPlanarReqPML('Indicate view to draw dimensions
in...', !point)
!viewHandle = !marDraft.viewIdentify(!point)
!colour = object MarColour('Red')
!dimHandle = !marDraft.DimShellNew(!viewHandle, !from, !along, !to, 0, !colour)
'…'

4.8.4 Other drawing components

AVEVA Marine PML customization can also generate other drawing components, which are stored as level
3 subpictures.

4.8.4.1 Clouds (based on rectangles or general polygons)

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!viewHandle = !marDraft.subviewIdentify(!point)

!p1 = object MarPointPlanar(10, 10)


!p2 = object MarPointPlanar(200,200)
!cloud = object MarRectanglePlanar(!p1, !p2)
!handle = !marDraft.CloudNew(!viewHandle, !cloud)
'…'

www.aveva.com
© Copyright 1974 to current year. 61
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.8.4.2 General restriction symbols

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!viewHandle = !marDraft.subviewIdentify(!point)

!p1 = object MarPointPlanar(10, 10)


!p2 = object MarPointPlanar(200,200)
!handle = !marDraft.GeneralRestrSymbolNew(!viewHandle, !p1, !p2, 0)
'…'

where the last argument determines, how soft the symbol will be. The value 1 indicates, that a spline
(soft corners) should be used, 0 the symbol will be drawn using a contour (sharp corners).
www.aveva.com
4.8.4.3 Crosses

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!viewHandle = !marDraft.subviewIdentify(!point)

!p1 = object MarPointPlanar(10, 10)


!p2 = object MarPointPlanar(10, 200)
!p3 = object MarPointPlanar(200,200)
!p4 = object MarPointPlanar(200, 10)
!line1 = object MarRlinePlanar(!p1, !p3)
!line2 = object MarRlinePlanar(!p2, !p4)
!text = object MarText('Text in the cross')
!handle = !marDraft.CrossNew(!viewHandle, !text, !line1, !line2)
'…'

4.8.4.4 Rulers

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!viewHandle = !marDraft.subviewIdentify(!point)

!p1 = object MarPointPlanar(10, 10)


!text = object MarText()
!text.Height(4.0)
!handle = !marDraft.RulerNew(!viewHandle, !p1, 16.0, 0, 200, 5, !text)
'…'

Where we produce a ruler component in the given !viewHandle, starting at point !p1, with the ticks from 0
to 200, displaced by 16.0 (in the drawing's co-ordinate system. At a scale 1:50 this produces ticks at every
800 mm in the ship's co-ordinate system). The labels are drawn at every 5th tick, using the text attributes
from the !text variable. Finally, we can also produce standard position rulers

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate view...', !point)
!viewHandle = !marDraft.viewIdentify(!point)

!start = object MarPointPlanar(10, 10)


!end = object MarPointPlanar(300, 10)
!handle = !marDraft.PositionRulerNew(4, !viewHandle, !start, !end)
'…'
www.aveva.com
© Copyright 1974 to current year. 62
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

where we produce the Longitudinal Horizontal ruler (4) between the indicated points. The first argument
indicates the type of ruler to draw, and can take the following values:
1 – Base Line ruler
2 – Centre Line ruler
3 – Frame ruler
4 – Longitudinal Horizontal ruler
5 – Longitudinal Vertical ruler

4.9 Marine Drafting default values

The appearance of the dimensioning components, as well, as many other low-level aspects of AVEVA
Marine are controlled through a number of parameters stored in the Marine Drafting default file
(SBD_DEF1 environment variable). The MarDrafting() class provides two methods for reading and
setting the Marine Drafting defaults.

'…'
!oldFont = !marDraft.DefaultValueGet('TEXT_FONT')
!marDraft.DefaultValueSet('TEXT_FONT:Courier New')
!point = object MarPointPlanar(10,10)
!handle = !marDraft.TextNew('This text is in Courier New font', !point)
!marDraft.DefaultValueSet(!oldFont)
'…'

The value returned by the method DefaultValueGet() has the format "KEYWORD : VALUE" or
"KEYWORD = VALUE". This is also the required format of the argument of the method
DefaultValueSet().

Both methods will raise an exception if the default keyword is not recognised. Additionally the method
DefaultValueSet() will raise an exception, if the value of the keyword is not valid, or if the argument
does not have the right format.

4.10 Subpicture managing methods

In the previous chapters were presented some methods creating subpictures. This includes the methods
creating views (ViewNew(), ViewSymbolicNew()), subviews (ModelDraw()), and components
(NoteNew(), PosnoNew(), HatchNew(), DimLinearNew(), etc.). All they were related either to the
creation of model views or of the standard drawing components. It was not possible to create arbitrary
subpictures 'on demand'.
www.aveva.com
SubviewNew(name)
ComponentNew(name)

These method create a new subpicture of the appropriate level under the current parent subpicture, assign
the given name and return the handle to the created subpicture. They cannot be used, if current subpicture
is set to 'automatic'. Current subpicture setting can be controlled by the functions

SubpictureCurrentGetPML()
SubpictureCurrentSet(subpictureHandle)

The first one returns a 3-element array, consisting of the handles to the current view, current subview, and
current component. If the current setting is 'automatic', the returned list is EMPTY!

NOTE: If you use the method SubpictureCurrentGetPML(), when the current subpicture settings are not set
to 'automatic' and there are no views, subviews or components, the system will create them and set them as
current. Handles of created subpictures will be returned.

The second method sets a subpicture to be current for the creation of new geometries. Ifwww.aveva.com
a component

© Copyright 1974 to current year. 63


AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

subpicture handle is given, this will be set as current. If a handle to view or subview is given, the component
(and subview) will be chosen by the system. If no argument is given, the subpicture will be automatically
chosen each time geometry is created ('automatic' mode – see restrictions above).

Note: If you try to set a view or a subview, which has no children as current, the system will create the
component (and subview) for you and set it current.

It is possible to manipulate the names of the subpictures, using the methods

SubpictureNameGet(subpictureHandle)
SubpictureNameSet(subpictureHandle, name)

It is not possible to change the name of the drawing form view, or set to a subpicture a name, that is already
occupied. PML supports the exchange of subpictures between the drawing and the subpicture databank
with the functions

SubpictureSave(subpictureHandle)
SubpictureInsert(subpictureName, parentHandle,databank)

The first method saves the subpicture identified by the given subpictureHandle to the standard subpicture
databank. The subpicture must have a non-empty name, before this method can be called. The second
method fetches a copy of the given subpicture from the subpicture databank (or the databank provided as
the third argument – valid values are 1 – SBD_PICT, and 2 – SBD_STD) and inserts it in the drawing under
the given parent subpicture, which must be of a correct level. If the inserted subpicture is a view (Level 1
subpicture), the parentHandle MUST NOT be given. The handle to the inserted subpicture is returned to the
program.

4.11 Drawing element handling

This section describes methods dealing with the drawing elements, regardless of their type. Each of these
methods refers to the drawing element by its handle. For removing a drawing element, we have a method

ElementDelete(handle)

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate text...', !point)
!textHandle = !marDraft.TextIdentify(!point)

!marDraft.ElementDelete(!textHandle)
'…'

 This method is used not only for deleting basic geometry elements, but also for all other kinds of
drawing elements, like: text elements, symbols, notes, position numbers, hatchings, views,
subviews, components, etc.

 For some kinds of objects there are special methods doing a better job, like e.g. ModelDelete(),
which is able to remove the model object (a subview) from all views, where it is present.

If necessary to delete multiple drawing elements, confined within a region (or located outside the region), the
following method can be used:

DeleteByArea(handleList, act, contour)

The elements, whose handles are in the handleList, that are located INSIDE or OUTSIDE (see the second
Argument act; 4 – delete inside, 3 – delete outside) the contour are removed from the drawing.

www.aveva.com
© Copyright 1974 to current year. 64
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

'…'
!p1 = object MARPOINTPLANAR(-200, -200)
!contour = object MarContourPlanar(!p1)
!p2 = object MARPOINTPLANAR(200, -200)
!contour.AddLine(!p2)
!p3 = object MARPOINTPLANAR(0, 200)
!contour.AddLine(!p3)
!contour.AddLine(!p1)

!p11 = object MarPointPlanar(-2000,-2000)


!p21 = object MarPointPlanar(6000,6000)
!marRec = object MarRectanglePlanar(!p11, !p21)
!region = object MarCaptureRegionPlanar()
!region.SetRectangle(!marRec)
!region.SetInside()
!region.SetCut()

!textHandle = !marDraft.TextCapturePML(!region)

!marDraft.DeleteByArea(!textHandle, 4, !contour)
'…'

An existing drawing element can be transformed using the method ElementTransform(),


which uses the MarTransformationPlanar() class instance to define the transformation. See the
example below:

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate geometry...', !point)
!geoHandle = !marDraft.GeometryIdentify(!point)

!trans = object MarTransformationPlanar()


!vector = object MarVectorPlanar(0, 300)
!trans.Translate(!vector)
!centre = object MarPointPlanar(150,150)
!trans.Rotate(!centre, 30.0)
!marDraft.ElementTransform(!geoHandle, !trans)
'…'

It is also possible to obtain the current transformation of any drawing element by calling the method
ElementTransformationGet().

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate geometry...', !point)
!viewHandle = !marDraft.ViewIdentify(!point)

!trans = object MarTransformationPlanar()


!marDraft.ElementTransform(!viewHandle, !trans)
!scale = !trans.GetScalePML()
!marUi.MessageNoConfirm('X scale factor = ' + STRING(!scale[0]))
'…'

The GetScalePML() method of the MarTransformationPlanar class returns a tuple, consisting of the X
and Y scale factors. Usually, they will be the same, so it should not matter, which one you choose.

The ability to transform elements is especially useful in a combination with the methods copying elements.
The copy, when created, is located at the same position as the original. Then the copy should be moved
somehow, so that the copy can be distinguish from the original:

ElementCopy(handle, targetHandle) www.aveva.com


© Copyright 1974 to current year. 65
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

This method copies an element and places it under the given target subpicture. If target is not given,
the copy will be placed under the same parent subpicture as the original. As a result, it returns the handle to
the created copy of the element. If the element is a subpicture and the target parent subpicture already has
a subpicture with this name, the name of the copy will be blanked. A new name can be set for the copy
subpicture, if necessary.

When copying and subsequently transforming an element, the original element will be temporarily erased
from the display. The DwgRepaint() method should be called (or apply an identity transformation) to
repaint the display so that the original element appears again.

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate panel...', !point)
!viewHandle = !marDraft.SubViewIdentify(!point)

!copyHandle = !marDraft.ElementCopy(!viewHandle)
!marDraft.SubpictureNameSet(!copyHandle, 'PML_Copy')
!trans = object MarTransformationPlanar()
!vector = object MarVectorPlanar(100, 0)
!trans.Translate(!vector)

!marDraft.ElementTransform(!copyHandle, !trans)
!marDraft.DwgRepaint()
'…'

It is possible to obtain the axis-parallel rectangle circumscribing the given element by calling the method

ElementExtentGet(handle)

The method returns the MarRectanglePlanar() class instance defining the area occupied by the
element defined by handle. If handle is not specified, the returned rectangle defines the area occupied by
the whole drawing. It is possible, that the given element is empty (e.g. empty subpicture). In this case the
IsEmpty() method of the MarRectanglePlanar() class will return 1, otherwise the result is 0. This
method is especially useful for fitting an element into the specified area in the drawing.

The visibility of the drawing elements can be controlled through the methods

ElementVisibilityGet(handle)
ElementVisibilitySet(handle, visible)

The value of 1 indicates, that the element is visible, and the value of 0, that it is hidden. This is sometimes
useful to turn off the visibility, make a change in the element, and turn the visibility back on.

4.12 Shading functions

AVEVA Marine system supports shading of model views. Only one shaded view can exist at a time. In order
to create a shaded view from the given model view, pass its handle to the function

ShdNew(viewHandle)

If a shaded view exists, an exception will be raised. It is possible to set the projection of the shaded view by
setting up the MarTransformation() class instance and passing it to the method
ShdProjectionSet()

The existing shaded view can be automatically scaled using the method ShdAutoscale(), and zoomed
using the method ShdZoomBox(p1, p2), where p1, and p2 are the opposite corners (MarPoint() class
instances) of the axis-parallel zooming box.
www.aveva.com
© Copyright 1974 to current year. 66
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

4.13 Dabacon references

Every one element has his own unique reference number in the dabacon database. It’s possible refer to
elements using his dbref, not only name, handle etc. Methods below allow retrieve this unique number:

ElementDbrefGet(handle)
ElementDESIDbrefGet(handle)

Dbref allows query any of the element attributes, see example below (query part position number):

'…'
!point = object MARPOINTPLANAR()
!pointResult = !marUi.pointPlanarReqPML('Indicate model part...', !point)
!viewHandle = !marDraft.ComponentIdentify(!point)

!dbref = !marDraft.ElementDbrefGet(!viewHandle)

!object = object DBREF()


!object.Dbref(!dbref)
!posno = !object.attribute('PosNo')

!marUi.MessageConfirm('Position number: ' + STRING(!posno))


'…'

www.aveva.com
© Copyright 1974 to current year. 67
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Chapter 5

5 Training exercises solution

5.1 Exercise 1
define function !!exercise1() is ANY
import 'marapi'
handle( 1000, 0 )
-- This error means that marapi has already been imported,
-- ignore this error and continue.
endhandle

using namespace 'Aveva.Marine.Ui'


!marUi = object MarUi()
using namespace 'Aveva.Marine.Utility'
!marUtil = object MarUtil()

!result = ARRAY()
!aftEnd = ''
!res = !marUi.StringReqPML('Key in aft end frame', !aftEnd)
if (!res eq !marUtil.OkPML()) then
!aftEnd = !aftEnd.UpCase()
!foreEnd = REAL()
!res = !marUi.IntReq('Key in last frame number', !foreEnd)
if (!res eq !marUtil.OkPML()) then
do !n from REAL(!aftEnd) to !foreEnd
!frPos = 0
!marUtil.PosToCoord(1, !n, !frPos)
!result.append(STRING(!n) + ',' + STRING(!frPos / 1000))
enddo
!csv = object FILE('c:\Temp\Frametable.txt')
!csv.WriteFile('OVERWRITE', !result )
handle ANY
!marUi.MessageConfirm('Frame table file not stored!')
endhandle
!pos1 = 0
!marUtil.PosToCoord(1, 125, !pos1)
!marUi.MessageConfirm('Frame 125 X coordinate located ' + STRING(!pos1) + '
mm from AP')
!pos2 = 0
!marUtil.PosToCoord(1, 200, !pos2)
!marUi.MessageNoConfirm('Frame 200 X coordinate located ' + STRING(!pos2) +
' mm from AP')
else
!marUi.MessageConfirm('Program terminated')
endif
else
!marUi.MessageConfirm('Program terminated')
endif
endfunction

www.aveva.com
68
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

5.2 Exercise 2
define function !!exercise2() is ANY
import 'marapi'
handle( 1000, 0 )
-- This error means that marapi has already been imported,
-- ignore this error and continue.
endhandle

using namespace 'Aveva.Marine.Ui'


!marUi = object MarUi()
using namespace 'Aveva.Marine.Utility'
!marUtil = object MarUtil()

!collection = object COLLECTION()


!collection.type('BLOCK')
!res = !collection.results()
!sres = object BLOCK(|!res[!evalIndex].NAMN|)
!blist = !res.evaluate(!sres)

!blo = REAL()
!stat = !marUi.StringSelect('Hull production blocks', 'Select block', '',
!blist, !blo)

if (!stat eq !marUtil.OkPML()) then


!blockName = !blist[!blo]
!collection = object COLLECTION()
!collection.type('HPANEL')
!expression = object EXPRESSION(|NAMN OF OWNER EQ '| + !blockName + |'|)
!collection.filter(!expression)
!res = !collection.results()
!panelres = object BLOCK(|!res[!evalIndex].namn|)
!panList = !res.evaluate(!panelres)
!weightres = object BLOCK(|!res[!evalIndex].gweight|)
!panWeight = !res.evaluate(!weightres)
do
!pan = REAL()
!stat = !marUi.StringSelect('Hull block ' + !blockName + ' panels', 'Select
panel', '', !panlist, !pan)
if (!stat eq !marUtil.OkPML()) then

!marUi.MessageConfirm('Panel ' + !panList[!pan] + ' weight ' +


STRING(!panWeight[!pan].nint().value()) + ' kg')
else
!marUi.MessageConfirm('Program terminated')
break
endif
enddo
else
!marUi.MessageConfirm('Program terminated')
endif
endfunction

www.aveva.com
© Copyright 1974 to current year. 69
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

5.3 Exercise 3

-- Input: !modelType - model type(plane panel, curved panel etc)


-- !partType - part type (planar plate, stiffener, pillar etc)
-- !status - 1 panel selected (!partType can be empty string),
-- 2 panel component selected
-- !message - message to display
-- Output: return array depend from !status
-- [0] - function cancel by user
-- [1] panel name
-- [2] panel name, part ID
--
--------------------------------------------------------------------------------
define function !!exercise3(!modelType is STRING, !partType is STRING, !status
is REAL, !message is STRING) is ARRAY
import 'marapi'
handle( 1000, 0 )
-- This error means that marapi has already been imported,
-- ignore this error and continue.
endhandle

using namespace 'Aveva.Marine.Drafting'


using namespace 'Aveva.Marine.Ui'
using namespace 'Aveva.Marine.Utility'
using namespace 'Aveva.Marine.Geometry'
!marUi = object MARUI()
!resultCodes = object MARUTIL()
!point = object MARPOINTPLANAR()
!marDraft = object MARDRAFTING()
!modelSubView = object MARELEMENTHANDLE()
!modelComponent = object MARELEMENTHANDLE()
!result = ARRAY()

do
-- return status + panel name
if (!status eq 1) then
!pointResult = !marUi.pointPlanarReqPML(!message, !point)
if (!pointResult eq !resultCodes.rejectPML()) then
!marUi.messageNoConfirm('Script aborted!')
!result.append(0)
return !result
else
!mod = object MARMODEL()
!marDraft.modelIdentify(!point, !mod, !modelSubView, !modelComponent)
if (!mod.Type() eq !modelType) then
!mess = !marUi.AnswerReqPML('Model selection', 'Selected panel ' +
!mod.name() + ', OK?')
if (!mess eq !resultCodes.YesPML()) then
!result.append(1)
!result.append(!mod.name())
return !result
elseif (!mess eq !resultCodes.OptionsPML() or !mess eq
!resultCodes.CancelPML()) then
!result.append(0)
!marUi.messageNoConfirm('Script aborted!')
return !result
endif
endif
endif
www.aveva.com
© Copyright 1974 to current year. 70
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

-- return status + panel name + component ID


elseif (!status eq 2) then
!pointResult = !marUI.pointPlanarReqPML(!message, !point)
if (!pointResult eq !resultCodes.rejectPML()) then
!marUi.messageNoConfirm('Script aborted!')
!result.append(0)
return !result
else
!mod = object MARMODEL()
!marDraft.modelIdentify(!point, !mod, !modelSubView,
!modelComponent)
if(!mod.PartType() eq !partType) then
!mess = !marUi.AnswerReqPML('Model selection',
'Selected component ' + !mod.name() + ', ' + !partType + ': ' +
STRING(!mod.partIDPML()) + ', OK?')
if (!mess eq !resultCodes.YesPML()) then
!result.append(2)
!result.append(!mod.name())
!result.append(!mod.partIDPML())
return !result
elseif (!mess eq !resultCodes.OptionsPML() or !mess eq
!resultCodes.CancelPML()) then
!marUi.messageNoConfirm('Script aborted!')
!result.append(0)
return !result
endif
endif
endif
endif
enddo

endfunction

www.aveva.com
© Copyright 1974 to current year. 71
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

5.4 Exercise 4

define function !!exercise3(!modelType is STRING, !partType is STRING, !status


is REAL, !message is STRING) is ARRAY
import 'marapi'
handle( 1000, 0 )
-- This error means that marapi has already been imported,
-- ignore this error and continue.
endhandle

using namespace 'Aveva.Marine.Drafting'


using namespace 'Aveva.Marine.Ui'
using namespace 'Aveva.Marine.Utility'
using namespace 'Aveva.Marine.Geometry'
!marUi = object MARUI()
!resultCodes = object MARUTIL()
!point = object MARPOINTPLANAR()
!marDraft = object MARDRAFTING()
!modelSubView = object MARELEMENTHANDLE()
!modelComponent = object MARELEMENTHANDLE()
!result = ARRAY()

do
-- return status + panel name
if (!status eq 1) then
!pointResult = !marUI.pointPlanarReqPML(!message, !point)
if (!pointResult eq !resultCodes.rejectPML()) then
!marUi.messageNoConfirm('Script aborted!')
!result.append(0)
return !result
else
!mod = object MARMODEL()
!marDraft.modelIdentify(!point, !mod, !modelSubView, !modelComponent)
!marDraft.elementHighlight(!modelSubView)
if (!mod.Type() eq !modelType) then
!mess = !marUi.AnswerReqPML('Model selection', 'Selected panel ' +
!mod.name() + ', OK?')
if (!mess eq !resultCodes.YesPML()) then
!result.append(1)
!result.append(!mod.name())
!marDraft.HighlightOff(0)
!marDraft.DwgRepaint()
return !result
elseif (!mess eq !resultCodes.OptionsPML() or !mess eq
!resultCodes.CancelPML()) then
!result.append(0)
!marUI.messageNoConfirm('Script aborted!')
!marDraft.HighlightOff(0)
!marDraft.DwgRepaint()
return !result
else
!marDraft.HighlightOff(0)
!marDraft.DwgRepaint()
endif
else
!marDraft.HighlightOff(0)
!marDraft.DwgRepaint()
endif
endif
-- return starus + panel name + component ID www.aveva.com
© Copyright 1974 to current year. 72
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Marine (12.1)
PML for Marine Drafting - TM-2401

elseif (!status eq 2) then


!pointResult = !marUI.pointPlanarReqPML(!message, !point)
if (!pointResult eq !resultCodes.rejectPML()) then
!marUi.messageNoConfirm('Script aborted!')
!result.append(0)
return !result
else
!mod = object MARMODEL()
!marDraft.modelIdentify(!point, !mod, !modelSubView,
!modelComponent)
!marDraft.elementHighlight(!modelComponent)
if(!mod.PartType() eq !partType) then
!mess = !marUi.AnswerReqPML('Model selection',
'Selected component ' + !mod.name() + ', ' + !partType + ': ' +
STRING(!mod.partIDPML()) + ', OK?')
if (!mess eq !resultCodes.YesPML()) then
!result.append(2)
!result.append(!mod.name())
!result.append(!mod.partIDPML())
!marDraft.HighlightOff(0)
!marDraft.DwgRepaint()
return !result
elseif (!mess eq !resultCodes.OptionsPML() or !mess eq
!resultCodes.CancelPML()) then
!marUi.messageNoConfirm('Script aborted!')
!result.append(0)
!marDraft.HighlightOff(0)
!marDraft.DwgRepaint()
return !result
else
!marDraft.HighlightOff(0)
!marDraft.DwgRepaint()
endif
else
!marDraft.HighlightOff(0)
!marDraft.DwgRepaint()
endif
endif
endif
enddo

endfunction

www.aveva.com
© Copyright 1974 to current year. 73
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.

You might also like