# prompt to select quilt whose color we want to select by # selects without respect for layer visibility package require PWI_Glyph 2.17.3 set targetLayer 999 proc selectQuilt {} { global targetLayer ## Set Info label set text1 [ format "Select the reference-quilt (quilts of this color will move to layer %d)" $targetLayer ] ## Set selection mask set mask [pw::Display createSelectionMask -requireDatabase {Quilts}] ############################################### ## This script uses the getSelectedEntities command added in 17.2R2 ## Catch statement should check for previous versions if { [catch {pw::Display getSelectedEntities -selectionmask $mask curSelection}] } { set picked [pw::Display selectEntities -description $text1 -single\ -selectionmask $mask curSelection] if {!$picked} { puts "Script aborted." exit } } elseif { [llength $curSelection(Databases)] > 1 } { puts "Please select one quilt." exit } elseif { [llength $curSelection(Databases)] == 0 } { set picked [pw::Display selectEntities -description $text1 -single\ -selectionmask $mask curSelection] if {!$picked} { puts "Script aborted." exit } } ############################################### return $curSelection(Databases) } set masterItem [ selectQuilt ] set masterColor [ $masterItem getColor ] puts [ format "Selected quilt %s, master color is %s" [$masterItem getName] $masterColor ] # select all dbs: set numberOfDbs [pw::Database getCount] set listOfDbs [pw::Database getAll] # loop, if color = master, add to selection set set thisCollection [ pw::Collection create] set numberFound 0 foreach thisDb $listOfDbs { set isQuiltFlag [ $thisDb isOfType pw::Quilt ] if { $isQuiltFlag } { set thisColor [ $thisDb getColor ] if { $thisColor == $masterColor } { incr numberFound $thisCollection add [list $thisDb ] } } } puts [ format "Found %d quilts of this color" $numberFound ] $thisCollection do setLayer $targetLayer pw::Layer setDescription $targetLayer [ format "Quilts of color %s" $masterColor ] puts [ format "Moved to layer %d " $targetLayer]