Old 08-08-2019, 05:24 AM   #1
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default reaper.GetSubProjectFromSource returns nil

I'm trying to get the subproject name from an item, but it seems to only ever return nil. Is it broken?



Code:
  item =  reaper.GetSelectedMediaItem( 0, 0 )
  take =  reaper.GetActiveTake( item )
  src =   reaper.GetMediaItemTake_Source( take )
  subproject = reaper.GetSubProjectFromSource( src )
  msg(subproject)
Travesty is offline   Reply With Quote
Old 08-08-2019, 05:39 AM   #2
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

I can't get this to work either...


reaper.SelectProjectInstance( proj )
Travesty is offline   Reply With Quote
Old 08-08-2019, 05:47 AM   #3
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 8,062
Default

GetSubProjectFromSource seems to be returning nil, at least with Lua ReaScript, so it's either buggy or it needs to be used in some non-obvious way.

Functions taking in a ReaProject are not going to work if the ReaProject is nil or the functions end up using the currently active project tab.

GetMediaSourceFileName(src, "") does return the file name of the .rpp file, though. (Not sure if that's useful for you.)
__________________
I am no longer part of the REAPER community. Please don't contact me with any REAPER-related issues.
Xenakios is offline   Reply With Quote
Old 08-08-2019, 05:54 AM   #4
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

Yeah I got the project through EnumProjects and tried that in SelectProjectInstance, but that did nothing either. They both seem to be broken.


I'm trying to close a subproject tab after it's been opened, but after getting hold of the project and filename of the open tab, I can't actually find a function to close a project.

The best I have at the moment is SWS: Switch to last project tab, then close current tab. But I don't trust native actions as the script won't always wait for them to complete
Travesty is offline   Reply With Quote
Old 08-08-2019, 07:02 AM   #5
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,874
Default

WHat if you call reaper.GetMediaSourceParent( src ) after the first src = ?


If src type is SECTION, it may not work.
X-Raym is offline   Reply With Quote
Old 08-08-2019, 08:11 AM   #6
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

That could be it actually
Travesty is offline   Reply With Quote
Old 08-08-2019, 08:16 AM   #7
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

No, still always returns nil

Code:
item =  reaper.GetSelectedMediaItem( 0, 0)
take =  reaper.GetMediaItemTake( item, 0 )
src =  reaper.GetMediaItemTake_Source( take )
src = reaper.GetMediaSourceParent( src ) 

proj = reaper.GetSubProjectFromSource( src )

msg(proj)
Travesty is offline   Reply With Quote
Old 08-08-2019, 08:42 AM   #8
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

https://forums.cockos.com/showthread.php?t=195460
mpl is offline   Reply With Quote
Old 08-08-2019, 08:43 AM   #9
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

Oh dear, 2017
Travesty is offline   Reply With Quote
Old 08-08-2019, 08:44 AM   #10
Travesty
Human being with feelings
 
Travesty's Avatar
 
Join Date: Nov 2014
Posts: 798
Default

I don't suppose anyone had any luck with this one?

reaper.SelectProjectInstance( proj )
Travesty is offline   Reply With Quote
Old 08-24-2019, 09:45 AM   #11
mpl
Human being with feelings
 
mpl's Avatar
 
Join Date: Oct 2013
Location: Moscow, Russia
Posts: 3,960
Default

This was fixed in some of latest builds, at least if project tab is opened, it is possible to give project pointer to regular API for stuff like that (the script is pretty rough actually, but it somehow works for simple stuff like drums):

mpl is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 01:37 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.