dynamic Context menu - select by modifier

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 01 January 2013   #1
Smile dynamic Context menu - select by modifier


(
	local form = dotnetobject "MaxCustomControls.Maxform"
	form.ShowInTaskbar = off
	form.FormBorderStyle = form.FormBorderStyle.None
	form.AllowTransparency = on
	form.Opacity = 0
	 --form.TransparencyKey = form.Backcolor

	form.StartPosition = form.StartPosition.Manual
	form.Size = Form.MinimumSize

	cursor = dotnetclass "System.Windows.Forms.Cursor"
	p = cursor.Position	

	form.Location =  dotnetobject "System.Drawing.Point" p.x (p.y+5) --500 300

	cm = dotNetObject "ContextMenu"
	
	form.ContextMenu = cm	
		
	items = for i in selection[1].modifiers collect i.name	
	
	fn selObject sender arg=
	(
		theSelection=#()

		for j in objects do
		(
			for k in j.modifiers do
			(
				If ((classof k) as string) == arg do appendIfUnique theSelection j
			)
		)
		print theSelection
	)

		
	for i in items do
	(
		item = cm.menuitems.add i
		item.name = i
		dotnet.addEventHandler item "Click" selObject  
	)


......


I want to select modifier by the name of context menu title I click, but when I try to execute the script...at the name of context menu ...the result always display "false"....please someone give me input how to make it work....


thanks many and best regard


fajar
 
Old 01 January 2013   #2
something like this:

try(form.close()) catch()
(
	global form = dotnetobject "MaxCustomControls.Maxform"
	form.ShowInTaskbar = form.MinimizeBox = form.MaximizeBox = off
	form.StartPosition = form.StartPosition.Manual
	form.Bounds = dotnetobject "System.Drawing.Rectangle" 800 200 100 60

	cm = dotNetObject "ContextMenu"
	
	fn onPopup s e = 
	(
		fn onClick s e = undo "Delete" on deletemodifier s.parent.tag.value s.tag.value
		for n in selection do
		(
			item = dotnetobject "MenuItem" n.name
			item.tag = dotnetmxsvalue n
			item.enabled = (n.modifiers.count > 0)
			
			for m in n.modifiers do
			(
				i = dotnetobject "MenuItem" m.name
				i.tag = dotnetmxsvalue m
				dotnet.addEventHandler i "Click" onClick
				item.menuitems.add i
			)
			s.menuitems.add item
		)
	)
	fn onCollapse s e = s.menuitems.Clear()
	
	dotnet.addEventHandler cm "Popup" onPopup
	dotnet.addEventHandler cm "Collapse" onCollapse
	
	form.ContextMenu = cm	
	form.showmodeless()
)		

(
	delete objects 
	for k=1 to 8 do
	(
		n = #(box, sphere, cylinder, cone)[random 1 4] pos:(random -[50,50,50] [50,50,50]) wirecolor:(random red green)
		for i=1 to (random 0 5) do addmodifier n (#(UVWmap, Unwrap_UVW, Edit_Poly, Edit_Normals, XForm)[random 1 5]())  
	)
	redrawviews()
)
 
Old 01 January 2013   #3
Thank denis...i got the big idea...but something is bugging me ...what do you mean by ...

onPopup s e ..... what s ...what e...sorry new dotnet learner...

also I just want to show the rc menu (right click only ) without empty dialog ...is that posible ?

thanks for input ...



best regard



fajar
 
Old 01 January 2013   #4
Originally Posted by fajar: ?

if i answer all your questions providing a sample code i will completely write your script for you

you have to read about dotnet event system, what the sender is, and the event argument it. the mxs help is a good start. there are many samples on this forum...
 
Old 01 January 2013   #5
so its the same sender and arg ....hmm....
 
Old 01 January 2013   #6
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:03 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.