Notifications
Clear all

[Closed] Scripted Helper Plugin – DisplayMesh

I’ve been trying to create a scripted plugin Helper that has custom geometry… The example has it using a primative, but I wish to have it be a text object… or text in the form of a mesh object…


plugin Helper MatteManBaseObject
name:"MatteMan" 
classID:#(0x47db14fe, 0x4e9b5f90) 
category:"Standard" 
extends:dummy 
( 
local tnMesh
on getDisplayMesh do 
	(
	if ( meshObj == undefined ) do 
		(
		tnMesh = Mesh vertices:#([-184.5,0,0],[-184.5,54.6,0],[-165.931,0,0],[-158.297,0,0],[-139.6,53.7,0],[-139.6,0,0],[-131.4,0,0],[-131.4,64.1,0],[-142.861,64.1,0],[-158.234,19.525,0],[-161.65,9.25469,0],[-164.73,18.7391,0],[-179.995,64.1,0],[-192.7,64.1,0],[-192.7,0,0],[-86.8,0,0],[-78.7,0,0],[-80.6156,5.62813,0],[-81.1,19.5125,0],[-81.1,29.9813,0],[-81.4937,37.2266,0],[-83.9484,42.5812,0],[-89.4258,46.1008,0],[-99.1094,47.5,0],[-109.671,45.8602,0],[-116.638,41.1813,0],[-120.1,33.2,0],[-112.4,32.2,0],[-108.454,39.0617,0],[-100.187,41,0],[-91.1484,38.3328,0],[-88.9,31.5547,0],[-88.9437,29.5,0],[-103.086,26.7906,0],[-110.134,25.6109,0],[-115.839,23.0328,0],[-119.936,18.5102,0],[-121.5,12.2844,0],[-117.36,2.73594,0],[-105.514,-1,0],[-96.7719,0.535156,0],[-88.4,5.8,0],[-88.9437,20.4312,0],[-90.225,12.6078,0],[-95.4805,7.1875,0],[-103.65,5.2,0],[-110.693,7.28828,0],[-113.1,12.5094,0],[-112.003,16.2297,0],[-108.888,18.775,0],[-102,20.3406,0],[-89.1,23.3,0],[-55.1922,6.7,0],[-57.9102,7.27031,0],[-59.2805,8.80625,0],[-59.7,13.15,0],[-59.7,40.4,0],[-51.7,40.4,0],[-51.7,46.5,0],[-59.7,46.5,0],[-59.7,62.7125,0],[-67.6,57.9938,0],[-67.6,46.5,0],[-73.4,46.5,0],[-73.4,40.4,0],[-67.6,40.4,0],[-67.6,13.6359,0],[-66.6367,4.32813,0],[-63.3094,0.757813,0],[-56.6547,-0.6,0],[-50.7,0.0953125,0],[-51.7,7.04375,0],[-30.2922,6.7,0],[-33.0102,7.27031,0],[-34.3805,8.80625,0],[-34.8,13.15,0],[-34.8,40.4,0],[-26.8,40.4,0],[-26.8,46.5,0],[-34.8,46.5,0],[-34.8,62.7125,0],[-42.7,57.9938,0],[-42.7,46.5,0],[-48.5,46.5,0],[-48.5,40.4,0],[-42.7,40.4,0],[-42.7,13.6359,0],[-41.7367,4.32813,0],[-38.4094,0.757813,0],[-31.7547,-0.6,0],[-25.8,0.0953125,0],[-26.8,7.04375,0],[7.75233,7.76641,0],[0.353119,5.5,0],[-9.36563,9.54453,0],[-13.7,21.2,0],[20.9562,21.2,0],[21,23.3,0],[15.0984,41.1547,0],[-0.115631,47.5,0],[-15.7672,41.0336,0],[-21.8,22.8563,0],[-15.8328,5.27031,0],[0.321869,-1,0],[13.6117,2.93594,0],[20.7375,14,0],[12.6125,15,0],[-9.20001,37.3805,0],[-0.0593872,41,0],[9.71875,36.4656,0],[12.7,27.7,0],[-13.3,27.7,0],[39.5,0,0],[39.5,54.6,0],[58.0688,0,0],[65.7031,0,0],[84.4,53.7,0],[84.4,0,0],[92.6,0,0],[92.6,64.1,0],[81.1391,64.1,0],[65.7656,19.525,0],[62.35,9.25469,0],[59.2703,18.7391,0],[44.0047,64.1,0],[31.3,64.1,0],[31.3,0,0],[137.2,0,0],[145.3,0,0],[143.384,5.62813,0],[142.9,19.5125,0],[142.9,29.9813,0],[142.506,37.2266,0],[140.052,42.5812,0],[134.574,46.1008,0],[124.891,47.5,0],[114.329,45.8602,0],[107.362,41.1813,0],[103.9,33.2,0],[111.6,32.2,0],[115.546,39.0617,0],[123.813,41,0],[132.852,38.3328,0],[135.1,31.5547,0],[135.056,29.5,0],[120.914,26.7906,0],[113.866,25.6109,0],[108.161,23.0328,0],[104.064,18.5102,0],[102.5,12.2844,0],[106.64,2.73594,0],[118.486,-1,0],[127.228,0.535156,0],[135.6,5.8,0],[135.056,20.4312,0],[133.775,12.6078,0],[128.52,7.1875,0],[120.35,5.2,0],[113.307,7.28828,0],[110.9,12.5094,0],[111.997,16.2297,0],[115.112,18.775,0],[122,20.3406,0],[134.9,23.3,0],[162.9,0,0],[162.9,25.3828,0],[166.535,37.5055,0],[175.178,40.7,0],[180.642,39.2773,0],[183.886,35.4703,0],[184.8,28.2719,0],[184.8,0,0],[192.7,0,0],[192.7,28.5609,0],[192.264,36.2156,0],[189.82,42.0328,0],[184.559,45.9914,0],[176.855,47.5,0],[162.1,39.9016,0],[162.1,46.5,0],[155,46.5,0],[155,0,0]) faces:#([14,15,1],[14,1,2],[13,14,2],[12,13,2],[12,2,3],[11,12,3],[11,3,4],[11,4,5],[10,11,5],[9,10,5],[8,9,5],[7,8,5],[7,5,6],[42,16,43],[42,43,44],[42,44,45],[41,42,45],[41,45,46],[40,41,46],[16,17,18],[43,16,18],[43,18,19],[26,27,28],[26,28,29],[25,26,29],[43,19,20],[52,43,20],[25,29,30],[24,25,30],[39,40,46],[39,46,47],[38,39,47],[38,47,48],[37,38,48],[37,48,49],[36,37,49],[36,49,50],[35,36,50],[35,50,51],[34,35,51],[34,51,52],[33,34,52],[33,52,20],[32,33,20],[32,20,21],[31,32,21],[31,21,22],[31,22,23],[31,23,24],[30,31,24],[60,61,62],[60,62,63],[70,71,72],[70,72,53],[69,70,53],[69,53,54],[68,69,54],[68,54,55],[67,68,55],[67,55,56],[67,56,57],[66,67,57],[64,65,66],[63,64,66],[60,63,66],[60,66,57],[59,60,57],[59,57,58],[80,81,82],[80,82,83],[90,91,92],[90,92,73],[89,90,73],[89,73,74],[88,89,74],[88,74,75],[87,88,75],[87,75,76],[87,76,77],[86,87,77],[84,85,86],[83,84,86],[80,83,86],[80,86,77],[79,80,77],[79,77,78],[96,111,112],[111,96,97],[111,97,98],[111,98,99],[110,111,99],[110,99,100],[109,110,100],[105,106,107],[105,107,93],[104,105,93],[104,93,94],[109,100,101],[108,109,101],[103,104,94],[103,94,95],[102,103,95],[102,95,96],[108,101,102],[112,108,102],[112,102,96],[126,127,113],[126,113,114],[125,126,114],[124,125,114],[124,114,115],[123,124,115],[123,115,116],[123,116,117],[122,123,117],[121,122,117],[120,121,117],[119,120,117],[119,117,118],[154,128,155],[154,155,156],[154,156,157],[153,154,157],[153,157,158],[152,153,158],[128,129,130],[155,128,130],[155,130,131],[138,139,140],[138,140,141],[137,138,141],[155,131,132],[164,155,132],[137,141,142],[136,137,142],[151,152,158],[151,158,159],[150,151,159],[150,159,160],[149,150,160],[149,160,161],[148,149,161],[148,161,162],[147,148,162],[147,162,163],[146,147,163],[146,163,164],[145,146,164],[145,164,132],[144,145,132],[144,132,133],[143,144,133],[143,133,134],[143,134,135],[143,135,136],[142,143,136],[181,182,165],[181,165,166],[179,180,181],[179,181,166],[179,166,167],[178,179,167],[178,167,168],[172,173,174],[171,172,174],[171,174,175],[170,171,175],[170,175,176],[169,170,176],[169,176,177],[169,177,178],[169,178,168]) 
		)
	tnMesh.mesh
	)
Tool create 
	(
	on mousePoint click do 
		(
		nodeTM.translation = gridPoint;#stop 
		)
	) 
)

I have this, but it generates an actual mesh in the scene… I just want to create the trimesh and not a node… and not have max quick exit would be good too…

Thanks

22 Replies

You’re currently constructing a mesh object; you should use createInstance and then manipulate that mesh.
In addition, you’re creating it ever time getDisplayMesh is invoked; I think you meant to say “if (tnMesh == undefined)”. ‘meshObj’ from the help file example is always undefined in your script, so it will create a ton of meshes (and is probably what makes max unhappy).

Here’s one example replacement code:


plugin Helper MatteManBaseObject
name:"MatteMan" 
classID:#(0x47db14fe, 0x4e9b5f90) 
category:"Standard" 
extends:dummy (
	local tnMesh
	on getDisplayMesh do (
		if (tnMesh == undefined) then (
			tnMesh = (createInstance Plane).mesh
			for i = tnMesh.numVerts to 1 do ( deleteVert tnMesh i )
			tnVerts = #([-184.5,0,0],[-184.5,54.6,0],[-165.931,0,0],[-158.297,0,0],[-139.6,53.7,0],[-139.6,0,0],[-131.4,0,0],[-131.4,64.1,0],[-142.861,64.1,0],[-158.234,19.525,0],[-161.65,9.25469,0],[-164.73,18.7391,0],[-179.995,64.1,0],[-192.7,64.1,0],[-192.7,0,0],[-86.8,0,0],[-78.7,0,0],[-80.6156,5.62813,0],[-81.1,19.5125,0],[-81.1,29.9813,0],[-81.4937,37.2266,0],[-83.9484,42.5812,0],[-89.4258,46.1008,0],[-99.1094,47.5,0],[-109.671,45.8602,0],[-116.638,41.1813,0],[-120.1,33.2,0],[-112.4,32.2,0],[-108.454,39.0617,0],[-100.187,41,0],[-91.1484,38.3328,0],[-88.9,31.5547,0],[-88.9437,29.5,0],[-103.086,26.7906,0],[-110.134,25.6109,0],[-115.839,23.0328,0],[-119.936,18.5102,0],[-121.5,12.2844,0],[-117.36,2.73594,0],[-105.514,-1,0],[-96.7719,0.535156,0],[-88.4,5.8,0],[-88.9437,20.4312,0],[-90.225,12.6078,0],[-95.4805,7.1875,0],[-103.65,5.2,0],[-110.693,7.28828,0],[-113.1,12.5094,0],[-112.003,16.2297,0],[-108.888,18.775,0],[-102,20.3406,0],[-89.1,23.3,0],[-55.1922,6.7,0],[-57.9102,7.27031,0],[-59.2805,8.80625,0],[-59.7,13.15,0],[-59.7,40.4,0],[-51.7,40.4,0],[-51.7,46.5,0],[-59.7,46.5,0],[-59.7,62.7125,0],[-67.6,57.9938,0],[-67.6,46.5,0],[-73.4,46.5,0],[-73.4,40.4,0],[-67.6,40.4,0],[-67.6,13.6359,0],[-66.6367,4.32813,0],[-63.3094,0.757813,0],[-56.6547,-0.6,0],[-50.7,0.0953125,0],[-51.7,7.04375,0],[-30.2922,6.7,0],[-33.0102,7.27031,0],[-34.3805,8.80625,0],[-34.8,13.15,0],[-34.8,40.4,0],[-26.8,40.4,0],[-26.8,46.5,0],[-34.8,46.5,0],[-34.8,62.7125,0],[-42.7,57.9938,0],[-42.7,46.5,0],[-48.5,46.5,0],[-48.5,40.4,0],[-42.7,40.4,0],[-42.7,13.6359,0],[-41.7367,4.32813,0],[-38.4094,0.757813,0],[-31.7547,-0.6,0],[-25.8,0.0953125,0],[-26.8,7.04375,0],[7.75233,7.76641,0],[0.353119,5.5,0],[-9.36563,9.54453,0],[-13.7,21.2,0],[20.9562,21.2,0],[21,23.3,0],[15.0984,41.1547,0],[-0.115631,47.5,0],[-15.7672,41.0336,0],[-21.8,22.8563,0],[-15.8328,5.27031,0],[0.321869,-1,0],[13.6117,2.93594,0],[20.7375,14,0],[12.6125,15,0],[-9.20001,37.3805,0],[-0.0593872,41,0],[9.71875,36.4656,0],[12.7,27.7,0],[-13.3,27.7,0],[39.5,0,0],[39.5,54.6,0],[58.0688,0,0],[65.7031,0,0],[84.4,53.7,0],[84.4,0,0],[92.6,0,0],[92.6,64.1,0],[81.1391,64.1,0],[65.7656,19.525,0],[62.35,9.25469,0],[59.2703,18.7391,0],[44.0047,64.1,0],[31.3,64.1,0],[31.3,0,0],[137.2,0,0],[145.3,0,0],[143.384,5.62813,0],[142.9,19.5125,0],[142.9,29.9813,0],[142.506,37.2266,0],[140.052,42.5812,0],[134.574,46.1008,0],[124.891,47.5,0],[114.329,45.8602,0],[107.362,41.1813,0],[103.9,33.2,0],[111.6,32.2,0],[115.546,39.0617,0],[123.813,41,0],[132.852,38.3328,0],[135.1,31.5547,0],[135.056,29.5,0],[120.914,26.7906,0],[113.866,25.6109,0],[108.161,23.0328,0],[104.064,18.5102,0],[102.5,12.2844,0],[106.64,2.73594,0],[118.486,-1,0],[127.228,0.535156,0],[135.6,5.8,0],[135.056,20.4312,0],[133.775,12.6078,0],[128.52,7.1875,0],[120.35,5.2,0],[113.307,7.28828,0],[110.9,12.5094,0],[111.997,16.2297,0],[115.112,18.775,0],[122,20.3406,0],[134.9,23.3,0],[162.9,0,0],[162.9,25.3828,0],[166.535,37.5055,0],[175.178,40.7,0],[180.642,39.2773,0],[183.886,35.4703,0],[184.8,28.2719,0],[184.8,0,0],[192.7,0,0],[192.7,28.5609,0],[192.264,36.2156,0],[189.82,42.0328,0],[184.559,45.9914,0],[176.855,47.5,0],[162.1,39.9016,0],[162.1,46.5,0],[155,46.5,0],[155,0,0])
			tnFaces = #([14,15,1],[14,1,2],[13,14,2],[12,13,2],[12,2,3],[11,12,3],[11,3,4],[11,4,5],[10,11,5],[9,10,5],[8,9,5],[7,8,5],[7,5,6],[42,16,43],[42,43,44],[42,44,45],[41,42,45],[41,45,46],[40,41,46],[16,17,18],[43,16,18],[43,18,19],[26,27,28],[26,28,29],[25,26,29],[43,19,20],[52,43,20],[25,29,30],[24,25,30],[39,40,46],[39,46,47],[38,39,47],[38,47,48],[37,38,48],[37,48,49],[36,37,49],[36,49,50],[35,36,50],[35,50,51],[34,35,51],[34,51,52],[33,34,52],[33,52,20],[32,33,20],[32,20,21],[31,32,21],[31,21,22],[31,22,23],[31,23,24],[30,31,24],[60,61,62],[60,62,63],[70,71,72],[70,72,53],[69,70,53],[69,53,54],[68,69,54],[68,54,55],[67,68,55],[67,55,56],[67,56,57],[66,67,57],[64,65,66],[63,64,66],[60,63,66],[60,66,57],[59,60,57],[59,57,58],[80,81,82],[80,82,83],[90,91,92],[90,92,73],[89,90,73],[89,73,74],[88,89,74],[88,74,75],[87,88,75],[87,75,76],[87,76,77],[86,87,77],[84,85,86],[83,84,86],[80,83,86],[80,86,77],[79,80,77],[79,77,78],[96,111,112],[111,96,97],[111,97,98],[111,98,99],[110,111,99],[110,99,100],[109,110,100],[105,106,107],[105,107,93],[104,105,93],[104,93,94],[109,100,101],[108,109,101],[103,104,94],[103,94,95],[102,103,95],[102,95,96],[108,101,102],[112,108,102],[112,102,96],[126,127,113],[126,113,114],[125,126,114],[124,125,114],[124,114,115],[123,124,115],[123,115,116],[123,116,117],[122,123,117],[121,122,117],[120,121,117],[119,120,117],[119,117,118],[154,128,155],[154,155,156],[154,156,157],[153,154,157],[153,157,158],[152,153,158],[128,129,130],[155,128,130],[155,130,131],[138,139,140],[138,140,141],[137,138,141],[155,131,132],[164,155,132],[137,141,142],[136,137,142],[151,152,158],[151,158,159],[150,151,159],[150,159,160],[149,150,160],[149,160,161],[148,149,161],[148,161,162],[147,148,162],[147,162,163],[146,147,163],[146,163,164],[145,146,164],[145,164,132],[144,145,132],[144,132,133],[143,144,133],[143,133,134],[143,134,135],[143,135,136],[142,143,136],[181,182,165],[181,165,166],[179,180,181],[179,181,166],[179,166,167],[178,179,167],[178,167,168],[172,173,174],[171,172,174],[171,174,175],[170,171,175],[170,175,176],[169,170,176],[169,176,177],[169,177,178],[169,178,168])
			setNumVerts tnMesh tnVerts.count
			for i = 1 to tnVerts.count do ( setVert tnMesh i tnVerts[i] )
			setNumFaces tnMesh tnFaces.count
			for i = 1 to tnFaces.count do (
				setFace tnMesh i tnFaces[i]
			)
			local openEdges = meshOp.getOpenEdges tnMesh.mesh
			for i = 1 to tnFaces.count do (
				for j = 1 to 3 do (
					if (openEdges[((i-1)*3)+j]) then (
						setEdgeVis tnMesh i j true
					)
				)
			)

		)
		tnMesh.mesh
	)
	tool create (
		on mousePoint click do (
			nodeTM.translation = gridPoint
			#stop
		)
	)
) -- plugin

Edit: Made the mesh appear a little nicer by only having the open edges set visible.

 PEN

You can just use this if you want.

http://www.paulneale.com/scripts/penHelpers/penHelper.htm

Or you can have a look at the code and how I did it. I have three others that I will release soon that are all based on simpleObject instead of helper because of the speed hit with helpers.

Ahhh. The old ( createInstance Plane).mesh trick… It wouldn’t let me “createInstance mesh” and I tried ( creatInstance Box ) and took the mesh from that, but didn’t appear to work, but shoud have from your example… obviously I did something else wrong… I had a visible edge loop, but didn’t think it was important to post in the example.

Thanks again ZeBoxx… Two answers in one morning… I definitely owe you…

Pen: You’ve noticed a speed difference between the helper and simpleObject? They both mesh init the same way right? Are simpleObjects collapsable? I’m using a CA, with a weak node reference, on a emptyMod on top of this Helper. So I don’t want the user to be able to collapse it and loose the modifier. I guess I should adapt the CA to just be in the helper itself.

Thanks guys!

1 Reply
(@zeboxx2)
Joined: 11 months ago

Posts: 0

Not pen, here, but I know I have; shied away from scripted helpers real quick-like for one of our scripts. Unfortunately I think I’ll have to use a scripted helper (I’ll just leave the icon as original so as not to get the speed hit) for another script as I don’t want the darn things ending up in renders (setting the simpleObject’s ‘renderable’ property works, but the next time somebody includes it in a layer and then resets that layer’s properties… erk.)

Yes

“Interface: custAttribCollapseManager” might be of use there (not sure, as it’s on the modifier), although…

…absolutely

Edit: errr, or in this case, on the simpleObject, of course

 PEN

Helpers are about 100 times slower then mesh objects, they are not handled in the same way. simpleObject is cached, helpers are constrantly rebuilt. This goes for point helpers as well. Do a test with 1000 point helpers in the viewport then 1000 boxes.

Wow…tested that… 100 times slower is a generous estimate (10,000 of the above helper makes your scene impossible to rotate! ) I don’t see a scene having more than a few of these helpers, but every little bit helps… I think the best move is to move all my code into a simpleGeometry plugin…

Thanks Again…

Okay, I have it all working in a SimpleObject, but I collapse it and the UI goes away and I have an editible mesh with the parameters still intact, but no UI… Is there a way I can flag this object to be non-collapsible? Or am I back to making it a helper object?

Thanks

are you talking about losing the parameters/rollout of the scripted simpleObject (makes sense, as collapsing it no longer leaves it as such a plugin), or of the custom attributes?

The CA seems to stay intact here (3ds Max 2009×32) …


plugin simpleObject test 
name:"Test" 
classID:#(0xdeadbeef,0xbaadf00d)
invisible:false
version:1
category:"Test" (
	tool create (
		on mousePoint click do (
			case click of (
				1: (nodeTM.translation = gridPoint; #stop)
			)
		)
	)

	on buildMesh do (
		mesh = (createInstance Plane).mesh
	)
)
myObj = test()

test_ca = attributes test_ca version:1 attribid:#(0xdeadbeef,0xbaadf00d) (
	rollout test_ca_roll "Test" width:168 height:328 (
		label lbl_test "test"
	)

	parameters params rollout:test_ca_roll (
		str type:#string default:"test" ui:lbl_test
	)
)
custAttributes.add myObj test_ca
myObj.str
collapseStack myObj
myObj.str

Yeah, but all the editable properties come up on top of the CA… Could be confusing to the user if it get’s collapsed and looks different than when it was made… I think I’ll reduce my Icon and go with it being a helper class object, I wouldn’t see there being more than a handful of these in a given file…

Thanks

true, true… could also put a little groupbox at the top with a single label “do not collapse me!”

Page 1 / 2