General GIMP help

Little Mafföh, big scripts!

Everything related to GIMP. Place for beginners to ask questions.

Little Mafföh, big scripts!

Postby Maffe811 » Mon Nov 22, 2010 4:25 pm

Okay... so i... uhm, i found a script in my fx-foundry scripts that renames layers like this:

From
Layer backround
Layer render
Lay0r border
Layah gradient mapz

To 1a
(0)_Layer Layer backround
(1)_Layer Layer render
(2)_Layer Lay0r border
(3)_Layer Layah gradient mapz

Or 1b
(0)_Layer
(1)_Layer
(2)_Layer
(3)_Layer

got it ?

--

Okay, this is the only script i got that has the number value infront of the name!
And in the script file it says:

(Blahblahblahblah (layer...sth("_Layer")))

And i changed it to:

(Blahblahblahblah (layer...sth("_Layer (15ms) (replace) ")))

for animation purposes

My Q is:
how do i change a static text like _Layer into.. uhm.. *Inputnamehere*.
And how do i make it so i can change the *inputnamehere* in the script GUI!
Members don't see the above ad. Register now - it's free!
Got möp?
Image
SOTW #1 ^
"Photoshop!? You don't need no stinkin' Photoshop" - We'll show you the power of the Gimp!!!
---
Honest CnC always beats crap CnC
Baum wrote:I think it doesnt has to be mentioned that self-voters have a small p....hotograph :D
User avatar
Maffe811
Global Moderator
 
Posts: 6810
Joined: Thu Jul 02, 2009 1:00 pm
Location: Norway/Norge/Norwegen

Re: Little Mafföh, big scripts!

Postby humblejohnny20 » Mon Nov 22, 2010 5:25 pm

And how do i make it so i can change the *inputnamehere* in the script GUI!


At the bottom of the scripts there's usually a group of variables which appear in the GUI.

I think you also need to define them at the top

You'd need an SF-STRING type.

Can you upload the script or is it proprietary :P
One journey ends... Another begins.
humblejohnny20
Full Member
 
Posts: 169
Joined: Wed Nov 17, 2010 7:30 am

Re: Little Mafföh, big scripts!

Postby Maffe811 » Tue Nov 23, 2010 8:14 am

humblejohnny20 wrote:Can you upload the script or is it proprietary :P

I have no idea what this mean, but it says you are free to change the script the way you want and to re-distribute if that whats concernin ya!


DL that ^, and find "bates-layers-number.scm"
Got möp?
Image
SOTW #1 ^
"Photoshop!? You don't need no stinkin' Photoshop" - We'll show you the power of the Gimp!!!
---
Honest CnC always beats crap CnC
Baum wrote:I think it doesnt has to be mentioned that self-voters have a small p....hotograph :D
User avatar
Maffe811
Global Moderator
 
Posts: 6810
Joined: Thu Jul 02, 2009 1:00 pm
Location: Norway/Norge/Norwegen

Re: Little Mafföh, big scripts!

Postby humblejohnny20 » Tue Nov 23, 2010 6:58 pm

Ok, I dont know if this is exactly wat u want, but i added a SF-STRING input box, and the end of the layer name will become what you enter. I learned a little bit also :P
Took about 5 minutes. You should be able to customize it from there.


Code: Select all

;
; The GIMP -- an image manipulation program
; Copyright (C) 1995 Spencer Kimball and Peter Mattis
;
; Number layers script  for GIMP 2.4
; Created by Daniel Bates
; Edited by humblejohnny20
;
; Tags: public domain, layer names
;
; Author statement:
;
; Script designed to add number notation to the layers of the current image
; User chooses at what number layer to begin numbering
; Used mainly to identify which layers to affect with the other layer options scripts

;
; --------------------------------------------------------------------
; Distributed by Gimp FX Foundry project
; --------------------------------------------------------------------
;   - Changelog -
;
; --------------------------------------------------------------------
;
; This script is released into the public domain.
; You may redistribute and/or modify this script or extract segments without prior consent.

; This script is distributed in the hope of being useful
; but without warranty, explicit or otherwise.
;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


; Define Script

(define (script-fu-number-layers theImage theDraw theLayer theLName theReplace)

; Define Variables

(let*
(
    (theNumber 0)
    (theRepeat 0)
    (theName 0)
    (theLayerRef 0)
 )


; Begin an undo group
(gimp-undo-push-group-start theImage)

; Get the number of layers in an image and set to a variable
(set! theNumber (car (gimp-image-get-layers theImage)))

; Set the repeat variable by subtracting the user input value from the total number of layers
(set! theRepeat (- theNumber (- theLayer 1)))

; If repeat is less than 1 produce error message and exit, otherwise continue script
(if (< theRepeat 1)
(begin
(set! theLayerRef (car (gimp-message-get-handler)))
(gimp-message-set-handler 0)
(gimp-message "Error: Input layer number exceeds total number of layers!")
(gimp-message-set-handler theLayerRef)
(gimp-undo-push-group-end theImage)
)
(begin

; If user input is higher than the number of layers in the image readjust user input to the number of layers
(if (> theLayer theNumber)
(set! theLayer theNumber))

; Set up variable for setting active layers and attributes
 (set! theLayerRef (cadr (gimp-image-get-layers theImage)))

; Alter theNumber for use in setting active layers and attributes
(set! theNumber (- theNumber (- theLayer 1)))

; Begin loop and continue while repeat is higher than zero
(while (> theRepeat 0)

    ; Set the layer to be editted as the active layer
    ; (set! theDraw (gimp-image-set-active-layer theImage (aref theLayerRef (- theNumber 1))))

    ; Get the layer's name and append a number to it
    (if (= theLName TRUE)
    (set! theName (string-append "(" (number->string theLayer) ")" "_" (car (gimp-drawable-get-name (aref theLayerRef (- theNumber 1))))))
    (set! theName (string-append "(" (number->string theLayer) ")" theReplace)))

    ; Assign name to the layer
    (gimp-drawable-set-name (aref theLayerRef (- theNumber 1)) theName)

    ; Alter variables ready for checking for next layer and applying to next layer
    (set! theLayer (+ theLayer 1))
    (set! theNumber (- theNumber 1))
    (set! theRepeat (- theRepeat 1))

)

; Update visual display
(gimp-displays-flush)

; End undo group
(gimp-undo-push-group-end theImage)

))
))

; Register script
(script-fu-register     "script-fu-number-layers"
            "<Image>/FX-Foundry/Multi-Layer Tools/Number Layers..."
            "Edits layer names to number them. Numbering starts at user's specified number. Effect is culmulative if layers maintain original names."
            "Daniel Bates"
            "Daniel Bates"
            "Dec 2007"
            "*"
            SF-IMAGE "SF-IMAGE" 0
            SF-DRAWABLE "SF-DRAWABLE" 0
            SF-ADJUSTMENT _"Start at which layer?" '(1 1 2000 1 5 0 1)
            SF-TOGGLE _"Maintain current layer names?" TRUE
            SF-STRING _"Replace Name" "MyName"
)




"theReplace" is the name of the variable, I don't know what you want to call it. The default value is "MyName".
One journey ends... Another begins.
humblejohnny20
Full Member
 
Posts: 169
Joined: Wed Nov 17, 2010 7:30 am

Re: Little Mafföh, big scripts!

Postby humblejohnny20 » Wed Nov 24, 2010 7:25 pm

Is it working?


Image
One journey ends... Another begins.
humblejohnny20
Full Member
 
Posts: 169
Joined: Wed Nov 17, 2010 7:30 am

Re: Little Mafföh, big scripts!

Postby Maffe811 » Wed Nov 24, 2010 10:19 pm

my gimp froze when trying sumthin.... xD
so im gonna try when i have the time, but we had/have lotz of tests this week!
math, a whole day of new-norweigan (on friday) and... uhm.... i think somethin....
Got möp?
Image
SOTW #1 ^
"Photoshop!? You don't need no stinkin' Photoshop" - We'll show you the power of the Gimp!!!
---
Honest CnC always beats crap CnC
Baum wrote:I think it doesnt has to be mentioned that self-voters have a small p....hotograph :D
User avatar
Maffe811
Global Moderator
 
Posts: 6810
Joined: Thu Jul 02, 2009 1:00 pm
Location: Norway/Norge/Norwegen


Return to General GIMP help

Who is online

Users browsing this forum: No registered users and 1 guest