Notifications
Clear all

[Closed] Pickbutton obj as simplemod parameter?

Hey all,

I’ve got a simplemod thats going to have a pickbutton that lets you select a scripted point helper that is used to define the pivot point of a transform.

Pickbutton works properly sorta…The problem I’m having is assigning the .obj property of the pickbutton or the selected object or any of its properties to a parameter of the simplemod that can be read from outside of the simplemod.

As a matter of fact, as soon as you deselect the simplemod, the pickbutton forgets its selection.

I’ve seen some code samples via searching that define a global variable to store the selected obj in…but considering I could have multiple instances of this simplemod, with different pivots, that doesnt’ sound like it would serve me very well.

I’ve tried to take the obj and assign it to a parameter, and I’ve tried to take just the pivot or pos of the obj and assign it to a parameter, but to no avail…any ideas?


plugin SimpleMod XPlaneObj8AnimRotate
name:"X-Plane Anim Rotation" 
classID:#(0x1302dc8, 0x11eccb0)  
version:1
(
	parameters main rollout:XPlaneObj8AnimRotateParams
	(
		PivotPoint	type:#point3
		simDataRef	type:#string	ui:txtDataRef	default:"sim/"
		XRot	type:#float	ui:spnXRot
		YRot	type:#float	ui:spnYRot
		ZRot	type:#float	ui:spnZRot
		CCWAngle	type:#float	ui:spnCCWAngle
		CWAngle	type:#float	ui:spnCWAngle
		SimMin	type:#float	ui:spnSimMin
		SimMax	type:#float	ui:spnSimMax
	)
	rollout XPlaneObj8AnimRotateInfo "X-Plane Anim Rotation" width:162 height:319
	(
	label lab1 "This mesh will be"
	label lab2 "designated as"
	label lab3 "ANIM_Rotate"
	)
	rollout XPlaneObj8AnimRotateParams "Rotation Parameters" width:162 height:319
	(
	pickbutton choosepivot "Select Pivot Point" width:120 filter:pivot_filter	autoDisplay:true
	edittext txtDataRef "Sim DataRef: " fieldwidth:135 labelOnTop:true
	spinner spnXRot "X Rotation: " range:[0,1,1] scale:0.1 fieldwidth:50
	spinner spnYRot "Y Rotation: " range:[0,1,1] scale:0.1 fieldwidth:50
	spinner spnZRot "Z Rotation: " range:[0,1,1] scale:0.1 fieldwidth:50
	spinner spnCCWAngle "CCW Angle: " range:[-360,360,0] scale:0.1 fieldwidth:50
	spinner spnCWAngle "CW Angle: " range:[-360,360,0] scale:0.1 fieldwidth:50
	spinner spnSimMin "DataRef Min: " range:[-9999,9999,0] scale:0.1 fieldwidth:50
	spinner spnSimMax "DataRef Max: " range:[-9999,9999,0] scale:0.1 fieldwidth:50
	on choosepivot picked obj do
		(
			PivotPoint = obj.pivot
		)
	)
	on map i p do
	(
		-- We do nothing here
	)
)

3 Replies

In addition (or instead of) storing a Point3 parameter with the pivot, you should associate the pickbutton with a #NODE type parameter to store the picked object with the plugin.
.obj is NOT a property of the pickbutton, it is the argument to the on … picked … do () event handler and is destroyed as soon as the event handler finishes executing.
The actual property that contains the picked object exists and is called .object – it contains the last selection during the current session. BUT this property will NOT be saved with the plugin in the MAX file, while a parameter block track associated with the pickbutton would.

I actually got pretty close there…at one point I had tried the association as a #MAXObject, but to no avail…#NODE was the missing link…I’ll give that a shot. Thanks Bobo.

Worked like a champ…that makes this exporter SOOO much more intuitive. Thanks again.