Rhino.RhinoDoc.ExtractPreviewImage buglet

Hi there,

using below code in R8 produces an error on a saved and opened document if no path is provided to the method:

import scriptcontext
bitmap = scriptcontext.doc.ExtractPreviewImage(path=None)
print bitmap

The help doc for ExtractPreviewImage mentions this:

path
Type: System.String
The model (3DM) from which to extract the preview image. If null, the currently loaded model is used.

It seems, providing null (None in Python) to the method does not work.
_
c.

Hi @clement,

Is this on Mac or Windows (or both)?

– Dale

Hi @dale, i’ve only tried it on Windows yet.

thanks,
c.

Hi @clement,

Thanks, I’ve logged the issue.

https://mcneel.myjetbrains.com/youtrack/issue/RH-80425

– Dale

2 Likes

Thanks @dale,

your example script works if the current document has been is saved before.

import Rhino
import System

bitmap = Rhino.RhinoDoc.ExtractPreviewImage(None)
if bitmap:
    folder = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop)
    path = System.IO.Path.Combine(folder, "test.png");
    bitmap.Save(path)

tested with (8.6.24074.1001, 2024-03-14) (windows)
_
c.