PickObject in a Scripted Plug-in mouse Tool Clause


I have a scripted Plug-in to create a manipulator (it can be a helper or an object) that I want to create with the mouse ‘mousePoint’ event at a position depending on an scene object (that I need to pick on creation).
For example, in the center of an existing object, or at the start of a spline, or…
How can I make the ‘pickObject’ command work in the ‘mousePoint’ event? Is there another way to do it?


What about

tool test numPoints:2
	on mousePoint clickNo do
		print (intersectRayScene (mapScreenToWorldRay mouse.pos)) #noMap

startTool test


maybe :

   on mousePoint click do
      objs = boxPickNode (box2 (viewPoint.x-1) (viewPoint.y-1) 3 3) crossing:on


When ‘Auto Window/Crossing by Direction’ is active, this always returns empty array for me.


maybe… but there is no ray-intersection with anything different than mesh-geometry


I like it better, too. There’s maxOps.setSelectionType to set the Auto window/crossing mode together with the direction, and you can get the current state with

getINISetting (getMAXIniFile()) #Performance #AutoCross
getINISetting (getMAXIniFile()) #Performance #AutoCrossDir


if just tested it … it works with “auto crossing” on my MAX 2016


I only tested in max 9 and max 2018 with couple of boxes in scene, returns empty array in both no matter if I click on edge or anywhere else on any box. When turned off, it worked, no idea what else might differ.


Thanks a lot both! I didn’t thought/knew about that.
As I need to pick shapes, I have to go through ‘boxPickNode’

I’m under Max2014. It allways works except for “maxOps.setSelectionType true 0”, meaning ‘Auto Window/Crossing by Direction’ is active with selection right to left. With selection left to right (true 1) it works. And with ‘Auto Window/Crossing by Direction’ disabled too.

Thanks again!


i confirm. with “maxOps.setSelectionType true 0” it doesn’t work. It’s a bug, and it has to be reported


I’m retaking this plugin, now creating a SimpleObject based on a SplineShape.
New Question:
In the ‘mouse tool create’, is it possible to force the nodeTM (the node transform) to be always the identity even though the user clicks in a Front or Left view?
I have tried assigning the nodeTM and assigning the ‘(refs.dependentNodes this)[1].transform’ but can’t get it work.
Any advice?


Never mind…
I’ve made a prototype SimpleObject plugin for Horizontal Signing Lines geometry creation.

You can download the code from:

				numFaces = mesh.numFaces;
				extrudeFace mesh #{1..numFaces}  thickness 100.0 dir:[0,0,1];
				numVerts = mesh.numVerts;
				meshop.moveVert mesh #{1..numVerts} [0,0,-thickness]

in most mesh and poly methods you can use #all instead of #{1…numFaces} (#{1…numVerts})

(also you can use #selection where you need only selected sub objects)


Yes, thanks. I forgot it. It’s been a while I don’t code in maxscript and in fact this plugin is just a prototype to write it in C# (at least deep mesh calculations).


One stupid (?) question…
To avoid making all a ‘SimpleObject’ plugin in the SDK way (descriptor, UI, beginedit, …) I have thought about the possibility of:

  • mantain the plugin as mxs
  • rewrite just the ‘on buildmesh’ event, where all the hardwork of updating the mesh is done.

So I have tryed to send the baseObject we are creating to the C# method, get its mesh and update it. I haven’t get it to work, as I think the mesh I get is not the one I should (sadly, a mesh has no handleByAnim)

Then, that’s what I’ve done and it seems to work, but I would like to know your opinion about possible objections/inconveniences:

  • When loading definition of the plugin in mxs (or on loading of a new scene), create an empty EditableMesh (through SDK) and keep its 'handleByAnim".
  • In the ‘on buildmesh’ event, call the C# method that creates the modifyed mesh on this fixed EditableMesh.
  • As result, copy this new mesh to the ‘mesh’ of our plugin object (just before the end of the event).
  • free the fixed mesh

By now, I haven’t found any incovenience, saving, loading, creating copies, references or instances and works really fast.
What do you think about?


this is what i do and i’m sure this is the most productive (and protected) way of development


But do you get the real mesh or do you do a similar trick?


i work with real mesh. because i use c++ sdk

… and not mesh only. i do the same for spline shapes, controllers, modifiers, etc. finally it’s very close to how MCG resulting code looks like


Maxscript code updated.

EDIT: sorry, there was an error in the previous version. Updated to new version.