Save History Streams
List of: Discussion Topic
Subjects: History and Roll
Contents: Kernel

History streams are saved with the part when the part:save extension is used. The default for part:save is not to save the history stream.

part:save Saves all entities in a part to a file

part:save-selection Saves a list of entities to a file; can not save history

part:load Loads a part from a file into an active part

If the history stream is no longer required, it does not have to be saved to a save file. This is an option on part:save. part:save has an option for the filename to specify both the path and filename. It has additional options for saving the part in a binary or text file, and for saving the history data.

If textmode is #t, the data is saved in text mode. If textmode is not specified, then the mode is determined by the extension of the filename. If the filename string ends in .sab (or .SAB), then the file is saved in binary mode; otherwise, the file is saved in text mode.

After setting textmode, a second Boolean specifies whether to save roll back history data. The default, #f, does not save history.

The "history save" APIs and Scheme extension support saving only the main history stream, without branches. This is done with a "mainline only" argument. If the argument is true, then rolled branches are not saved to the file.

; part:save
; Define a new part
(define my_part (part:new))
;; my_part
(part:set-distribution-mode #t)
;; #t
(env:set-active-part my_part)
;; ()
; ...

; Create model here
; ...

; Save the currently-active part to the named file.
; This saves the part defined earlier in text mode
; and saves history data.
(part:save "test" #t my_part #t)
;; #t

The saved file can be restored at any time using part:load. Obviously, a save file that is loaded that did not contain history streams cannot roll back to previous states.

; part:save
; Define a new part
(define my_part (part:new))
;; my_part
(part:set-distribution-mode #t)
;; #t
(env:set-active-part my_part)
;; ()
; ...
; Create model here
(define my_block (solid:block

(position 0 0 0) (position 10 10 10)))
;; my_block => #[entity 1 1]
; ...
; Save the currently active part to the named file.
; This saves the part defined earlier in text mode
; and saves history data.
(part:save-selection my_block "test" #t #t)
;; #t
PDF/KERN/07HIST.PDF
HTM/DATA/KERN/KERN/07HIST/0021.HTM