Another interesting user question from the
German user forum on CoCreate Modeling: Starting with a list of selected objects, how do I filter out
shared instances?
The magic sauce:
oli:sd-inq-obj-contents-sysid
. The following code uses content sysids as the keys
for a hash table. The
unique-objects
function returns the filtered list, i.e. a list which contains
only one representative for any given number of shared instances.
(in-package :de.clausbrod.filterinstances)
(use-package :oli)
(defun unique-objects(objects)
(let ((ht (make-hash-table :test 'equal)))
(dolist (obj objects)
(setf (gethash (oli:sd-inq-obj-contents-sysid obj) ht) obj))
(loop for obj being the hash-values of ht collect obj)))
Revision: r1.1 - 08 Dec 2017 - 13:12 - ClausBrod