Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello everyone, I need a little help. I have a working script for a year and I got stuck in one part and I can't solve it. the script should do this: -select all layers with suffix exmp: "*m*" -random select one Group from all layers "*m*" -must not indicate objects but only groups, because random selection works poorly if "group_1"(10objects) and "group_2"(300objects).
currently the script is as follows:
run 1: layer 1 select 0 group
layer 2 select 2 groups
run 2: layer 1 select 1 group
layer 2 select 1 group
run 3: layer 1 select 2 groups
layer 2 select 0 group
run 1 and 3 are bad. run 2 is correct
----- Select layer with suffix and group ------ work
showtextg1 = "*m*"
nodesInsideLayerWithPrefix = for nodeOn in objects where isGroupHead nodeOn and matchPattern nodeOn.layer.name pattern:showtextg1 collect nodeOn
if nodesInsideLayerWithPrefix.count > 0 then
select nodesInsideLayerWithPrefix
if selection.count != 0 then
(
hide $
selObjsArr = for nodeOn in objects where isGroupHead nodeOn and matchPattern nodeOn.layer.name pattern:showtextg1 collect nodeOn
if selObjsArr.count != 0 then
(
layersArr = #()
for o in selObjsArr do
(
selObjLayer = o.layer
appendIfUnique layersArr selObjLayer
)
objToSelArr = #()
for la in layersArr do
(
la.nodes
append objToSelArr (nodes[random 1 nodes.count])
)
select objToSelArr
)
)
----- UnHide all what is selected ------ work
hiddenObjs = for obj in objects where obj.isNodeHidden collect obj
unhide selection hiddenObjs ;
iwant this result:
Thanks for any advice.
Solved! Go to Solution.