Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = <nop>CoCreate Modeling code examples: Swap part color --> <style type="text/css"> pre { background-color:#FFEECC; } </style> ---++ <nop>CoCreate Modeling: Swap part color A customer recenty asked for a tool to change the color of any part which matches a given color, i.e. change the color of all red parts to blue. It is almost trivial to re-use the approach described [[MacroDeleteMatchingParts][here]] for this purpose: Instead of specifying a pattern and searching for parts which match it, we search for parts with a given color; and instead of deleting matching parts, we change their color - that's all. <pre> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Description: Changes colors for parts with a specified color ;; Author: Claus Brod ;; Created: 3/20/2006 20:20 ;; Language: Lisp ;; ;; (C) Copyright 2006 Claus Brod, all rights reserved ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (in-package :clausbrod.de) (use-package :oli) (sd-defdialog 'CHANGE_COLOR :dialog-title "Change part color" :toolbox-button t :variables '( (parts :value-type :part :multiple-items t) (oldcolor :value-type :rgb-color :title "Old color") (newcolor :value-type :rgb-color :title "New color") ) :local-functions '( (change-color (item) (when (= (sd-rgb-to-color (sd-inq-part-color item)) oldcolor) (sd-call-cmds (part_prop item :color newcolor :done)))) ) :ok-action '(mapc #'change-color parts) ) </pre> There is one problem with this: If the user selects all parts in a very large assembly, the variable =parts= will hold a long list, even though maybe only a few parts would have to change their color. A more efficient solution is to use [[MacroGetSelection][<tt>get_selection</tt>]] with a =:check-function= which allows to filter parts with the matching color. -- Main.ClausBrod - 20 Mar 2006 %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.4 |
>
|
r1.3
|
>
|
r1.2
|
Total page history
|
Backlinks
You are here:
CoCreateModeling
>
MacroSwapColor
r1.4 - 24 Jul 2009 - 19:59 -
ClausBrod
to top
CoCreateModeling
CoCreate Modeling
FAQ
Introduction
Hardware
Operating system
Memory management
File handling
Installation
Licensing
Graphics
App. knowhow
Lisp
Learning
Programming
Debugging
DDE
Compiler
Customization
Troubleshooting
Links
Code examples
Viewbench
News
Changes
Index
Search
Impressum
Home
Webs
Atari
Blog
Claus
CoCreateModeling
Klassentreffen
Main
Sandbox
Sommelier
TWiki
Xplm
My links
edit
TWiki
Welcome
TWiki Web TWiki Web Home Changes Topics Index Search
TWiki Webs Atari Blog Main
OneSpaceModeling
?
Sandbox TWiki TWiki Webs Atari Blog Main
OneSpaceModeling
?
Sandbox TWiki
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