how can i create shape button with script ?

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

Comment viewing options

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

.

use startObjectCreation

dussla's picture

hi jahman , there is some problem ~

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's picture

.

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

dussla's picture

i made this , pls check ~

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's picture

.

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

what your script is supposed to do?

dussla's picture

Thank you ~~

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's picture

.

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()
)

dussla's picture

wow wow perpect

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's picture

.

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.

dussla's picture

ok i will tr

thank you
i will try

always thank you for good answer ~~~

Comment viewing options

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