Data-Shapes - Image

I have a working script where I am creating a page in Notion from Revit.

I was wanting to take a screenshot of my screen to help reference the issue I am logging. I found a screenshot node and there is an image input in Data-Shapes. I haven’t figured out the Python side of it yet, one step at a time.

When I run it I am getting this error though:

[
Value cannot be null.
Parameter name: path
Stack Trace:
at System.IO.Path.GetFullPathInternal(String path)
at System.IO.Path.GetFullPath(String path)
at System.Drawing.IntSecurity.UnsafeGetFullPath(String fileName)
at System.Drawing.IntSecurity.DemandReadFileIO(String fileName)
at System.Drawing.Image.FromFile(String filename, Boolean useEmbeddedColorManagement)
at Microsoft.Scripting.Interpreter.FuncCallInstruction2.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run4[T0,T1,T2,T3,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3) at System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) at Microsoft.Scripting.Interpreter.DynamicInstruction4.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.LightLambda.Run8[T0,T1,T2,T3,T4,T5,T6,T7,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7)
at IronPython.Compiler.PythonCallTargets.OriginalCallTarget7(PythonFunction function, Object arg0, Object arg1, Object arg2, Object arg3, Object arg4, Object arg5, Object arg6)
at Microsoft.Scripting.Interpreter.FuncCallInstruction10.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame) at Microsoft.Scripting.Interpreter.LightLambda.Run10[T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,TRet](T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8, T9 arg9) at System.Dynamic.UpdateDelegates.UpdateAndExecute9[T0,T1,T2,T3,T4,T5,T6,T7,T8,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5, T6 arg6, T7 arg7, T8 arg8) at Microsoft.Scripting.Interpreter.DynamicInstruction10.Run(InterpretedFrame frame)
at Microsoft.Scripting.Interpreter.Interpreter.Run(InterpretedFrame frame)
]

Here is an image of my workspace:

What is the issue here?

Thanks

It’s a bit hard to tell without the python code.
It does look like you are trying to load an image but not with a file path string (or perhaps nothing at all). Check that any backslashes are escaped in paths i.e. "C:\\path\\to\\image.png"

Well as far as I can tell the script isn’t even getting to the Python code at this point. There is an error occurring in the Data-Shapes Multiple UI node. It’s what I pasted in my first post. I know I’ll need to update the Python code, but I need to the info to get there first.

I’m assuming there isn’t an issue with my file path because there isn’t an error on any of those nodes and in the Watch node showing my list it states an ‘UI.Image input’.

Looks like the workspace it’s reference isn’t what I was thinking it was referencing and that is my issue.

Hi,

You need to read your image.
" File path > File.FromPath > Image.ReadFromFile"

@john_pierson

Your the person behind the Rhythm package. I was thinking I could use this node to get a screenshot of whatever is on my Revit Screen. Am I able to do this with this node?

Hi @kslifter that node take a screenshot at the dynamo screen not revit…for revit something here

1 Like

Thanks, I was still having issues with Data-Shapes, but decided to just bypass that.

Now I just need to see how to use the System.Drawing.Bitmap in Python and the Notion API.

1 Like

So it looks like I need a file location to be able to point notion to in order to upload it.
The export image can save it to a file, but I can’t keep overwriting the same file.
Any suggestions?
I did see the copy file and move file nodes. So I was thinking I could copy the since source file and move it. So the the new images would go to the new folder. The little bit of time I spent on it, that didn’t work.

¨no not really…do you mean something here ?

explorer_E1xegRE7Yc

1 Like

Why not generate a unique file name per image? Look into the UUID library in Python for some ideas on how.

1 Like

python tempfile builtin module is handy

import tempfile

def gen_filename(dir="C:\\temp"):
    with tempfile.NamedTemporaryFile(dir=dir, prefix="IMG_", suffix=".png") as f:
        return f.name

OUT = gen_filename()

It should work. It simply screenshots your entire main display (or at least it used to, Dynamo 3 might’ve screwed it up).

Although, you cannot use the output of that node for anything as it is void. You would have to use a passthrough node or something.

1 Like

true yeah you are right :wink: i just thought it was only for dynamo window…offcoarse it gives that screenshot when i have dynamo open hehehe :wink: works great in 24

1 Like

Thanks, this worked great

I had to lean on ChatGPT for the Python to get the image uploaded to Imgur so that I could use the url to give to my script to send it to Notion, but I now am able to create a page from notion.
This creates a list of issues and has reference screenshots now.

Thanks everyone for your help