• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to select text art programmatically?

Explorer ,
Apr 24, 2021 Apr 24, 2021

Copy link to clipboard

Copied

I have text handle (myTextHandle) and I'm trying to select text programatically, but the following does not help

sAIArt->SetArtUserAttr(myTextHandle, (kArtFullySelected | kArtSelected), (kArtFullySelected | kArtSelected));

 

Is there a way to select text art, not textReange programatically?

 

 

TOPICS
SDK

Views

385

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Explorer , May 02, 2021 May 02, 2021

Calling sAIDocument->SyncDocument(); before sAIArt->SetArtUserAttr helped to solve the issue.

Votes

Translate

Translate
Adobe
Engaged ,
Apr 25, 2021 Apr 25, 2021

Copy link to clipboard

Copied

Hi Syuzie, maybe you're looking for something more specific than this, but here's how I select all text objects.

	AIErr error = noErr;
	AIArtHandle **matches;
	long count;
	long i;
	long attributes;
	AIBoolean isEditable, isVisible;
	AILayerHandle layer = nil;

	error = unselect_selection();
	if (error) goto error;
	
	error = get_text_objects( &matches, &count );
	if (error) goto error;
	
	for ( i = 0 ; i < count ; i++ ) {
		error = sAIArt->GetLayerOfArt( (*matches)[i], &layer );
		if ( (error) || ( !layer ) ) goto error; // if no next layer, split
		error = sLayer->GetLayerEditable( layer, &isEditable );
		if (error) goto error;
		if ( !isEditable ) 
			continue;
		error = sLayer->GetLayerVisible( layer, &isVisible );
		if ( error ) goto error;
		if ( !isVisible ) 
			continue;
		error = sAIArt->GetArtUserAttr( (*matches)[i], kArtLocked | kArtHidden, &attributes);
		if ( error ) goto error;
		if ( attributes ) 
			continue;
		error = sAIArt->SetArtUserAttr( (*matches)[i], kArtSelected, kArtSelected );
	}

return kNoErr;

error:
	return error;

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 25, 2021 Apr 25, 2021

Copy link to clipboard

Copied

Thanks for the answer Rick, but setting kArtSelected doesn't work for me. I'm not sure is it related or no, my text is created as point text and is in the group.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

I think I may see the problem. Are you calling it this way?

 

     sAIArt->SetArtUserAttr(myTextHandle, (kArtFullySelected | kArtSelected), (kArtFullySelected | kArtSelected));

 

I may be wrong, but as I understand it you can check an attribute with GetArtUserAttr and (kArtFullySelected | kArtSelected) (OR'ing the two states, which gives a binary result that's not the same as either of the values you OR'ed), but you must choose one or the other when setting the attribute. I'd use only kArtSelected to set the attribute. If you use kArtSelected on a group or other art that has child art, all child art should become selected (fully selected) as well.

 

Please try it using only kArtSelected. I may have been doing it wrong for the last 30 years, but it's been working for me.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 26, 2021 Apr 26, 2021

Copy link to clipboard

Copied

It is really strange kArtSelected attribute value is 1 but it is actually not selected. Probably something wrong in my plugin

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
May 02, 2021 May 02, 2021

Copy link to clipboard

Copied

LATEST

Calling sAIDocument->SyncDocument(); before sAIArt->SetArtUserAttr helped to solve the issue.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines