[Closed] <Edit_Poly>.GetOperation() counterpart in Editable Poly?
The joys of max… this seems to work and will return the name of the current caddie control in max 2018 (the first line of it, since different parameter names are appended to it depending on the active input):
dotnet.LoadAssembly "UIAutomationClient.dll"
topLevelWindows = windows.getChildrenHwnd (windows.getDesktopHWND())
ownerHWND = (windows.getChildrenHWND (windows.getMaxHWND()))[6][1]
caddyHWND = for w in topLevelWindows where w[3] == ownerHWND and w[4] == "Qt5QWindowToolSaveBits" do exit with w[1]
UIAElem = (dotNetClass "System.Windows.Automation.AutomationElement").FromHandle caddyHWND
subElems = UIAElem.FindAll (dotNetClass "System.Windows.Automation.TreeScope").Children (dotNetClass "System.Windows.Automation.PropertyCondition").TrueCondition
name = (filterString subElems.Item[0].Current.Name "
")[1]
But of course, since it’s going through all desktop children, it’s not that fast. Translating it to C# or anything else will remove the speed problem, the question that remains is: what’s the proper way to get the owner and what is it exactly anyway? I’m talking about this handle:
ownerHWND = (windows.getChildrenHWND (windows.getMaxHWND()))[6][1]
I don’t feel super confident about the indexed access and would prefer some sure way of getting it that won’t change in the next release or something…
i found finally how to get via SDK an Active Caddy if any active:
#include <igrip.h>
MSTR* GetActiveGripName()
{
FPInterface* fpi = ::GetCOREInterface(IGRIPMANAGER_INTERFACE);
if (fpi)
{
IGripManager* igrip = (IGripManager*)fpi;
if (IBaseGrip* base = igrip->GetActiveGrip())
{
MSTR name;
base->GetGripName(name);
return new MSTR(name);
}
}
return NULL;
}
it should be easy to do with MaxPlus as well.
Please show a solution if you will be able to get it.
PS. if Caddies are not used the windows search has to work instead
That’s awesome, exactly what I wanted! Here it is as a c# method:
IGlobal global = Autodesk.Max.GlobalInterface.Instance;
public static string getActiveGripName()
{
IFPInterface fpi = global.GetCOREInterface(global.Interface_ID.Create(0x59cb513c, 0x7a0a5232));
ICustomMarshaler marshaler = Autodesk.Max.Wrappers.CustomMarshalerIGripManager.GetInstance("");
Autodesk.Max.Wrappers.IGripManager igrip = (Autodesk.Max.Wrappers.IGripManager)marshaler.MarshalNativeToManaged(fpi.NativePointer);
if (igrip != null)
{
IIBaseGrip baseGrip = igrip.ActiveGrip;
if (baseGrip != null)
{
string name = "";
baseGrip.GetGripName(ref name);
return name;
}
}
return null;
}
Btw. I’m glad I’ve also checked UI Automation, might come in handy some time, quite a bit friendlier than pinvoke methods as well
as i’ve understood it works for any max version ‘where Caddies are’ + , right?
at least the SDK solution…
To change properties (say bridge/connect/chamfer etc. segments) matching the currently active mode.