Edit
Attach
Printable
topic end
<!-- * Set TOPICTITLE = <nop>CoCreate Modeling code examples: Delete all parts matching a pattern --> <style type="text/css"> pre { background-color:#FFEECC; } </style> #DeleteMatchingParts ---++ <nop>CoCreate Modeling: Deleting all parts matching a pattern This example demonstrates how to combine the selection facilities in =sd-defdialog= and pattern matching. The dialog takes two inputs: * A list of parts (use the standard selection mechanisms to build the list, for example "select recursively all parts in assembly", "all at top", "all in 3D box" etc.) * A pattern which the names of the selected parts are compared against The code scans all selected parts and compares their names with the specified pattern. If the pattern matches, the part is deleted. <tt>sd-string-match-pattern-p</tt> accepts a number of special characters and wildcards - see the Developer's Kit documentation (reference manual, section on "String Handling") for details. Examples: * <tt>part*</tt> matches =part=, =part42=, =party= etc. * <tt>*part*</tt> matches =depart=, =departure=, =part= etc. * <tt>p?rt</tt> matches =part=, =port= and =pirt= (whatever the latter may be :D ) * <tt>[a-z]art</tt> matches =part= and =dart= <pre> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; Description: Deletes parts matching a pattern ;; Author: Claus Brod ;; Created: 2/11/2005 20:20 ;; Language: Lisp ;; ;; (C) Copyright 2005 Claus Brod, all rights reserved ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; (in-package :clausbrod.de) (use-package :oli) (sd-defdialog 'DELETE_MATCHING_PARTS :dialog-title "Delete matching parts" :toolbox-button t :variables '( (parts :value-type :part :multiple-items t) (pattern :value-type :string :initial-value "*42*")) :local-functions '( (delete-item (item) (when (sd-string-match-pattern-p pattern (sd-inq-obj-basename item)) (sd-call-cmds (delete_3d item)))) ) :ok-action '(mapc #'delete-item parts) ) </pre> Thanks to Stephan Wörz for the [[http://ww3.cad.de/foren/ubb/Forum29/HTML/001471.shtml][inspiration]]. If you also need to delete assemblies which match a pattern, you could simply change the variable type for =parts= from =:part= to =:part-assembly=. However, it is not clear what happens in the following scenario: * Selection returns =/a1pattern/= and =/a1pattern/p1pattern= * =delete-item= is called for =/a1pattern= and deletes the assembly (including =/a1pattern/p1pattern= * =delete-item= is called again, this time for =/a1pattern/p1pattern= and tries to delete it although it no longer exists. -- Main.ClausBrod - 11 Feb 2005 See MacroSwapColor to see how the approach above can be used to find all parts with a specified color, and change it to some new 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.10 |
>
|
r1.9
|
>
|
r1.8
|
Total page history
|
Backlinks
You are here:
CoCreateModeling
>
MacroDeleteMatchingParts
r1.10 - 24 Jul 2009 - 19:52 -
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