Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = #define private public - Claus Brod on stuff (08 Dec 2017) --> <style type="text/css"> pre {background-color:#ffeecc;} </style> %STARTINCLUDE% <a name="08"></a> ---+++ [[DefinePrivatePublic20171208FilterInstances][Filtering instances in <nop>CoCreate Modeling]] (08 Dec 2017) <summary> Another interesting <a href="https://ww3.cad.de/foren/ubb/Forum92/HTML/000888.shtml">user question</a> from the German user forum on <nop>CoCreate Modeling: Starting with a list of selected objects, how do I filter out shared instances? </summary> 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. <style type="text/css"> <!-- pre { white-space: pre-wrap; font-family: monospace; color: #000000; background-color:#ffeecc; } body { font-family: monospace; color: #000000; background-color: #ffffff; } * { font-size: 1em; } .Type { color: #008b00; font-weight: bold; } .Special { color: #8a2be2; } .Identifier { color: #458b74; } .Statement { color: #b03060; font-weight: bold; } --> </style> <pre id='vimCodeElement'> <span class="Special">(</span><span class="Statement">in-package</span> :de.clausbrod.filterinstances<span class="Special">)</span> <span class="Special">(</span><span class="Statement">use-package</span> :oli<span class="Special">)</span> <span class="Special">(</span><span class="Statement">defun</span> unique-objects<span class="Special">(</span>objects<span class="Special">)</span> <span class="Special">(</span><span class="Statement">let</span> <span class="Special">((</span>ht <span class="Special">(</span><span class="Statement">make-hash-table</span> <span class="Type">:test</span> <span class="Special">'</span><span class="Identifier">equal</span><span class="Special">)))</span> <span class="Special">(</span><span class="Statement">dolist</span> <span class="Special">(</span>obj objects<span class="Special">)</span> <span class="Special">(</span><span class="Statement">setf</span> <span class="Special">(</span><span class="Statement">gethash</span> <span class="Special">(</span>oli:sd-inq-obj-contents-sysid obj<span class="Special">)</span> ht<span class="Special">)</span> obj<span class="Special">))</span> <span class="Special">(</span><span class="Statement">loop</span> for obj being <span class="Statement">the</span> hash-values of ht collect obj<span class="Special">)))</span> </pre> --- %STOPINCLUDE% %COMMENT{type="below" nonotify="on"}% ---
to top
End of topic
Skip to action links
|
Back to top
Edit
|
Attach image or document
|
Printable version
|
Raw text
|
Refresh
|
More topic actions
Revisions: | r1.1
|
Total page history
|
Backlinks
You are here:
Blog
>
DefinePrivatePublic20171208FilterInstances
r1.1 - 08 Dec 2017 - 13:12 -
ClausBrod
to top
Blog
This site
2017
:
12
-
11
-
10
2016
:
10
-
7
-
3
2015
:
11
-
10
-
9
-
4
-
1
2014
:
5
2013
:
9
-
8
-
7
-
6
-
5
2012
:
2
-
10
2011
:
1
-
8
-
9
-
10
-
12
2010
:
11
-
10
-
9
-
4
2009
:
11
-
9
-
8
-
7
-
6
-
5
-
4
-
3
2008
:
5
-
4
-
3
-
1
2007:
12
-
8
-
7
-
6
-
5
-
4
-
3
-
1
2006:
4
-
3
-
2
-
1
2005:
12
-
6
-
5
-
4
2004:
12
-
11
-
10
C++
CoCreate Modeling
COM & .NET
Java
Mac
Lisp
OpenSource
Scripting
Windows
Stuff
Changes
Index
Search
Maintenance
Impressum
Datenschutzerklärung
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
Jump:
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