Is it possible to find objects by color?

Previous topic - Next topic

JavierSam

I mean, is there a way to ask Scribus to select all the elements that have a certain colour?

AdmFubar

Not one that is built in, you would have to script it.
What situation/use case are you trying to resolve? More details perhaps we can come up with an alternative.
Using Scribus 1.6.1, openSUSE 15.6
Advanced hobbyist

JavierSam

Hi AdmFubar Thanks for your reply.

I am trying to "Remove unused colours" from a file. But the supposed unused colours still appear in the colour palette.
So I guess they are applied to some object that I can't find.
That elusive object is an SVG imported from Inkscape (since the names of the colours I can't remove are, for example, "FromSVG#3b7d9f").

I thought I could find that object by searching by the colours I couldn't remove.
That's the reason for the original question.

AdmFubar

Have you looked in the  "Outline" window?  If you dont have it opened  yet,  from the main menu select Windows/Outline, it is about the 7th entry down. This will show all objects in your document. You should be able to find this allusive  svg that way.
Using Scribus 1.6.1, openSUSE 15.6
Advanced hobbyist

a.l.e

hey

i have now created a script that searches the current document for the first item that has the given color for its fill or stroke:

https://github.com/aoloe/scribus-script-repository/tree/master/search_by_color

sadly, scribus cannot yet get the color name for items that are inside of a group.

https://bugs.scribus.net/view.php?id=17160

so, if you think that the shape you're looking for is inside of an imported svg, you will need to first ungroup the drawing.

a.l.e

p.s.: i've created a patch for getting the scripter to query items by name, even if they're inside of groups.
it's attached to the ticket linked above.
as soon as the patch is accepted, the script will find the colors inside of groups.

JavierSam

Quote from: AdmFubar on February 15, 2024, 03:23:10 AMHave you looked in the  "Outline" window?  If you dont have it opened  yet,  from the main menu select Windows/Outline, it is about the 7th entry down. This will show all objects in your document. You should be able to find this allusive  svg that way.

It is a great tool. I didn't know it (or didn't remember it).
I figured I had to know the name of the object I was looking for. So I opened the Scribus file in a plain text editor and looked up the name of one of the colours.
For example, here is a part of the code that has the name of the colour:

<PAGEOBJECT XPOS="710.001430267374" YPOS="288.328782313903" OwnPage="-1" ItemID="1601467263" PTYPE="7" WIDTH="39.3892097961418" HEIGHT="117.669863848483" FRTYPE="3" CLIPEDIT="1" PWIDTH="1.08913688752862" PCOLOR="FromSVG#e20010" PLINEART="1" ANNAME=" path5480" TEXTFLOWMODE="1" path="M3.12701 0 C3.00285 1.68163 1.18396 2.77514 2.44736 5.24094 C3.07035 6.17434 4.90971 5.68647 5.17871 5.60149 C6.42253 4.80207 5.24127 2.09317 4.40813 0.414806 L3.12701 0 M9.13217 3.39026 C6.72366 3.34435 7.59607 9.33052 8.34403 11.4407 C5.99694 12.006 5.69728 7.9143 3.90238 9.34432 C3.13345 9.95864 2.3635 10.577 2.03894 11.2588 L3.90876 12.3756 C5.02402 17.1276 0.567433 11.9979 0 15.9318 C1.23859 18.0742 3.01209 16.9879 3.65509 15.6112 C5.80179 19.5473 -0.55127 21.1321 0.483406 23.3409 C2.58109 26.0072 5.18219 22.1995 6.75818 22.2528 C3.31324 24.124 3.18568 31.1665 4.99365 35.7932 C8.33946 39.2 7.1434 45.7949 11.5588 49.6494 C12.087 52.0466 12.5925 55.2869 13.5738 58.2788 L13.0425 58.5759 C13.22 58.5635 13.3958 58.5197 13.5929 58.4035 C12.042 61.8743 17.8436 64.7161 14.1689 67.389 C17.3011 68.9373 13.3607 69.072 13.1877 70.3756 C14.7517 72.4362 12.9139 77.3081 16.7247 76.6854 C16.5842 77.0001 16.3034 76.8449 16.1727 77.1577 L17.5799 78.7355 C18.4229 78.4193 19.5576 78.2694 20.2634 77.4862 C22.9717 79.3144 20.3143 79.2497 19.563 80.6308 C22.2586 84.103 24.5183 88.5227 24.5215 93.2471 C23.9726 93.5523 23.6224 93.9546 23.4217 94.4169 L30.9207 117.67 C33.0357 115.198 35.3048 116.028 36.6266 114.801 L39.3892 113.753 L38.4606 70.9702 C37.1394 63.7987 34.8314 57.1399 32.2099 50.7325 C29.1668 44.5343 30.356 39.8631 30.356 39.8631 C29.9922 40.1691 29.6308 39.8259 29.303 39.5743 C28.8194 40.5512 28.3191 41.5079 27.7985 42.4413 C27.6406 41.2726 27.4125 40.1264 26.9115 39.1483 C23.6778 39.5546 24.3605 33.3695 20.9526 33.4925 C19.3592 27.3847 21.6029 29.0674 20.2697 22.7602 C17.9096 20.2944 14.9339 17.4741 13.6727 13.7046 C13.1924 12.3519 13.9232 10.4715 14.6268 10.3463 C13.701 8.91407 12.6645 6.69695 12.0023 5.06545 C10.7386 3.88921 9.80652 3.40311 9.13217 3.39026 L9.13217 3.39026 " copath="M3.12701 0 C3.00285 1.68163 1.18396 2.77514 2.44736 5.24094 C3.07035 6.17434 4.90971 5.68647 5.17871 5.60149 C6.42253 4.80207 5.24127 2.09317 4.40813 0.414806 L3.12701 0 Z M9.13217 3.39026 C6.72366 3.34435 7.59607 9.33052 8.34403 11.4407 C5.99694 12.006 5.69728 7.9143 3.90238 9.34432 C3.13345 9.95864 2.3635 10.577 2.03894 11.2588 L3.90876 12.3756 C5.02402 17.1276 0.567433 11.9979 0 15.9318 C1.23859 18.0742 3.01209 16.9879 3.65509 15.6112 C5.80179 19.5473 -0.55127 21.1321 0.483406 23.3409 C2.58109 26.0072 5.18219 22.1995 6.75818 22.2528 C3.31324 24.124 3.18568 31.1665 4.99365 35.7932 C8.33946 39.2 7.1434 45.7949 11.5588 49.6494 C12.087 52.0466 12.5925 55.2869 13.5738 58.2788 L13.0425 58.5759 C13.22 58.5635 13.3958 58.5197 13.5929 58.4035 C12.042 61.8743 17.8436 64.7161 14.1689 67.389 C17.3011 68.9373 13.3607 69.072 13.1877 70.3756 C14.7517 72.4362 12.9139 77.3081 16.7247 76.6854 C16.5842 77.0001 16.3034 76.8449 16.1727 77.1577 L17.5799 78.7355 C18.4229 78.4193 19.5576 78.2694 20.2634 77.4862 C22.9717 79.3144 20.3143 79.2497 19.563 80.6308 C22.2586 84.103 24.5183 88.5227 24.5215 93.2471 C23.9726 93.5523 23.6224 93.9546 23.4217 94.4169 L30.9207 117.67 C33.0357 115.198 35.3048 116.028 36.6266 114.801 L39.3892 113.753 L38.4606 70.9702 C37.1394 63.7987 34.8314 57.1399 32.2099 50.7325 C29.1668 44.5343 30.356 39.8631 30.356 39.8631 C29.9922 40.1691 29.6308 39.8259 29.303 39.5743 C28.8194 40.5512 28.3191 41.5079 27.7985 42.4413 C27.6406 41.2726 27.4125 40.1264 26.9115 39.1483 C23.6778 39.5546 24.3605 33.3695 20.9526 33.4925 C19.3592 27.3847 21.6029 29.0674 20.2697 22.7602 C17.9096 20.2944 14.9339 17.4741 13.6727 13.7046 C13.1924 12.3519 13.9232 10.4715 14.6268 10.3463 C13.701 8.91407 12.6645 6.69695 12.0023 5.06545 C10.7386 3.88921 9.80652 3.40311 9.13217 3.39026 L9.13217 3.39026 Z" fillRule="0" gXpos="121.754008751015" gYpos="31.8078374320139" gWidth="289.184881889772" gHeight="220.239168895918" LAYER="0"/>

I tried in the Outline window searching by "1601467263" (the ItemID) y " path5480" (ANNAME), but no one returned any outcome.
I don't know if there is another value to search by.
I know nothing about the code, but it's even more strange to me the negative value in "OwnPage"

JavierSam

Quote from: a.l.e on February 15, 2024, 01:36:29 PMhey

i have now created a script that searches the current document for the first item that has the given color for its fill or stroke:

https://github.com/aoloe/scribus-script-repository/tree/master/search_by_color

sadly, scribus cannot yet get the color name for items that are inside of a group.

https://bugs.scribus.net/view.php?id=17160

so, if you think that the shape you're looking for is inside of an imported svg, you will need to first ungroup the drawing.

It seems to be a very useful script.
In fact I have tried it and it works fine.
But it didn't work with the "indelible" colours.

The error message was:

Traceback (most recent call last):
  File "<string>", line 11, in <module>
  File "<string>", line 189, in <module>
  File "<string>", line 183, in main
  File "<string>", line 110, in search_color
AttributeError: module 'scribus' has no attribute 'getGroupItems'



So it looks like it's within a group. I will re-download the script shortly and, with the patch you mention, it might work.

a.l.e

i have now uploaded a version of the script that checks if getGroupItems() exists, before using it (it won't magically make the script better but, now, it won't crash anymore when the command is missing).

getGroupItems() has been added on January 7 and scribus 1.6.1 has been released the same day.

but, as said, it won't select inside of the groups without the patch i've made today.