Attributes in KID   

<<< Enquiries Chapters KID Graphics: Overview >>>

Contents

[back to top]


10.1 Using attributes

An example of the function of an attribute colour , given a face set f0 with tags is:

 

> (colour enquire)      --> output information about attribute
                            definition
> (f0 colour)           --> delete all colour attributes in f0
> (f0 colour ´(0.3 0.3 0.3))
                         --> create colour attributes on all f0

[back to top]


10.2 Constructing attributes

There are 5 ways to create a working attribute.

Activate all current attributes

 

> ( attribute update )

Interrogates the model for all active attributes and build corresponding objects in KID with matching names. Only attributes new to the World since the last call to this are re-created.

Attach to an existing attribute

 

> ( colour create )

The effect is as in the first method, but since only a single attribute is processed this is faster.

Specify a full attribute definition

 

> ( define spin_axis attribute )
> ( spin_axis owners ´( face body assembly )) 
                                     -- or inherit the default
> ( spin_axis class 5 )
> ( spin_axis prefix "CUSTOMER/" )   -- optional
> ( spin_axis name   "rotation_axis" ) -- mandatory
> ( spin_axis create )

Create just from the tag

 

> ( attribute create 21 )

This path is used to do the work for the first option.

Post the attribute name but delay creation until actual use

 

> ( define colour system_attribute )
> ( colour lazy )      -- only supported for system defined attributes

[back to top]


10.3 Defining attribute structures

Attribute structures are defined from a list of names, each field in the structure can be of type: real, integer, string, vector, coordinate, direction or axis.

 

> ( define myatt attribute )
> ( myatt structure ´( string vector real vector real ))
> ( myatt create )

The structure must always be given as a list, even if only one field is needed.

Additionally an attribute with NO fields is valid. This is indicated in KID by defining the structure to be t .

 

> ( define marked attribute )
> ( marked structure t )
> ( marked create )

If a structure is not defined, KID interrogates the kernel when the attribute is created to try and find an existing structure definition for an attribute of that name.

[back to top]


10.4 Reading from attributes

Values are returned in the order implied by the structure definition, formatted into sublists to reflect the implied structure of axis, coordinate, vector and direction subfields. Since an object may have several tags, each with an attribute attached, or since class 6 and 7 attributes may be attached to a single owner multiple times, each set of attribute data is returned in a separate list.

 

> ( f0 hatching )   --> ( ( 0.1 0.2 0.3 4 ) ( 0.2 0.2 0.2 1 ) )
                    -- data for two tag lists
> ( e0 blend_v5 ) 
       --> ( ( 0.3 1 ( 0.1 0.2 0.3 ) ( 4.4 5.5 6.6 ) ) )
       -- an attribute structure with 2 vector fields

Attributes with a single field return that field without enclosing it in another list.

 

> ( f0 name )     --> ( George )one tag with a name attached
> ( g0 name )     --> ( Peter Bob two tags have a name attached

Attributes with no fields return a ( t ) for each tag in the object taglist which has the attribute attached and nil if there are none at all.

 

> ( f0 marked )    --> ( t t t t ) 4 of the faces are marked
> ( f0 marked )    --> nil - none of the faces are marked

[back to top]


10.5 Writing to attributes

The attribute values should be supplied in the order which corresponds to the structure definition.

 

> ( b0 density ´( 135.4 kg/m3 ))    
            -- real before string in this case

Integer values may be provided in positions in which real values are expected.

 

> ( b0 density ´( 135 kg/m3 ))

Reflecting embedded structure of the data values using brackets is optional.

Structures with a single field need not be enclosed in a list. So both the following work:

 

> ( f0 translucency ´( 0.5 ))
> ( f0 translucency 0.5 )

Structures with no fields can always be set using the value t. All structures can be unset (deleted) by using the value nil.

 

> ( f0 marked t )            -- set a logical attribute
> ( f0 marked nil )          -- delete for any attribute
 

[back to top]


10.6 Controlling attribute names

If the class of attributes has a standard prefix then it would be convenient to take this for granted whilst working with the attributes. This system is already used for system_attributes which have a prefix of SDL/TYSA_.

 

> ( define site_attribute attribute )
> ( site_attribute prefix "EDS/UG_" )
> ( define system_id  site_attribute )
> ( system_id structure ´( integer ))
> ( system_id create )         -- New site_attribute system_id:
                                  full name EDS/UG_SYSTEM_ID

Alternatively the full attribute name can be overridden manually before it is first created.

 

> ( define id attribute )
> ( id name "EDS/UG_SYSTEM_ID" )
> ( id structure ´( integer ))
> ( id create )   -- New attribute id:full name EDS/UG_SYSTEM_ID

 

[back to top]

<<< Enquiries Chapters KID Graphics: Overview >>>