Andrew Hazelden wrote:How did you create this macro? Likely there is invalid syntax in the Lua table if you are seeing the results you mentioned and the problem wasn't a file path issue. Often this can be caused by a missing comma, at the end of a line in the macro... which can occur if you edited the file by hand in a text editor like "Notepad" that lacks syntax highlighting.
I right clicked on the node and --> settings --> save as.
Dont think it is a problem with the lua table since I can ctrl+v it in to the comp
Andrew Hazelden wrote:Also, the filepath in your example doesn't have backslashes that are escaped with "\\".
If you aren't using Linux/macOS style slashes then you will likely have to manage escaping the Windows style slashes by hand if you are going to use them. For example to explain where issues can appear with unescaped slashes in a filepath, if you had the letters "n", "r", or "t" as the first digit after the backslash, (without using double slashes), what you typed in will be translated into a C-Code style control character: "\n" = newline, "\r" carriage return, "\t" = tab.
I have never needed to escape backlashes in a raw string path before and as you can see in the workaround below the raw string works fine. Maybe there is a difference between python 2 and 3 or some special need in Resolve. All tho I am new to windows so I will explore this further but double slash did not solve the problems sadly.
Andrew Hazelden wrote:To further help with troubleshooting, do you have an actual standalone media pool Fusion composite open in the Fusion page, or an Edit page timeline clip loaded as the foreground Fusion page comp?
I do not have a clue. I will provide a picture trying to run the code insted
- Capture.PNG (103.58 KiB) Viewed 3944 times
Andrew Hazelden wrote:I tested Resolve v17.4.3 on Windows 10 and had no issue adding an external macro to the foreground Resolve Fusion page composite I created in the Media Pool. The macro had no Loader nodes or MediaIn nodes present in it, and used the Fusion page's 3D system.
Here is the exact Python code I ran:
- Code: Select all
# Stop Loader/Saver node file dialogs from showing
comp.Lock()
# Translate a relative PathMap location into a filepath:
macroFilePath = comp.MapPath(r'C:\\ProgramData\\Blackmagic Design\\DaVinci Resolve\Fusion\\Reactor\\Deploy\\Macros\\3D\\CoopersShape3D.setting')
print('[Macro File] ' + macroFilePath)
# Read the macro file into a variable
macroContents = bmd.readfile(macroFilePath)
print('[Macro Contents]\n' + str(macroContents))
# Add the macro to your foreground comp
comp.Paste(macroContents)
# Resume Loader/Saver node file dialogs from showing
comp.Unlock()
Here is a zipped copy of a macro file I used that you can test.
The attachment CoopersShape3D.zip is no longer available
In the image above I am running this exact code only changing the file path but escaping the slash this time. Dont know any thing about the 3D system and if I remember correctly there are some limitations on 3D in Resolve Free so maybe that is why this fails. All tho a simple text node also fails in the same way.
To me it seems that we have done this in the same way with the exception of the python version. So I guess uninstall python 3 and install v.2 just got on the todo list.
***
I made a workaround with pyperclip, all tho I would like to be able to use the BMD built ins instead. I dont think it will shead any light on the problem but I will post it any way if someone else have the same issue and needs a workaround.
- Code: Select all
import pyperclip
# Absolute filepath to the macro
macroFilePath = r'C:\Users\david\DVR/Text1.setting'
print('[Macro File] ' + macroFilePath)
# Read the macro file into a variable
macroContents = (open(macroFilePath)).read()
# Copy the macro content to the os clipboard
pyperclip.copy(macroContents)
# Print the content of the os clipboard
print('[macro contents]\n', pyperclip.waitForPaste())
# Add the macro to your foreground comp
comp.Paste()
# Empty the clipboard
pyperclip.copy('')
Note: I tried to comment to the best of my ability but being new to DVR I might describe this completely wrong. Also you probably do not want to print the content of the clipboard.
And the result
- Capture2.PNG (165.5 KiB) Viewed 3944 times