Announcements

Between mid-October and November, the content on AREA will be relocated to the Autodesk Community M&E Hub and the Autodesk Community Gallery. Learn more HERE.

Track View selected item(focus)

Track View selected item(focus)

Anonymous
Not applicable
530 Views
3 Replies
Message 1 of 4

Track View selected item(focus)

Anonymous
Not applicable

Does anyone know what the correct syntax to get the currently highlighted controller in the track view? (ie box-transform-position-Z position) Thank you

0 Likes
531 Views
3 Replies
Replies (3)
Message 2 of 4

Swordslayer
Advisor
Advisor

This will get you the controller:

 

(
	local currentTV = trackViews.current
	local selCount = currentTV.numSelTracks()
	for i = 1 to selCount collect currentTV.getSelected i
)

 You can get its parent by calling

 

currentTV.getParentOfSelected i

If you only want to get the expression for it, you can also use exprForMAXObject.

0 Likes
Message 3 of 4

Anonymous
Not applicable

Okay, I'm nearly there. I just need to convert the parent type of controller into the form of position/rotation.controller and I'm not sure how to do that

 

--clear the listener
clearListener()

-- put everything in brackets
(
	local currentTrackView = trackViews.current
	if (currentTrackView != undefined) then
	(
		local numOfTracks = currentTrackView.numSelTracks()
		for i = 1 to numOfTracks collect 
		(
			local theParent = currentTrackView.getParentOfSelected i -- controller
			-- Parental check
			if (theParent != undefined) then 
			(
				local theSubnum = currentTrackView.getSelectedSubNum i -- axis number
				
				local theSubanim = getsubAnim theParent theSubnum -- anim type
				
				selectKeys $Box01.position.controller[theSubnum].controller -- works
				selectKeys $Box01.theParent[theSubnum].controller -- doens't work!!!!
			)
		)
	)
	else messageBox ("No trackview open, dude")
)

-- selectKeys $Box01.position.controller[3].controller --Z

 

0 Likes
Message 4 of 4

Swordslayer
Advisor
Advisor

So you are only interested in the position/rotation controllers?

 

(
	fn getPosRotController ctrlTrack currentTV posRotController:false =
	(
		while isController ctrlTrack AND NOT posRotController do
		(
			posRotController = isKindOf ctrlTrack RotationController OR isKindOf ctrlTrack PositionController
			if NOT posRotController do ctrlTrack = currentTV.getParent (currentTV.getIndex ctrlTrack)
		)
		if posRotController then ctrlTrack
	)

	local currentTrackView = trackViews.current
	if (currentTrackView != undefined) then
	(
		local numOfTracks = currentTrackView.numSelTracks()
		local posRotCtrls = for i = 1 to numOfTracks collect
		(
			local posRotCtrl = getPosRotController (currentTrackView.getSelected i) currentTrackView
			if posRotCtrl == undefined then dontCollect else posRotCtrl
		)
		
		-- if you want to select all the keys belonging to pos/rot controllers, this is enough:
		selectKeys posRotCtrls
		-- if you want to work with the resulting array, just filter out the duplicates:
		makeUniqueArray posRotCtrls
	)
	else messageBox ("No trackview open, dude")
)

 

0 Likes