close caddy menu

Hi, I am making optimization for connecting edges on mose movement. But dont know how to close caddy dialog. Previously I used "UIAccessor.CloseDialog t[1]", but it stoped working, you will find it in a full script bellow. How can I close this caddy menu? Thanks.

macroScript connectPreview_ category:"paulius3d" buttonText:"connectPreview" tooltip:"_connectPreview" -- CONNECT PREVIEW
(
local kasPazymeta
startPosX = mouse.pos.x
startPosY = mouse.pos.y
--print startPos
if $ != undefined and classof $ == Editable_Poly then( -- ar editPoly
if subobjectLevel == 2 then( -- ar Edge
if (polyOp.getEdgeSelection $) as string == (#{}) as string then( --ar pazymeta edge
messagebox "select edge/edges"
)else()
tool foo(
on mousePoint clickno do( -- ant paspaudimo darom
if clickno <= 2 then(
macros.run "paulius3d" "connectGrip_"
for child in (windows.getChildrenHWND 0 parent:#max) where (child[5] == "Connect Edges") do( -- dialogo pozicija ties 0
windPosAndSize = windows.getWindowPos child[1]
windows.setWindowPos child[1] 0 0 windPosAndSize.w windPosAndSize.h true
)
)else (
$.EditablePoly.ConnectEdges ()
t = windows.getChildHWND 0 "Connect Edges"
DestroyDialog t[1]
--UIAccessor.CloseDialog t[1]
#stop
)
)
on mouseMove clickno do(
try(
$.connectEdgeSlide = ((viewPoint.x - startPosX)/3)
$.connectEdgeSegments = (1+abs((viewPoint.y - startPosY-100)/300))
)catch false
)
on mouseAbort clickno do(
try(
t=windows.getChildHWND 0 "Connect Edges"
--UIAccessor.CloseDialog t[1]
)catch false
)
)
startTool foo
)
else(
subobjectLevel = 2
messagebox "make edge selection and run again"
)
)else messagebox "select Editable poly"
)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
paulius3d's picture

Hi, thanks for taking time to

Hi, thanks for taking time to check my problem. Yes, caddy dialog appears when I am trying to run macro to have connect dialog (connectGrip_). I know I could use old style connect dialog, but For other places, like extrude, bridge and so on, I quite like caddy menu. Just wondering is there is a simple command to close that dialog.

miauu's picture

.

Can you post the connectGrip_ so we can see the code?

paulius3d's picture

Hi, I have replaced that

Hi, I have replaced that macro to default macros, that shoud run on any 3ds max system. The script works as follow: If you have Editable Poly selected, in Edges subobjectt level. You have to select one edge and run the script. First macro selects the ring of edges, the second macro runs connect function. Later new edges move according to mouse movement, horizontaly shifts them to the sides, if you move verticaly, that adds some extra edges. Because of the mouse movement, you have to run this script as maxro, and assign the shortcut, as the mouse initial position matters. You can download as script file here:
https://mega.nz/#!LyYUGYSJ!H26F_vidiRFNNI31JcKyrEG2w4GcYMofFoIAUa6kIfo
or copy from bellow. Thanks a lot.

macroScript connectPreview_ category:"paulius3d" buttonText:"connectPreview" tooltip:"_connectPreview" -- CONNECT PREVIEW
(
local kasPazymeta
startPosX = mouse.pos.x
startPosY = mouse.pos.y
--print startPos
if $ != undefined and classof $ == Editable_Poly then( -- ar editPoly
if subobjectLevel == 2 then( -- ar Edge
if (polyOp.getEdgeSelection $) as string == (#{}) as string then( --ar pazymeta edge
messagebox "select edge/edges"
)else()
tool foo(
on mousePoint clickno do( -- ant paspaudimo darom
if clickno <= 2 then(
macros.run "Editable Polygon Object" "EPoly_Select_Ring"
macros.run "Ribbon - Modeling" "ConnectEdgesOptions"
for child in (windows.getChildrenHWND 0 parent:#max) where (child[5] == "Connect Edges") do( -- dialogo pozicija ties 0
windPosAndSize = windows.getWindowPos child[1]
windows.setWindowPos child[1] 0 0 windPosAndSize.w windPosAndSize.h true
)
)else (
$.EditablePoly.ConnectEdges ()
t = windows.getChildHWND 0 "Connect Edges"
DestroyDialog t[1]
--UIAccessor.CloseDialog t[1]
#stop
)
)
on mouseMove clickno do(
try(
$.connectEdgeSlide = ((viewPoint.x - startPosX)/3)
$.connectEdgeSegments = (1+abs((viewPoint.y - startPosY-100)/300))
)catch false
)
on mouseAbort clickno do(
try(
t=windows.getChildHWND 0 "Connect Edges"
--UIAccessor.CloseDialog t[1]
)catch false
)
)
startTool foo
)
else(
subobjectLevel = 2
messagebox "make edge selection and run again"
)
)else messagebox "select Editable poly"
)

miauu's picture

.

I can't find a solution. Sorry.

paulius3d's picture

.

No problem, thanks for taking time ;)

pixamoon's picture

`

Sorry it might be late, but did you try to print if there is any windows found with "Collect Edges"

Try to add:
print t.count
or:
messageBox t.count

after:
t = windows.getChildHWND 0 "Connect Edges"

Best,
Pixamoon

paulius3d's picture

*

That didn't work. Caddy is some kind of "not window" type dialog.

jahman's picture

.

Try this one.
But note that for some reason there's no resulting edges selection in caddy mode.

(
 
	$.EditablePoly.ConnectEdges ()
	t = windows.getChildHWND 0 "Connect Edges"
 
	qtwidgets = for w in UIAccessor.GetPopupDialogs() where (windows.getHWNDData w)[4] == "QWidget" collect w
	if qtwidgets.count > 2 then
	(
		-- caddy mode is active
		button_hwnd = qtwidgets[ qtwidgets.count ] -- last control is Apply button
		windows.sendMessage button_hwnd 0x201 1 0 -- left mouse click
 
	)
	else
	(
		UIAccessor.CloseDialog t[1]
	)
 
	#stop
)

and
caddy is absolutely a window
see for yourself

	$.EditablePoly.ConnectEdges ()
	t = windows.getChildHWND 0 "Connect Edges"
 
 
	for w in UIAccessor.GetPopupDialogs() do
	(
		format "% % \"%\" %\n" (UIAccessor.GetWindowClassName w) (UIAccessor.IsWindow w) (UIAccessor.GetWindowText w) (windows.getWindowPos w)
 
	)

ok, apply and cancel buttons have 22x22 dimensions in my 2014 max, don't know if it's the case for all the rest. But anyway, knowing control position you can find its handle pretty easily

btw. you can use Spy++ to check what messages are sent to any max control

paulius3d's picture

*

I tried your script, but it doesnt work on 3dsmax 2018

t: undefined

--qtwidgets: #()

--button_hwnd: undefined

Tried couple of modifications, and still didnt find a solution. Also installed spy++, played with it a bit and also didnt find a solution, or required "line" to solve that. For now I am using this script, that works well when disabling caddy controls, but as I mentioned previosly I quite like caddy controls in overal.

ps. dont know how to insert a script here properly :(

script

macroScript connectPreview_ category:"paulius3d" buttonText:"connectPreview" tooltip:"_connectPreview" -- CONNECT PREVIEW
(
local kasPazymeta
startPosX = mouse.pos.x
startPosY = mouse.pos.y
--print startPos
if $ != undefined and classof $ == Editable_Poly then( -- ar editPoly
if subobjectLevel == 2 then( -- ar Edge
if (polyOp.getEdgeSelection $) as string == (#{}) as string then( --ar pazymeta edge
messagebox "select edge/edges"
)else()
tool foo(
on mousePoint clickno do( -- ant paspaudimo darom
if clickno <= 2 then(
macros.run "Editable Polygon Object" "EPoly_Select_Ring"
macros.run "Ribbon - Modeling" "ConnectEdgesOptions"
for child in (windows.getChildrenHWND 0 parent:#max) where (child[5] == "Connect Edges") do( -- dialogo pozicija ties 0
windPosAndSize = windows.getWindowPos child[1]
windows.setWindowPos child[1] 0 0 windPosAndSize.w windPosAndSize.h true
)
)else (
$.EditablePoly.ConnectEdges ()
try(
uiaccessor.closedialog (windows.getchildhwnd 0 "Connect Edges")[1]
)catch false
#stop
)
)
on mouseMove clickno do(
try(
$.connectEdgeSlide = ((viewPoint.x - startPosX)/3)
$.connectEdgeSegments = (1+abs((viewPoint.y - startPosY-100)/300))
)catch false
)
on mouseAbort clickno do(
try(
uiaccessor.closedialog (windows.getchildhwnd 0 "Connect Edges")[1]
)catch false
)
)
startTool foo
)
else(
subobjectLevel = 2
messagebox "make edge selection and run again"
)
)else messagebox "select Editable poly"
)

jahman's picture

.

<code> ... code goes here ... </code>
but I won't be able to help you with anything above 2014 anyway

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.