GetModelScale() asks for 3 arguments but only 2 provided in documentation

When trying to use the GetModelScale() function python asks for 3 arguments but only two are needed in the documentation, what is the third argument that it is asking for?

The same question also stands for the SetModelScale() function, in the python editor it asks for two arguments when in the documentation it only asks for one.

Any help that could be provided would be greatly appreciated.

My code is provided below.

def exportLasernew():
    dpi = 300
    size = System.Drawing.Size(8.5*dpi, 11*dpi)
    scale = Rhino.Display.ViewCaptureSettings.GetModelScale(rs.UnitSystem(2,True,True),
                rs.UnitSystem(8,True,True))
    imscale = Rhino.Display.ViewCaptureSettings.SetModelScaleToValue(scale)
    settings = Rhino.Display.ViewCaptureSettings(sc.doc.Views.ActiveView,size, dpi)
    svgxml = Rhino.Display.ViewCapture.CaptureToSvg(settings)
    filename = rs.SaveFileName()
    svgxml.Save(filename)
    

if __name__ == "__main__":
    exportLasernew()

Hi @Michael_Larbie,

rs.UnitSystem returns an int, not a UnitSystem.

Also, ViewCaptureSettings is a class, not a function. So you need make one.

For example:

import Rhino
import scriptcontext as sc
import System

def test_viewcapture_detail():
    
    view = sc.doc.Views.ActiveView
    if not view: 
        return
    if not isinstance(view, Rhino.Display.RhinoPageView): 
        return
    
    viewport = view.ActiveViewport
    if viewport.ViewportType != Rhino.Display.ViewportType.DetailViewport:
        return
        
    settings = Rhino.Display.ViewCaptureSettings(view, 96)
    settings.Document = sc.doc
    settings.RasterMode = True
    settings.SetViewport(viewport)
    
    bitmap = Rhino.Display.ViewCapture.CaptureToBitmap(settings)
    if bitmap:
        path = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop)
        filename = System.IO.Path.Combine(path, "test_viewcapture_detail.png")
        bitmap.Save(filename, System.Drawing.Imaging.ImageFormat.Png)

if __name__ == "__main__":
    test_viewcapture_detail()

– Dale

Hi @dale thank you for the help!

I was able to make some of the corrections you suggested, but I am having an issue with the SetModelScaleToValue method. When I implement it, the size of the image does not change no matter what I set the scale to, whether it be 1 or 100, what could be the reason for this. Thanks again Michael.

My code is below

def exportLasernew():
    dpi = 300
    size = System.Drawing.Size(8.5*dpi, 11*dpi)
    settings = Rhino.Display.ViewCaptureSettings(sc.doc.Views.ActiveView,size,dpi)
    scale = settings.GetModelScale(Rhino.UnitSystem.Inches,Rhino.UnitSystem.Millimeters)
    settings.SetModelScaleToValue(-scale)
    svgxml = Rhino.Display.ViewCapture.CaptureToSvg(settings)
    filename = rs.SaveFileName()
    svgxml.Save(filename)

if __name__ == "__main__":
    exportLasernew()
    

I believe this is for printing Layout (Page Views). Is this what you are doing?

– Dale