Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How can I get a layer ID by its position ? [Script-Fu]
#6
Ok ... So, some precisions after some tests (and losing my last hair Big Grin ) :

In fact ... list-ref doesn't work ... because gimp-image-get-layers doesn't return a list for the layer IDs ...

gimp-image-get-layers is said to return "The number of layers contained in the image (num-layers >= 0)  [INT32]" and "The list of layers contained in the image. [INT32ARRAY]".
So, as "gimp-..." procedures always return a list, I thought gimp-image-get-layers returns a list with two elements : 1- the number of layers (a number) ; 2- a list of the layers' IDs (a list). But it doesn't work with this assessment...

I experimented a lot, and the list returned is indeed a two-element list, with the first term indeed being a number = the number of layers (ok, and easy to get --> "car (gimp-image-get-layers Image)") ; but the second element is not a list ... but a vector ! (Spent hours to find that ... Dodgy  Ok the description talks about "INT32ARRAY", maybe a term to mean "vector" ... but it's not specified ... and description talks about "list of layers" ...)

Definitely bald now, but it finally works, using vector-ref !
(can get easily the IDs' list (as a vector...) with "cadr (gimp-image-get-layers Image)").

((Could be usefull if someone else is asking.))
Reply


Messages In This Thread
RE: How can I get a layer ID by its position ? [Script-Fu] - by Nival - 07-29-2024, 06:56 PM

Forum Jump: