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 Tools Search this Thread Display Modes
  01 January 2013
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=

		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

  01 January 2013
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	

	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]())  
  01 January 2013
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

  01 January 2013
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...
  01 January 2013
so its the same sender and arg ....hmm....
  01 January 2013
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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
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
Society of Digital Artists

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

All times are GMT. The time now is 01:33 PM.

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