You are on page 1of 26

Knowledge Fusion Training

Introduction

UGS PLM Solutions Inc. 2003. All right reserved.


2

Knowledge Fusion Language

Key Characteristics
Interpreted
Object oriented
Multi-inheritance; polymorphism
Declarative rather than procedural
Rules can appear in any order
Knowledge Fusion determines the order in which the rules are evaluated
Analogous to Spreadsheet

Demand-driven evaluation scheme


Non-child rules will not be evaluated until they are required by another
required rule
Child rules are always evaluated

UGS PLM Solutions Inc. 2003. All right reserved.


3

Source File

DFA files
Source code for user defined classes and functions
File extension is .dfa
Every NX2 DFA start with
#! UGNX/KF 2.0
Single Line Comments #
# Rest of line is a comment
Multi-Line Comments
Starts with #+
Ends with #-
After editing a DFA file while UG is running, the updated
definition needs to be reloaded

UGS PLM Solutions Inc. 2003. All right reserved.


KF Language Elements
Class
Basic Class Syntax
Object
Child rule

UGS PLM Solutions Inc. 2003. All right reserved.


5

Class

What is a Knowledge Fusion Class?

A class is the logic for creating an object

A class is a collection of rules

A class has parameters that receive values

KF classes are similar to C++ and Java classes

Classes are instantiated to create KF objects (instances)

Classes can instantiate other classes forming an object tree

UGS PLM Solutions Inc. 2003. All right reserved.


6

Basic Class Syntax

Class Marker Class Name Mix-Ins Parameter Attributes

DefClass: Door (ug_base_part);


(Number Parameter) door_height: 84;
(Number Parameter) door_width: 36;
(Child) block_1:
{
Child Rule Class, ug_block; Default Values
height, door_height:;
width, door_width:;
}; Child Rule
Input Values

UGS PLM Solutions Inc. 2003. All right reserved.


7

Object

What is a Knowledge Fusion Object?

Different than a UG object

An object is an instance of a class

An object is sometimes called an instance

An instance has unique values for the classs parameters

A class can be instantiated multiple times yielding multiple unique


instances

UGS PLM Solutions Inc. 2003. All right reserved.


8

Child Rule Syntax

Attribute Type Attribute Name First name must be Class or Design

Class name is second

(Child) block_1:
{
List of Parameter Class, ug_block;
Name and Value height, door_height:;
pairs width, door_width:;
};
Semicolons
or comas
Parameter names
Parameter values
(No colons)

UGS PLM Solutions Inc. 2003. All right reserved.


Attribute
Syntax
Data types
Behavioral flags
Referencing

UGS PLM Solutions Inc. 2003. All right reserved.


10

Attribute

What is a Knowledge Fusion Attribute?


Much different than a UG attribute (totally unrelated)
An attribute is basically a named value
Closest thing in programming world is a Variable
Can be a floating point number, an integer, a string, a
point, a vector, an instance, a list of other attributes, etc.
KF does not have arrays, but it has lists, which allows
mixed data types within one list

UGS PLM Solutions Inc. 2003. All right reserved.


11

Attribute Syntax

Data Type Behavorial Flags(s) Attribute Name Rule


(end of statement marker)

(Number Parameter) door_height: 84;

Rule containing a Reference

(Number) door_width: door_height: / 2;

Required Space

UGS PLM Solutions Inc. 2003. All right reserved.


12

Attribute Data Types

Commonly Used Types

Type Example
Integer 22
Number 3.14
Point X,Y,Z coordinates
Vector I,J,K direction
List { 12, 3.14, Test }
Frame Is a KF coordinate system
Boolean True or False
String Example
Instance Instance of any class
Name ug_block

UGS PLM Solutions Inc. 2003. All right reserved.


13

Set Range Limit

(Number Parameter Modifiable) Length: 10;


(Number) Length_min: 5.0;
(Number) Length_max: 100.0;

Maxium
Minimum

UGS PLM Solutions Inc. 2003. All right reserved.


14

Behavioral Flags

To explicitly control the way KF interprets and


stores the values of attributes

Commonly used behavior flags:


Parameter
UnCached / Cached

Others discussed later


Canonical, Lookup, Method, Modifiable, Child List

UGS PLM Solutions Inc. 2003. All right reserved.


15

Behavioral Flags Parameter, Uncached

Parameter Tells the system that this attribute is a


parameter to the class and might receive a value when
the class is instantiated
(Number Parameter) door_height: 84;
UnCached - Tells the system not to store the value. It
will be recomputed every time it is referenced (Default is
cached)
(Number UnCached) door_volume: rule...;
No behavioral flag is typical 95% of the time
(Number) door_height: 84;

UGS PLM Solutions Inc. 2003. All right reserved.


16

Attribute and Class Names

Can contain any alphabetic character, numeric


character, "_" and "?, as well as the special character
"%"

Not case sensitive

Must begin with an alphabetic character or _ or %

depth, isSolid?, front_wall, point3, correct%

UGS PLM Solutions Inc. 2003. All right reserved.


17

Hidden Classes/Attributes

Hidden Classes
If the a class name starts with a %, it will not appear in the KF
Navigator
Use this to hide classes from the user that are not supposed to
be instantiated manually

Hidden Attributes
An attribute name starting with a % will not appear in the KF
Navigator, unless the attribute is created interactively using the
KF Navigator

UGS PLM Solutions Inc. 2003. All right reserved.


18

Attribute Referencing

When referencing an attribute, always suffix it with a


colon. (Referencing means use its value in the rule.)

(Number) Rad: Dia: / 2;

Colon means use value of attribute Dia

(Number) Rad: Dia / 2;

No colon means use the name Dia, which results in


a run-time error if a name was not expected. KF
does not check the data type until the rule is
evaluated, which depending on logic, might not
happen.

UGS PLM Solutions Inc. 2003. All right reserved.


NX KF Environment

UGS PLM Solutions Inc. 2003. All right reserved.


20

KF Toolbar

Applications KF Debug

Adopt Existing Object Part Inspector

Reference by Select Update Now

DFA Manager Delay Update on Edit

UGS PLM Solutions Inc. 2003. All right reserved.


21

KF Navigator

UGS PLM Solutions Inc. 2003. All right reserved.


22

Nodes MB3 Pop-up Dialogs

Root node Instance node Attribute node

UGS PLM Solutions Inc. 2003. All right reserved.


23

Preferences

C:\KF_Library\dfa\debug
C:\KF_Library\dfa\Design
C:\KF_Library\dfa\CAM

Directories storing DFA files


of customer created classes

UGS PLM Solutions Inc. 2003. All right reserved.


24

KF Related Environment Variables

UGII_KF_CLASS_DIR
Dont change!!! Its for system classes

UGII_KF_USER_CLASS_DIR
Where system looks for customer created DFA files.
Path entries separated by a colon (UNIX) or semi-colon (WNT)
To take effect, must set the following entry in ug_metric.def or ug_english.def

UG_kf_modifiable_search_directories: no

UGII_USER_DIR or UGII_SITE_DIR
Point to a directory with four sub-directories:
dfa, application, udo, and startup
application sub-folder is where system looks for Open API dynamic linked library files

UGII_LIB_PATH
Where system looks for Open API dynamic linked library files

UGII_KF_DOC_DIR / UGII_KF_DOC_URL
Where system looks for documents for customer created classes
Examples:
UGII_KF_DOC_DIR = D:\kf_docs\%s.txt
UGII_KF_DOC_URL = http://doc_server/kf_docs/%s.html

UGS PLM Solutions Inc. 2003. All right reserved.


25

Custom_dirs.dat

A text file located inside UGII_ROOT_DIR/menus


Multi-entries
Each entry points to a directory structures
Each directory structure comprises of three sub-folders
dfa for KF dfa file
application for UI Styler dialog and Open/API dynamically
linked library
startup for MenuScript files
MenuScript, UI Styler dialog and DFA are all needed
$UGII_CUSTOM_DIRECTORY_FILE to control the
actual location of this file

UGS PLM Solutions Inc. 2003. All right reserved.


End

UGS PLM Solutions Inc. 2003. All right reserved.

You might also like