PickObject in a Scripted Plug-in mouse Tool Clause


#1

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?


#2

What about

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

startTool test

#3

maybe :


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


#4

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


#5

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


#6

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

#7

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


#8

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.


#9

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!


#10

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


#11

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?


#12

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

You can download the code from:
http://www.proin3d.org/pathscripts/DOWNLOAD/HSigning/H_Signing_V100.ms


#13
				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)


#14

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


#15

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?


#16

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


#17

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


#18

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


#19

Maxscript code updated.
http://www.proin3d.org/pathscripts/DOWNLOAD/HSigning/H_Signing_V100.ms

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