You are on page 1of 19

$M = Runs a macro in pdms

$! = Evaluate a variable
$. = Terminates a macro
$S = Defines a synonym
$G = Defines a global synonym
$S- = Turns synonyms of
$S+ = Turns synonyms On
$QS = Quearys the synonyms
$H = Help
$Q = Another syntax help
$P = Prints a line to your command line
$$ = Adds a $ symbol
$D = Default argument value

pml rehash
pml index
!!pmldefinition(codename)
pmlscan directory_name
q var !!PML.getpathname( 'filename.pmlobj' )
Q Var !browser
Q methods !browser
q var !!mydata.elements()
q var !!mydata.collections()

------------------------------------------------------------- DEBUG
$R <n>

1 = Tracing to shell window (default)


2 = Tracing to requests window
4 = Tracing of only input lines executed
8 = Tracing of all input lines
16 = Tracing without expresion (default of)
32 = Tracing includes line numbers
64 = Tracing of macro/function changes
100 = General Debugging
102 = capture trace in ALPHA LOG

------------------------------------------------------------- objet d'element de type PDMS


!EQUI = object elementtype('EQUI')
!UEQUI = object elementtype(':MYEQUI')

------------------------------------------------------------- objet d'element de type PDMS

Name()

$* Name of element type


$* Description()

Description()

Hash()

IsUdet()

systemAttributes()

$* Description of element type

$* Hash value

$* Whether a UDET or not

$* List of system attributes (excludes UDAs)

string array DbType()

string ChangeType()
changed

SystemType()

$* List of valid DB types

$* Indicates if an element of this type may have its type

$* for UDETs this is the base type


$* UDETs derived from this type

Primary()

$* Whether the element is primary or not

MemberTypes()

$* Valid members, including UDETs

ParentTypes()

$* Valid parents, including UDETs

IsPseudo()

$* Whether pseudo or not

IsUda()

$* Whether a UDA or not

querytext()

$* As output at the command line when querying attribute

units

$* Either BORE, DISTANCE or NONE

$* Returns the unit field of the attribute which is the


string of the hash code of the dimension of the attribute (BORE, DIST, MASS, ANGL, or for numbers of
no physical quantity NONE). For UDAs it is the value of the UTYP attribute.

Noclaim()

ElementTypes
works for UDAs

Real array limits

$* Whether attribute can be changed without doing a claim

$* List of Elements for which the attribute is valid. This only

$* Min/Max values for real/int types

ValidValues(ElementType)
element type

$* List of valid for text attributes. The list may vary with

string DefaultValue
(ElementType) Attribute default. This only works for UDAs
Category()
Utility form

$* Determines the grouping of attributes on the Attribute

hyperlink()

$* if true then the attribute value refers to an external file

connection()

$* if true then the attribute value will appear on the reference list

form
hidden()
form or after Q ATT
protected()

$* If true then attribute will not appear on the Attribute utility


$* if true then attribute is not visible if a protected DB

------------------------------------------------------------- Pml diagram


import 'Aveva.Diagrams'
using namespace 'Aveva.Diagrams'
!tool = object PMLDiagrams()
!tool.PublishToAVEVANET('/MainRoom')

------------------------------------------------------------- Diagram Viewer Methods


--Some diagram viewer functionality is available via PML methods.
--To use these methods the following initialisation is required at
--the top of each PML file (object, function, or macro) where these methods are to be used.
import 'IntegratorAddin'
handle any
endhandle
--The following initialisation is also required in each method or function where

--the diagram methods are to be called.


using namespace 'Aveva.PDMS.IntegratorAddin'
!intMan = object IntegratorManager()
--The following methods can be used to clear colours and close the current or all diagrams,
--and correspond to the equivalent bar menu entries.
!intMan.resetDiagramColours()
!intMan.resetAllDiagramColours()
!intMan.closeDiagram()
!intMan.closeAllDiagrams()
--The findOnDrawing method opens the diagram for one or more schematic objects and
--highlights them, in the same way as the main table View on Diagram menu entry.
--Note that the argument is an array. If an object appears on more than one diagram,
--the user will be prompted to choose which diagram to open.
--This example shows how to view the linked schematic object for the current element in 3D.
!itemList[1] = !!ce.schlnk.ref.string()
!intMan.findOnDrawing(!itemList)

------------------------------------------------------------- How to Add Integrator Functionality with PML


--Integrator communicates with PML via events that call methods on PML objects supplied in the
pmllib\Integrator\objects folder. These objects are essential to the correct functioning of Integrator
and should not be modified other than as described below.
--The IntegratorProjectHandler object is provided to enable project specific actions to be added
to certain methods. The methods that can be modified are as follows.
BeginBuildCallback
--This method is called once prior to any other actions during the Build process.
PreCreateCallback
--This method is called prior to the creation of each object in 3D during the Build process
PostCreateCallback
--This method is called after the creation of each object in 3D during the Build process

EndBuildCallback
--This method is called once after any other actions during the Build process.
BeginCompareCallback
--This method is called once prior to any other actions during the Build process.
EndCompareCallback
--This method is called once after any other actions during the Build process.
--The arguments for each method are specified in the supplied PML.
--Each place where customised code can be added is delimited as follows.
--================================================
-- Start of customisation
-- End of customisation
--================================================
--Other methods on the IntegratorProjectHandler object should not be modified.

------------------------------------------------------------- Progress and Interrupt Methods


--Form and Gadget callbacks may take a long time to execute, so it is often desirable to use the
Progress Indicator on the Application Window's status bar (along the bottom) to indicate continuing
progress to the user. The Progress Indicator consists of a display text field and a progress bar.
--The user can write to the text field using
!!FMSYS.setProgressText(!text is STRING )
--The user can set the %progress by
!FMSYS.setProgress(!percent is REAL)
--The user can also query the current settings of both using the methods
!real = !!FMSYS.Progress()
!string = !!FMSYS.ProgressText()
--Additionally for some callback operations it may be required to allow the user to interrupt the
operation and choose to cancel it. The FMSYS methods Interrupt and setInterrupt allow this to be
achieved.

--The callback which provides the required operation, must be cyclical so that there is some
repeated access point where the user can report progress (approximately as a percentage of the total
task), and check to see if the user has clicked a stop button which the user has provided on some
displayed form.
--In the users callback function they must first notify the system of the identification of the stop
button using the FMSYS method SetInterrupt:
!!FMSYS.setInterrupt(!!fmstop.stopButton )
--Then at an appropriate point in the callback, check to see if the stop button has been pressed
using the FMSYS Interrupt method, and exit with a message if it has:
-- Initialise progress bar
!!FMSYS.setProgress(0)
!!FMSYS.setProgressText('Routing pipes')
do !next from 1 to 50
...
!!RoutePipe( !next, . . . ) $*Route next pipe
...
-- Update the progress bar - first update the percentage
--completion
!percent = ...
!!FMSYS.setProgress( !percent )
-- Check if user pressed interrupt button
if ( !!FMSYS.Interruppt() ) then
return error 1 'Processing aborted'
endif
enddo
--Following is the PML code for a simple interrupt form !!fmstop.pmlfrm:
$* F&M test harness: Stop form for interrupt management
--layout form !!fmstop dialog NoAlign
title 'STOP (!!fmstop)'
path down

para .stopText text |Press to quit task| width 20


button .stopButton |Quit| width 25 height 2
exit
define method .fmstop()
--Constructor
-- define callbacks
!this.firstShownCall = |!this.stopButton.background =
'red'|
endmethod

!!FMSYS.SetStatusText( !message is STRING )


!string = !!FMSYS.StatusText()

!!FMSYS.Refresh()

------------------------------------------------------------- Pml tags


import 'Aveva.Pdms.Tags.Pml'
handle (1000,0)
endhandle

using namespace 'Aveva.Pdms.Tags'


!!tags = object PMLTags()
!!tags. PublishToAVEVANET ('category', 'list')
handle any
$P $!!Error.Text
endhandle

------------------------------------------------------------- Pml repport


import 'ReportingAddin'
handle (1000,0)
endhandle

using namespace 'Aveva.Pdms.Reporting'


!!report = object PMLReport()
--For example, to add parameters to a parameterised report
!argNames = object array()
!argNames[1] = 'param1'
!argValues = object array()
!argValues[1] = 'value1'
!!report.addParameters(!argNames, !argValues)
--To add scope to a report for limiting the data to be displayed, overriding existing scope
defined in the report
!ancestorElements = '/ATEST,/BTEST'
!elements = ''
!!report.AddScope(!ancestorElements, !elements)
--And to export report as csv file
!rep1 = object file('C:\rep1.repv')
!csv1 = object file('C:\rep1.csv')
!!report.exportAsCsv(!rep1.fullname(), !csv1.fullname())

------------------------------------------------------------- String separator in string


!string = |SWITCH UNITS ||| + !string + |||| > donne |SWITCH UNITS 'toto'|

------------------------------------------------------------- UNDO REDO

!undo = object UNDOABLE()


!undo.description('comment undo redo')
!undo.undoAction('!!hvacSpool.undoRedoAction()')

$* optionel

!undo.redoAction('!!hvacSpool.undoRedoAction()')

$* optionel

!undo.add()

blabla

!undol.endUndoable()

------------------------------------------------------------- forms ALERTE

!!alert.message('message')
!!alert.error('message')
!!alert.warning('message')
!answer = !!alert.Confirm('Question resulte YES or NO in string')
!answer = !!alert.Question('Question resulte YES or NO in string')
!answer = !!Alert.Input( 'message', 'default' ) is STRING

------------------------------------------------------------- SORT ARRAY A PLUSIEUR DIMENSIONS

!table = array()
!table[1][1] = 50

!table[1][2]= 'E'
!table[2][1] = 100
!table[2][2]= 'N'
!table[3][1] = 10
!table[3][2]= 'D'

do !x indices !table
!tmptable[!x] = !table[$!x][1]
enddo

!tmptable = !tmptable.sortedindices()
!table.reindex(!tmptable)

------------------------------------------------------------- PROGRESS BAR AVEVA

define method .PROGRESSBAREXEMPLE()

-- Initialise progress bar


!this.showProgress(-1)

-- Show the progress


!progressMax = !this.TABLE.size()
if (!progressMax eq 0 ) then
return
endif
!progressIncrement = 100 / !progressMax

!progress

=0

!this.showProgress(0)

do !x values !this.TABLE

!progress = !progress + !progressIncrement


!this.showProgress(!progress)

enddo

!this.showProgress(0)

endmethod

define method .showProgress(!percent is REAL)

if (!percent lt 0) then
!!fmsys.setProgress(0)
else
!!fmsys.setProgress(!percent)
endif

endmethod

------------------------------------------------------------- PROGRESS BAR Custom

define method .PROGRESSBAREXEMPLE()

-- Creation d'un objet BarProgressO()


!BarGraph = object BarProgressO()

-- init table des Diferentes taches pour 100%


!task = array()
!task.append('Premierement')
!task.append('Deuxiement')
!task.append('Troisiement')

-- Show the progress


!progressMax = !this.TABLE.size()

-- Construction progress bar

-- mode une taches 100% avec 100 parties


!BarGraph.BarProgressO('Titrebar')
-- OU
-- mode une taches 100% avec X parties, True affiche la bar
!BarGraph.BarProgressO(true,!progressMax,'Titrebar')
-- OU
-- mode plusieurs taches pour 100% avec X parties, True affiche la bar
!BarGraph.BarProgressO(true,!progressMax,!task )
-- OU
-- mode gauche droite, avec ou sans pourcentage
!BarGraph.BarProgressO(true,'Titrebar',true)

do !x values !this.TABLE

!progress = !progress + !progressIncrement


!BarGraph.AfficherNomEtape(1,!progress)
!BarGraph.progress(!progress)
-- OU
-- mode gauche droite
!BarGraph.ProgressNoMax(!progress)

enddo

-- remet a 0% et ferme la bar


!BarGraph.reset()
!BarGraph.close()

endmethod

------------------------------------------------------------- PRJECT CODE OBJECT


!Project = CURRENT PROJECT
!MyProj = !Project.code()

------------------------------------------------------------- WRITE FILE and VIEW in eplorer


!FO = OBJECT FILE(!FileName)
!FO.Writefile('OVERWRITE', !FinalOutput)
SYSCOM | EXPLORER $!FileName & |

------------------------------------------------------------- OPEN AND SAVING B ROWSERFILE


--Opening
using namespace 'Aveva.Pdms.Presentation'
Import 'pmlfilebrowser'
handle any
endhandle
!Browser = object PMLFILEBROWSER('LOAD')
!FilePath = 'C:\'
!Browser.show (!FilePath,'','Open the text file', false, 'Files txt (*. Txt) | *. Txt', 2)
!FileName =!Browser .file()
--Saving
using namespace 'Aveva.Pdms.Presentation'
Import 'pmlfilebrowser'
handle any
endhandle
!Browser = object PMLFILEBROWSER('SAVE')
!FilePath = 'C:\'
!Browser.show (!FilePath, '', 'Save the text file', false, 'Files txt (*.Txt) | *.Txt', 2)
!FileName =!Browser.file()
-- In a variable !FileName returns the file name

------------------------------------------------------------- Copy Image Command


!imgPath = 'c:\temp\image.jpg'

Import 'PMLNetUtilities'
Handle (1000, 0)

Endhandle

import 'PDMSCommands'
Handle (1000, 0)
Endhandle

using namespace 'Aveva.Pdms.PMLNet'


!clipboard = object PMLCLIPBOARD()
using namespace 'Aveva.Pdms.Presentation.PDMSCommands'
!commandManager = object PMLNETCOMMANDMANAGER()
!commandManager.executeCommand('AVEVA.View.CopyImage.Size1')
!clipboard.saveImage(!imgPath)

------------------------------------------------------------- Collect PML2


!Collect = object COLLECTION()
!Collect.scope(WORLD)
!Collect.type('PIPE')
!Collect.expression(object EXPRESSION('SUBSTR(NAME,1,1) eq |/|') )

!Pipes = !Collect.results()

------------------------------------------------------------- Explant I ( EXPORT DGN )


export system /explant
export CE colour 5
export file /c:\pdmsuser\export2.dgn
export finish

------------------------------------------------------------- Export REVIEW ( RVM )


repre lev pipe 6
repre lev nozz 6
repre lev struc 6
repre tube on
repre obstruction of
export holes on
export autocolour on
export autocolour RESET
export autocolour ALL STRU WITH ( MATCHWILD ( NAME OF STRU , '*CLOISON*' ) ) Colour 252
Export file /:\tmp.rvm
Export ce
Export finish

------------------------------------------------------------- Manipulation des fichiers copie deplacer supprim


copyfile "c:\desp.txt" "c:\desp2.txt"
deletefile
movefile

------------------------------------------------------------- poids volume surface & CdG


!args[1]='inside'
!args[2]=$!!ce.refno
!nvol=!!ce.attribute('nvol',!args)
!poid = (!nvol[1] / 1000000 ) * 7.850

$p Poid = $!poid kg pour $!nvol[1] mm3

!args[1]='inside'
!args[2]=$!!ce.refno
!nvol=!!ce.attribute('nvol',!args)
!poid = (!nvol[1] / 1000000 ) * 7.850
$p Poid = $!poid kg pour $!nvol[1] mm3

------------------------------------------------------------- retour d'erreur dans la commande line


handle any
$p $!!error.text
returncode ERROR
endhandle

handle any
!!alert.error(|Error |& !!error.text & | - |& !!error.line & | - |& !!error.command )
endhandle

------------------------------------------------------------- connaitre le temps d'un operation


!today = object DATETIME()
!timestampDEPART = !today.second() + ( !today.minute() * 60 ) + ( !today.hour() * 60 * 60 )

-- OPERATION

!today = object DATETIME()


!timestamp = !today.second() + ( !today.minute() * 60 ) + ( !today.hour() * 3600 )

!timestamp = !timestamp - !timestampDEPART


!H = INT(!timestamp / 3600)
!M = INT(($!timestamp - ( ( $!H * 3600 ) ) ) / 60 )
!S = INT((( !timestamp - ( $!H * 3600) - ( !M * 60 ))) / 60 )
$p Temps total de la mise a jour $!H heures $!M minutes $!S secondes

------------------------------------------------------------- HVAC SPOOL


!h =object HVACSPOOLMANAGER()
-- generate HSLIST an HSPOOL
!h.generateHvacSpools(!!ce)
-- delete HSLIST an HSPOOL
!h.deleteHvacSpools(!!ce)

You might also like