Skip to main content
Known Participant
July 24, 2023

P: Can’t get background layer information with last beta

  • July 24, 2023
  • 6 replies
  • 1311 views

Hi,

 

After last update of beta version: Adobe Photoshop: 24.7.0 20230718.m.2245 afb5f03 x64

I can't get information about background layer (previous build works fine).

I'm using a Automation plugin in macOS.

 

This is a code sniped:

 

	SPErr error = kSPNoError;
	
	PIActionDescriptor result = NULL;
	PIActionReference reference = NULL;

	// BACKGROUND
	error = sPSActionReference->Make(&reference);
	if (error) goto returnError;
	
	error = sPSActionReference->PutProperty(reference, classBackgroundLayer, keyBackground);
	if (error) goto returnError;
	
	error = sPSActionReference->PutEnumerated(reference, classDocument,  typeOrdinal, enumTarget);
	if (error) goto returnError;
	
	sPSActionControl->Get(&result, reference);
	if (result != NULL)
		{
			hasKey = false;
			
			// Name
			error = sPSActionDescriptor->HasKey(result, keyName, &hasKey);
			if (error) goto returnError;
			if (hasKey)
				{
					memset(&data, 0, sizeof(data));
					
					// Name
					ASZString ztitle = NULL;
					error = sPSActionDescriptor->GetZString(result, keyName, &ztitle);
					if (error) goto returnError;
					
					if (!ASZString2CString(ztitle, data.name, sizeof(data.name)))
						error =  kBadParameterErr;
					
					if (ztitle)
						sASZString->Release(ztitle);					
					if (error) goto returnError;
					
					// Index
					error = sPSActionDescriptor->GetInteger(result, keyItemIndex, &data.index);
					if (error) goto returnError;
					
					// Background
					data.background = true;
					
					// Visible
					error = sPSActionDescriptor->GetBoolean(result,  keyVisible, &data.visible);
					if (error) goto returnError;
					
					// ID
					error = sPSActionDescriptor->GetInteger(result,  keyLayerID, &data.ID);
					if (error) goto returnError;
					
					// Selected
					data.selected = false;
					
					// Kind
					data.kind = kLayerKind_PixelSheet;
					
                    // Bounds
                    data.empty = false;

					// Data
					data.data = NULL;
				}
		}

 

 

 

This topic has been closed for replies.

6 replies

Known Participant
July 31, 2023

I will consider the suggestion. Thanks @Tom Ruark 

Tom Ruark
Inspiring
July 31, 2023

Another workaround is to NOT ask for all the keys but for a single key. If you first do this

error = sPSActionReference->PutProperty(reference, classProperty, keyBackground); before the other PutProperty it will work. It only fails if you as for ALL keys. In your *Release* code you should NOT ask for all keys as that can be very expensive! Ask for them one at a time even if you have many keys to get. It WILL BE faster.
CShubert
Community Manager
Community Manager
July 26, 2023

Glad this works for you @David_Storm 

 

Known Participant
July 26, 2023

Hi @Tom Ruark 

Using targetLayersIDs and layer information by ID I can get the background information.

Thanks.

Tom Ruark
Inspiring
July 25, 2023

The workaround is to NOT ask for classBackgroundLayer but get all the layer IDs via targetLayersIDs on the classDocument and then ask for the layer information via a reference with that id and with a property of “background” or no property to get them all. We are looking into a fix.

CShubert
Community Manager
Community Manager
July 25, 2023

Thank you @David_Storm we will have the team look into this.