Messages and Macros

The functions described below are used in Knowledge browsers.

Message Function

You can 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 Tools > Options > General > Parameters and Measures > Units tab. i.e. Message(#,3mm)is displayed 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.

Syntax

Message(String [# String1 # String2 ..., Param1Name, Param2Name, ...] ) : Void

Arguments

TheMessage function takes one required argument and several optional arguments in input depending on whether parameter values are to be displayed in the message.


  • String: Required. String to be displayed in the information box (must be put in quotes).
  • # String1, Param1Name...: Optional. When 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.

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

Note that this function can be used along with the BuildMessageNLS function

Message (BuildMessageNLS(KwrCATCatalog.CATNls,Zero))

Note that 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.

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).

Question Function

You can 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).

Note that questions launched by the Question operator are executed only when parsing the evaluation.

Syntax

Question(String [# String1 # String2 ..., Param1Name, Param2Name, ...] ): Boolean

Arguments

The Question function takes one required argument and several optional arguments depending on whether parameter values are to be displayed in the message.


  • String: Required. String to be displayed in the dialog box (must be put in quotes).
  • # String1, Param1Name...: Optional. When 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.

Use the "|" symbol to insert a carriage return in a prompt.

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)

Trace Function

You can write information in a file for debugging purposes for example.

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).

Syntax

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

Where:


  • level is comprised between 1 and 9 and is used to indent the traces
  • message is used like a message function
  • argument must 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.

Note that:


  • 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

You can 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.

Syntax

Visual Basic Script Macro->Run(valueOrFeature:ObjectType,...): VoidType where valueOrFeature correspond to the macro argument. Macros have arguments that have a particular order. Values assigned to arguments have to be passed in the same order. Example You must have created the VB Script.1 macro before creating the rule below:

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

Advisor Action -> Run

You can run an action.

Syntax

Advisor Action->(valueOrFeature: ObjectType, ...): VoidType

CheckLicense

You can check if a given license was acquired by the current user.

Syntax

CheckLicense(License: String, LaunchError: Boolean): Integerwhere String is the name of the license, LaunchError is True if the user is granted the license or False if not, and Integer 0 (if the user is granted the license) or 1 (if not).

Note: If the user does not own the license, a Knowledge report is launched.

Note: This function can prove particularly useful when working with DPC.It can help a DPC designer stop his process if he requires an unavailable license.

TextFormat

You can build a message using a format string and its arguments.

Syntax

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

The format to be used is identical to the one of the Message function. To find out more, see the Message function.