Composition > Scripting

Hier diskutieren die Betatester von PhotoLine untereinander und mit den Entwicklern
PhilM
Mitglied
Posts: 184
Joined: Thu 28 May 2015 18:00
Location: Belgium

Composition > Scripting

Post by PhilM »

Is it possible to use VBscript to browse around existing compositions ?
Or to create a new composition ?

I don't see the composition object in the scripting manual.

Best regards.
Martin Huber
Entwickler
Entwickler
Posts: 4208
Joined: Tue 19 Nov 2002 15:49

Re: Composition > Scripting

Post by Martin Huber »

PhilM wrote: Fri 06 Sep 2024 20:35 Is it possible to use VBscript to browse around existing compositions ?
IPLDocument has two properties regarding layer compositions:
  • ActiveLayerComposition: Returns the name of the active layer composition (or an empty string if there is none)
  • LayerCompositions: Returns an array of IPLDictionary objects. Each dictionary has two entries:
    • "name": The name of the composition.
    • "description":The description of the composition
The following VBScript queries the layer compositions and activates the second one (the one with the index 1):

Code: Select all

Dim pl
Dim doc

Set pl = CreateObject("PhotoLine.Application")
Set doc = pl.ActiveDocument

If Not doc Is Nothing Then
	Dim layerComps

	pl.Visible = True
	
	layerComps = doc.LayerCompositions
	'WScript.Echo "Number of compositions: " & UBound(layerComps)
	
	If (UBound(layerComps) > 1) Then
		doc.ActiveLayerComposition = layerComps(1)("name")
	End If
End If
PhilM wrote: Fri 06 Sep 2024 20:35 Or to create a new composition ?
There's no way to create a layer composition by script.
PhilM wrote: Fri 06 Sep 2024 20:35 I don't see the composition object in the scripting manual.
The documentation will be added when scripting of layer compositions is added to the official version.
PhilM
Mitglied
Posts: 184
Joined: Thu 28 May 2015 18:00
Location: Belgium

Re: Composition > Scripting

Post by PhilM »

Thanks !

Is scripting of layer compositions available in the last Beta B18 ?
Martin Huber
Entwickler
Entwickler
Posts: 4208
Joined: Tue 19 Nov 2002 15:49

Re: Composition > Scripting

Post by Martin Huber »

PhilM wrote: Tue 10 Sep 2024 15:07 Is scripting of layer compositions available in the last Beta B18 ?
Yes.
PhilM
Mitglied
Posts: 184
Joined: Thu 28 May 2015 18:00
Location: Belgium

Re: Composition > Scripting

Post by PhilM »

Both V24.01 and Beta 18 give me an error on line 11 of the script that the object does not handle the "LayerCompositions" property or method.

Phil
Martin Huber
Entwickler
Entwickler
Posts: 4208
Joined: Tue 19 Nov 2002 15:49

Re: Composition > Scripting

Post by Martin Huber »

PhilM wrote: Thu 12 Sep 2024 18:16 Both V24.01 and Beta 18 give me an error on line 11 of the script that the object does not handle the "LayerCompositions" property or method.
24.01 doesn't support scripting of layer compositions.
The script works fine here with B18.

Did you remember to activate scripting for B18?
https://www.pl32.com/forum3/viewtopic.p ... 835#p52835
PhilM
Mitglied
Posts: 184
Joined: Thu 28 May 2015 18:00
Location: Belgium

Re: Composition > Scripting

Post by PhilM »

Martin Huber wrote: Fri 13 Sep 2024 11:10
PhilM wrote: Thu 12 Sep 2024 18:16 Both V24.01 and Beta 18 give me an error on line 11 of the script that the object does not handle the "LayerCompositions" property or method.
24.01 doesn't support scripting of layer compositions.
The script works fine here with B18.

Did you remember to activate scripting for B18?
https://www.pl32.com/forum3/viewtopic.p ... 835#p52835
Understood ...
Yes it does work.

Thanks a lot.
PhilM
Mitglied
Posts: 184
Joined: Thu 28 May 2015 18:00
Location: Belgium

Re: Composition > Scripting

Post by PhilM »

What is the syntax to retrieve the index (0, 1, 2 ...) of the active composition ?

Thanks
Martin Huber
Entwickler
Entwickler
Posts: 4208
Joined: Tue 19 Nov 2002 15:49

Re: Composition > Scripting

Post by Martin Huber »

PhilM wrote: Sun 15 Sep 2024 09:24 What is the syntax to retrieve the index (0, 1, 2 ...) of the active composition ?
There is none. Depending on what you want to to, you can either check the name of the composition or you'll have to find it "manually". The following script activates the next layer composition.

Code: Select all

Dim pl
Dim doc

Set pl = CreateObject("PhotoLine.Application")
Set doc = pl.ActiveDocument

If Not doc Is Nothing Then
	Dim comps
		
	comps = doc.LayerCompositions
	' Is there more than 1 layer composition?
	If (UBound(comps) > 1) Then
		Dim activeCompName
		' Determine index of active layer composition
		activeCompName = doc.ActiveLayerComposition
		For i = 0 To UBound(comps)
			cmp = StrComp(comps(i)("name"), activeCompName)
			If (cmp = 0) Then
				Exit For
			End If
		Next
		' Switch to next layer composition
		i = i + 1
		' If there was no layer composition or the last one is the
		' active one, activate the first.
		If (i > UBound(comps)) Then
			i = 0
		End If
		doc.ActiveLayerComposition = comps(i)("name")
	End If
End If
PhilM
Mitglied
Posts: 184
Joined: Thu 28 May 2015 18:00
Location: Belgium

Re: Composition > Scripting

Post by PhilM »

Thank you
This does the job

Regards

Phil