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

How can I switch on AI smart guides in my plugin

Explorer ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Hello

Do you know how can I programmatically switch on AI smart guides in my plugin?

I've tried to set preferences like kAISnappingPrefShowSmartGuides & kAISnappingPrefShowToolGuides, but it does not help. Probably there should be a tool option but again cannot find any.

Any other ides? I know it is possible as I've seen it in other plugins. Just cannot figure out how

 

 

TOPICS
SDK , Third party plugins , Tools

Views

582

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

Participant , Feb 23, 2021 Feb 23, 2021

@syuzie Ok. I managed to do it.

 

  1. Create tool using AIToolSuite and assign it kToolWantsToTrackCursorOption
  2. In Plugin::TrackToolCursor (where you receive AIToolMessage, this is kSelectorAITrackToolCursor selector) you will receive AIToolMessage, this message contains event and cursor point (AIRealPoint)
  3. Call following to activate snap and get destination/snap point (snap annotations will be drawn automatically by AICursorSnapSuite suite)

 

 

 

 

 

// Get current view
AIDocumentViewHandle vh;
sAIDocumentVi
...

Votes

Translate

Translate
Adobe
Participant ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

You can try one of following options:

 

  1. Using AICommandManagerSuite::GetCommandIDFromName get command ID from command name "Snapomatic on-off menu item" (kSnapomaticOnOffMenuItemCommandStr), then with that ID call AIMenuSuite::InvokeMenuAction. To check wether smart guides are enabled i guess you can use AICursorSnapSuite::UseSmartGuides 
  2. Record an action, save to file, examine the file to find out which command is called (probably same as above, invoke menu action with key written above) and trigger same action using AIActionManagerSuite::RecordActionEvent. It would be something like this:
AIActionParamValueRef param;

sAIActionManager->AINewActionParamValue(&param);
sAIActionManager->AIActionSetStringUS(param, 'itnm', ai::UnicodeString(kSnapomaticOnOffMenuItemCommandStr));

return sAIActionManager->PlayActionEvent("adobe_commandManager", kDialogOff, param);

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 ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Thanks MilosR for the answer.

I've tried solution 1 but didn't get the expected result, then figured out that InvokeMenuAction actually is the same as I have clicked it in menu. 

So when my plugin tool is active and I select View->Smart Guides (Ctrl+u) it anyway doesn't show me smart guides.

 

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 ,
Feb 22, 2021 Feb 22, 2021

Copy link to clipboard

Copied

Forgot to mension

AICursorSnapSuite::UseSmartGuides(NULL) always return false despite the "View-> Smart Guide" menu item is choosen or no

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
Participant ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Did you try second solution (just paste code). It is same as Invoke, but it work in some cases when options are grayed-out/disabled

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 ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

@MilosR  I've tried and it looks it does the same just switches on/of smart guides in menu, but doesn't show guides.

I think the problem is: UseSmartGuides is not returning true. And I cannot figure out how to switch it on.

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
Participant ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

Did you create tool with AIToolSuite? Could you please describe that part. I tested method using PlayActionEvent and Smart Guides are turned on/off with code above - guides are also visible after, when i drag some element. It could be that it isn't possible to toggle smart guides at specific point in your code, maybe during drag.

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
Participant ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

I also checked with AnnotatorTool example. When Annotator Tool is active it is possible to toggle Smart Guides using code above or manually.

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
Participant ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

I think I got your point. You are able to toggle option, but guides are not visible while your tool is active.

 

If you wish for your tool to snap to guides during drag I think you need to make that yourself using AIHitTestSuite and AICursorSnapSuite. I didn't use this feature, so I don't know much. I will try to find out more, if i find something i will get back to you.

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
Participant ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

@syuzie Ok. I managed to do it.

 

  1. Create tool using AIToolSuite and assign it kToolWantsToTrackCursorOption
  2. In Plugin::TrackToolCursor (where you receive AIToolMessage, this is kSelectorAITrackToolCursor selector) you will receive AIToolMessage, this message contains event and cursor point (AIRealPoint)
  3. Call following to activate snap and get destination/snap point (snap annotations will be drawn automatically by AICursorSnapSuite suite)

 

 

 

 

 

// Get current view
AIDocumentViewHandle vh;
sAIDocumentView->GetNthDocumentView(0, &vh);

// Check if smart guides are active
if(sAICursorSnap->UseSmartGuides(vh)){

	AIRealPoint dst;

	// See documentation for control letters
	// You can also use HitTrack or TrackInRect 
	error = sAICursorSnap->Track(vh, fCursorArtPoint, message->event, "ATFGPLM v i o f", &dst);

	// After this you will have snap point in dst

}​

 

 

 

 

 

Per documentation AICursorSnapSuite functions doesn't accept NULL. You need to pass AIDocumentViewHandle

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 ,
Feb 23, 2021 Feb 23, 2021

Copy link to clipboard

Copied

LATEST

@MilosR you made my day! THANKS a lot

I was using HitTrack but with NULL and getting error PARM, but was playing with other parameters butnot with document.

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