Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
changing active layers
#4
(01-29-2023, 12:47 PM)salamander017 Wrote:
(01-29-2023, 10:57 AM)programmer_ceds Wrote: It might help if you gave details of the error message.

Hello, thank you for your time.
Regarding that, the error says:
  GIMP Error
Execution error for 'Set active layers':
Error: Invalid type for argument 2 to gimp-image-set-active-layer
I think that the problem is that gimp-image-get-layers returns two parameters - the first is the number of layers and the second is an int32 array of the layer IDS (see the description of gimp-image-get-layers in the PDB browser).

So your code is assigning the number of layers to layer1, not the ID of the first layer.

Try replacing the assignments that set layer1 and layer2 with:

(num_layers (cad (gimp-image-get-layers image)))
(layers (cadr (gimp-image-get-layers image)))

then:

(layer1 (aref layers 0))
(layer2 (aref layers 1))



However, it would be better code to set layer1 and layer2 (using the set! statement) after your let* statement - having checked that the image does actually have 2 (or possibly, depending on your needs) at least 2 layers before proceeding - report an error if there are not 2 layers, then your script can fail gracefully if it activated with just the one layer.
Reply


Messages In This Thread
changing active layers - by salamander017 - 01-29-2023, 06:54 AM
RE: changing active layers - by programmer_ceds - 01-29-2023, 10:57 AM
RE: changing active layers - by salamander017 - 01-29-2023, 12:47 PM
RE: changing active layers - by programmer_ceds - 01-29-2023, 05:25 PM
RE: changing active layers - by salamander017 - 01-30-2023, 01:35 PM
RE: changing active layers - by Ofnuts - 01-31-2023, 11:25 AM
RE: changing active layers - by salamander017 - 02-01-2023, 09:35 AM
RE: changing active layers - by programmer_ceds - 02-01-2023, 09:54 AM
RE: changing active layers - by salamander017 - 02-01-2023, 10:40 AM
RE: changing active layers - by Ofnuts - 01-29-2023, 09:10 PM

Forum Jump: