Skip to main content
Known Participant
Jul 24, 2023 8:55 AM UTC
Released

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

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 is closed to new replies. Start a new post to keep the conversation going.

6 replies

Known Participant
Jul 31, 2023 6:39 AM UTC

I will consider the suggestion. Thanks @Tom Ruark 

Translate
Tom Ruark
Inspiring
Jul 31, 2023 12:33 AM UTC

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.
Translate
CShubert
Community Manager
Community Manager
Jul 26, 2023 2:15 PM UTC

Glad this works for you @David_Storm 

 

Translate
Known Participant
Jul 26, 2023 1:46 PM UTC

Hi @Tom Ruark 

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

Thanks.

Translate
Tom Ruark
Inspiring
Jul 25, 2023 8:47 PM UTC

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.

Translate
CShubert
Community Manager
Community Manager
Jul 25, 2023 6:50 PM UTC

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

 

Translate