Messages and Macros Functions

This package deals with messages and macros functions.

This page discusses:

CheckLicense

Enables you to verify if a given license was acquired by the current user.

Signature

CheckLicense(License: String, LaunchError: Boolean) : Integer

Arguments

NameInput / OutputRequired?TypeComment
LicenseInYesStringName of the license
LaunchErrorInYesBooleanTrue 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).
  • The method verifies that the current user is granted a Native App license.
  • If the user does not own the license, a Knowledge report is launched.
  • This function can prove particularly useful when working with Know-how Apps Components. It can help a Know-how Apps Components designer stop the process if it requires an unavailable license.

Example

If (CheckLicense(“license1”,TRUE) == 0)
{
...
}

ReturnType

Integer

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 is defined in Me > Preferences > General > Parameters and Measures > Units tab. That is, Message(#,3mm) appears as "3mm." However, if you specify Message(#,3mm+2mm) the resulting unit is displayed as a real number that is to say 0.005. Furthermore, if you specifyMessage(#,-2mm) the resulting unit is 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

  • 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 see as many messages as loop iterations.

Message (BuildMessageNLS(KwrCATCatalog, Zero))

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 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 are replaced in the message).

Notify

Enables you to display a yellow tooltip on the upper 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 the 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(message : String [, argument : Literal, ..])

Arguments

NameInput/OutputRequired?TypeComment
messageInYesString--
argumentInNoLiteral--

Example

let i = 1
for i while i < 10
      PopupMessage("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 to be replaced in the message)

Report

Enables you to create an error displayed at the end of an 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, define 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). See also Trace on the server side.

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 verify 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() 
						)