Filtering instances in CoCreate Modeling (08 Dec 2017)

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)))


Previous month: Click here.

Revision: r1.1 - 08 Dec 2017 - 13:03 - ClausBrod
Blog > DefinePrivatePublic201712
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback