Messages and macros

LaunchMacroFromDoc Function Question Function
LaunchMacroFromFile Function VBScriptRun
Message Function  

 

LaunchMacroFromDoc Function  

Executes a macro stored in a document from a rule.
A macro is stored in a document when you don't specify any external file before recording it.

Warning: 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

LaunchMacroFromDoc(MacroName )

Example

LaunchMacroFromDoc("Macro1") 

Question Function  

Displays a message in a dialog box, waits for you to click a button and returns a value indicating which button you clicked (true if Yes was clicked, false if No was clicked)

Syntax

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

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

Arguments Description
String Required. String to be displayed in the dialog box (to be put in quotes).
# String1, Param1Name... Optional. When parameter values are to be displayed within the message, the arguments are 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 )
Note that you can use the Question function together with the BuildMessageNLS 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)

LaunchMacrofromFile Function  

Executes a macro CATScript from a rule.

Warning: 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

LaunchMacroFromFile("MacroName.CATScript" )

Example

LaunchMacroFromFile("Macro1.CATScript")

Run Method

Runs a macro with arguments.

Warning: 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

VB Script.Run(valueOrFeature:ObjectType,...): Void

where valueOrFeature is the macro argument name. There can be several arguments.

Example

You must have created the VB Script.1 macro before creating the rule below:

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

Sample

KwrObject.CATPart

Message Function  

Displays a message in an information box. The message can include one or more parameter values.

Syntax

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

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

Arguments Description
String Required. String to be displayed in the information box (to be put in quotes).
# String1, Param1Name... Optional. When parameter values are to be displayed within the message, the arguments are 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"))

Where x,y,z are parameters.

 

Note that you can use the Message function together with the BuildMessageNLS 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)