ScriptSpot

Forum topic · General Scripting

how can i create shape button with script ?

By dussla · 2021-03-04

Description

hi
i would like to press button create- spline - recangle button with hwnd way

i modified sample code but error

what problem ?

fn pressButton hwnd: name:"OK" =
(
if hwnd == unsupplied do hwnd = DialogMonitorOPS.GetWindowHandle()
UIAccessor.PressButtonByName hwnd name
)

hwnd = windows.getchildhwnd #max "Create Shape"

DialogMonitorOPS.unRegisterNotification id:#rectangle
DialogMonitorOPS.RegisterNotification pressButton id:#rectangle
DialogMonitorOPS.Enabled = on
UIAccessor.PressButton hwnd[1]
DialogMonitorOPS.unRegisterNotification id:#rectangle
DialogMonitorOPS.Enabled = off

Comments (11)

wow wow very simple

dussla · 2021-03-04

wow wow
very thank you ~~~
very simple

hi jahman , there is some problem ~

dussla · 2021-03-05

i made this
but there is error ~

pls can you test ? ~

xx= startObjectCreation rectangle

select xx

max modify mode
modPanel.addModToSelection (Extrude ())

$.modifiers[#Extrude].amount = 50

.

jahman · 2021-03-05

you have to read the docs again :) if you want startObjectCreation to return value

ok i will tr

dussla · 2021-03-05

thank you
i will try

always thank you for good answer ~~~

i made this , pls check ~

dussla · 2021-03-05

i made this
but if i esc press , there is no "add modifier" function for undeifined

pls check again
sorry for many question ~

while not keyboard.escPressed do
(

measureLine = startObjectCreation rectangle returnNewNodes:true newNodeCallback:setColor

addModifier measureLine[1] (extrude amount:100000)

convertToPoly measureLine[1]

select (for obj in objects where intersects obj measureLine[1] collect obj)
deselect measureLine[1]

bigbox = selection[1]

ProBoolean.createBooleanObjects bigbox measureLine[1] 2 0 0
ProBoolean.SetPlanarEdgeRemoval bigbox 3

)

.

jahman · 2021-03-05

good.
just add another check to ensure that measureLine[1] actually contains a valid node

what your script is supposed to do?

Thank you ~~

dussla · 2021-03-05

This script is used to cut objects

I often use box object.

So i have to cut box.

So i made this.

Thank you
I will check your advice ~~~

.

jahman · 2021-03-05

I guess you don't really need while loop at all


(
	local rects = startObjectCreation rectangle returnNewNodes:true --newNodeCallback:OnNewNode

	for rect in rects where isValidNode rect do
	(
		addModifier rect (extrude amount:1000)
		convertToPoly rect

		for obj in objects where intersects obj rect do
		(
                        --  not all objects can be used in ProBoolean. TODO: Implement missing checks
			ProBoolean.CreateBooleanObjects obj (copy rect) 2 0 0
			ProBoolean.SetPlanarEdgeRemoval obj 3			
		)
	)

	StopCreating()
)

wow wow perpect

dussla · 2021-03-05

You are always so perfect
And I envy your concise code

You can only say that you are a real genius

Thank you so much for helping me so many times

.

jahman · 2021-03-05

thanks
Code simplicity comes from practice and reading a LOT of others code.
You don't have to be a genius at all to write a good maintainable code after a few years of daily practice.
It is actually harder to find a maxscript task that wasn't discussed over the past years here or on cgsociety.org. Some googling before writing code is a good idea most of the time.