Example 1-2 from the
attribut.scm file creates a block, and then attaches an attribute that specifies its volume, and a second attribute that specifies its composition.
|
|
; - attribut.scm ----------------------------------------------
|
; Assign two name/value attribute pairs to an entity, then
|
; modify them.
|
; Demonstrate non-volatility by saving, restoring, and
|
; displaying the entity.
|
; -------------------------------------------------------------
|
|
;; Create a new part so we know what's there when we reload
|
(part:set-active (part:new))
|
|
;; Create a block and add some attributes
|
(define blk (solid:block (position 0 0 0) (position 20 30 40)))
|
(attrib:add blk "name" "cornerstone")
|
(attrib:add blk "volume" 24000)
|
|
;; Display the attributes
|
(display (attrib:get blk))
|
|
;; Add and modify attributes
|
(attrib:replace blk "volume" 12000)
|
(attrib:add blk "name" "granite")
|
(display (attrib:get blk))
|
|
;; Remove all name attributes
|
(attrib:remove blk "name")
|
(display (attrib:get blk))
|
|
;; Save and restore part
|
(part:save "attrib.sat")
|
(part:clear)
|
(part:load "attrib.sat")
|
|
;; Display attributes for first restored entity
|
(display (attrib:get (car (part:entities))))
|
|
Example 1-2. Name-Value Attribute Pairs
|