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
@syuzie Ok. I managed to do it.
// Get current view
AIDocumentViewHandle vh;
sAIDocumentVi
...
Copy link to clipboard
Copied
You can try one of following options:
AIActionParamValueRef param;
sAIActionManager->AINewActionParamValue(¶m);
sAIActionManager->AIActionSetStringUS(param, 'itnm', ai::UnicodeString(kSnapomaticOnOffMenuItemCommandStr));
return sAIActionManager->PlayActionEvent("adobe_commandManager", kDialogOff, param);
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.
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
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
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.
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.
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.
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.
Copy link to clipboard
Copied
@syuzie Ok. I managed to do it.
// 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
Copy link to clipboard
Copied
@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.