Hi,
I am creating .pdf files from a viewport using RhinoCommon API, but when I call FilePdf().AddPage() the detail CameraLocation (Z component) is different after the call than before. I would expect it to remain similar.
I’ve attached a sample file and script below.
241212_error_detail_cam_location.3dm (1016.2 KB)
#! python3
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
import System
def main():
# get specific layout (pageview)
pageview = None
for view in sc.doc.Views.GetPageViews():
if view.PageName == '993-001_Facade_INT_Back_7-10':
pageview = view
# get detail objects
detail_objects = pageview.GetDetailViews()
# print detail viewport camera position
# only show detail object in specific layer
for detail_object in detail_objects:
if rs.ObjectLayer(detail_object) == 'LAYOUT::L_Template':
print(detail_object.Viewport.CameraLocation)
# export as pdf
filepath = 'C:/users/info/downloads/temp.pdf'
resolution = 300
inch = 25.4
pdf = Rhino.FileIO.FilePdf.Create()
width = pageview.PageWidth / inch
height = pageview.PageHeight / inch
size = System.Drawing.Size(width * resolution, height * resolution)
settings = Rhino.Display.ViewCaptureSettings(pageview, size, resolution)
pdf.AddPage(settings)
pdf.Write(filepath)
# print detail viewport camera position
# only show detail object in specific layer
for detail_object in detail_objects:
if rs.ObjectLayer(detail_object) == 'LAYOUT::L_Template':
print(detail_object.Viewport.CameraLocation)
if __name__ == '__main__':
main()
(I’ve tried to solve this by duplicating the PageView first, this solves the but this adds >1sec per layout to the operation. Exporting large collections of layouts as .pdf results in unacceptable duration)