Messages and macros Functions

This page discusses:

Message

Enables you to display a message in an information box. The message can include one or more parameter values.

Important: The unit used to valuate a Parameter takes into account the unit which has been set in Me > Preferences > General > Parameters and Measures > Units tab. i.e. Message(#,3mm)appears as "3mm". However, if you specify Message(#,3mm+2mm)the resulting unit will be displayed as a real number that is to say 0.005. Furthermore, if you specifyMessage(#,-2mm) the resulting unit will be also displayed as -0.002.

Signature

Message(message: String [, argument: Literal, ..])

Arguments

NameInput / OutputRequired?TypeComment
messageInYesStringString to be displayed in the information box (must be put in quotes).
argumentInNoLiteralWhen parameter values are to be displayed within the message, the arguments must be specified as follows:
  • one string in quotes including a # symbol wherever a parameter value is to be displayed.
  • as many [, parameter name] statements as parameter values declared with a "#" in the message.
Note: Use the "|" symbol to insert a carriage return in a message.

Example 1

Message("External radius is: # | Internal Radius is: #", PartBody\Sketch.1\Radius.3\Radius, PartBody\Hole.1\Diameter)

Example 2

Message (BuildMessageNLS(KwrCATCatalog, Zero))

Note: Remember that:
  • This function can be used along with the BuildMessageNLS function.
  • Messages returned by the Message operator are returned only at the end of rules executions. The order in which they are returned is identical to the order in which they were sent. It is the only way to make sure that messages are not displayed twice. Two messages are considered as identical if the first evaluator strings are identical.

    For example, Message ("", 3mm) and Message ("",4mm) are considered as identical and only the second one appears. When working with loops, if a message appears at each loop iteration, all messages are displayed. So if a message displays the iterator in a loop, for example Message("",i) , you will see as many messages as loop iterations.

Important: You can use the Message function together with the String function for your question to display in your language. To use this function, use the following syntax: Message(BuildMessageNLS (x,xx,a,b))
  • x corresponds to the name of the CATXXX.CATNls file where you will find the NLS message (it is the CATXXX name without the CATNls extension).
  • xx corresponds to the key name in this catalog.
  • a and b are the arguments (values that will be replaced in the message).

Notify

Enables you to display a yellow tooltip on the top right of the screen. To avoid tooltip overlap, the messages are stored within a defined timeframe and displayed altogether when the application idles. The notifications are stacked until:

  • The notifications stack reaches 40 elements.
  • Notify is called using “|” as first character, which indicates that you want to start a new notification stack.
When the application idles, the different stacks are displayed as tooltips. Each tooltip appears for a certain time which is computed using the size of the message with a maximum of 60 seconds.

Signature

Notify(message: String [, argument: Literal, ..])

Arguments

NameInput / OutputRequired?TypeComment
messageInYesString
argumentInNoLiteral

PopupMessage

Function identical to Message except that it does not have the optimization that compacts different messages into one and blocks the evaluation until the user clicks OK.

Signature

PopupMessage(severity: String, message: String [, argument: Literal, ..])

Arguments

NameInput / OutputRequired?TypeComment
severityInYesString
messageInYesString
argumentInNoString

Example

let i = 1
for i while i < 10
      Message("i = #", i)

When executing the above script, the PopupMessage function displays the 10 popup messages and stops the execution when calling the PopupMessage function. If you use the Message function, you only see "i = 1" which appears at the end of the script execution.

Question

Enables you to display a message in a dialog box, click a button to get a value indicating which button you clicked (true if Yes was clicked, false if No was clicked).

Signature

Question(question: String [, argument: Literal, ..]) :
 Boolean

Arguments

NameInput / OutputRequired?TypeComment
questionInYesStringString to be displayed in the dialog box (must be put in quotes).
argumentInNoLiteralWhen parameter values are to be displayed within the message, the arguments must be specified as follows:
  • one string in quotes including a # symbol wherever a parameter value is to be displayed.
  • as many [, parameter name] statements as parameter values declared with a "#" in the message.
Note: Use the "|" symbol to insert a carriage return in a prompt.

ReturnType

Boolean

Example

Boolean2 = Question("SketchRadius is # | Do you want to change this value ?",
PartBody\Sketch.1\Radius.3\Radius )

Important: You can use the Question function together with the String function for your question to display in your language. To use this function, use the following syntax:
  • question(BuildMessageNLS (x,xx,a,b))
  • x corresponds to the name of the CATXXX.CATNls file where you will find the NLS message (it is the CATXXX name without the CATNls extension)
  • xx corresponds to the key name in this catalog
  • a and b are the arguments (values that will be replaced in the message)

Report

Enables you to create an error displayed at the end of evaluation in an error report.

Signature

Report(severity: String, summary: String, 
message: String [, argument: Literal, ..])

Arguments

NameInput / OutputRequired?TypeComment
severityInYesStringCan be Information, Warning or Error.
summaryInYesStringString that qualifies the error. It can both contain # characters combined with the variable arguments.
messageInYesStringString that qualifies the error. It can both contain # characters combined with the variable arguments.
argumentInNoLiteral
Note: To view an example, import the Sample_extra.3dxml file located in win_b64\startup\Knowledgeware\PKT Samples\Sample 1 in the installation folder.

TextFormat

Function used to build a message using a format string and its arguments.

Signature

TextFormat(format: String [, argument: Literal, ..]) :
 String

Arguments

NameInput / OutputRequired?TypeComment
formatInYesString
argumentInNoLiteral

ReturnType

String

Note: The format to be used is identical to the one of the Message function.

Trace

Enables you to write information in a file for debugging purposes for example. On the client side, to do so, valuate the CATKnowledgeTracePathvariable (for example, set CATKnowledgeTracePath=E:\Temp\CATKnowledge_UserDefined.txt). If the variable is empty, the default name of the trace file is CATKnowledgeTrace_YYYY-MM-DD_HH-MM-SS.txt. This file is located in the CATTemp directory (For example: C:\Documents and Settings\user\Local Settings\Application Data\DassaultSystemes\CATTemp\CATKnowledgeTrace_2005-8-8_16-28-20.txt).

On the server side, to activate traces, the server must be launched with the trace options: For instance when working with a Tomcat server,set _JAVA_OPTIONS=-DJSystemTraceFile=e:\tmp\traces.txt.In this traces.txt file, the environment variable has to be set :

  • CKE_CUSTO_TRACES 10 for basic traces like Business rules called,
  • CKE_CUSTO_TRACES 30 for advanced traces like objects dump

Traces put with the function Trace() in the script are displayed on the server side, in the application server console. These traces are only use for debug issues.

Signature

Trace(level: Integer, message: String [, argument:
 Literal, ..])

Arguments

NameInput / OutputRequired?TypeComment
levelInYesIntegerComprised between 1 and 9 and is used to indent the traces
messageInYesStringmessage used like in Message function.
argumentInNoLiteralMust have the same number of # and parameters. If there are more parameters than #, parameters are added at the end of the message. If there are more # than parameters, the character # is not replaced

  • The | symbol lets you insert a carriage return in a prompt.
  • # is replaced with the parameter value.

Example

Trace(1 , "MyMessage... 
						Param1: #, Param2: #", Integer.1, String.1) 

The generated .txt file looks like the one below:

Action.1: MyMessage... Param1: 1, Param2: I'm a string
Action.1: MyMessage... Param1: 1, Param2: I'm a string
Action.1: MyMessage... Param1: 2, Param2: I'm a string
Action.1: MyMessage... Param1: 3, Param2: I'm a string
Action.1: MyMessage... Param1: 3, Param2: I'm a string # <-- Too many #
Action.1: MyMessage... Param1: 3, Param2: I'm a string3 <-- Too many parameters
Action.1: MyMessage... Param1: 4, Param2: I'm a string
Action.1: MyMessage... Param1: 5, Param2: I'm a string
Action.1: MyMessage... Param1: 6, Param2: I'm a string

Visual Basic Script Macro -> Run

Function used to run a macro with arguments. It is up to you to check that the macro which is run is not going to cause an infinite loop or result in a system crash.

Signature

Visual Basic Script Macro->Run(valueOrFeature:ObjectType,...): VoidType 	

Arguments

NameInput / OutputRequired?TypeComment
valueOrFeatureCorresponds to the macro argument. Macros have arguments that have a particular order. Values assigned to arguments have to be passed in the same order.

ReturnType

String

Note: The format to be used is identical to the one of the Message function.

Example

if PartBody\Pad.1.HasAttribute(String.1) 	== true 
						`VB Scripts.1` .Run(PartBody\Pad.1 .GetAttributeString(String.1),PartBody\Pad.1.Name() 
						)

AdvisorAction -> Run

Executes an action.

Signature

AdvisorAction->Run(valueOrFeature:ObjectType,...): VoidType 

Arguments

Name Input / Output Required? Type Comment
valueOrFeature

The arguments to pass to the action execution. There must be the right number of arguments based on the signature of the action.

ReturnType

String

Note: The format to be used is identical to the one of the Message function.

Example

if PartBody\Pad.1.HasAttribute(String.1)              == true 
 
`Action.1` .Run(PartBody\Pad.1 .GetAttributeString(String.1),PartBody\Pad.1.Name()