こちらの続きです。
画面を原寸大にする2 - C#ATIA
時間が無いので、コードだけ。
50mmの四角書いているのだけれども、これで出来ているんじゃないかな?
# Fusion360API Python script import traceback import adsk.fusion import adsk.core def run(context): ui = adsk.core.UserInterface.cast(None) try: app: adsk.core.Application = adsk.core.Application.get() ui = app.userInterface app.documents.add(adsk.core.DocumentTypes.FusionDesignDocumentType) des: adsk.fusion.Design = app.activeProduct root: adsk.fusion.Component = des.rootComponent skt: adsk.fusion.Sketch = root.sketches.add( root.xYConstructionPlane ) skt.sketchCurves.sketchLines.addTwoPointRectangle( adsk.core.Point3D.create(0,0,0), adsk.core.Point3D.create(5,5,0), ) sels: adsk.core.Selections = ui.activeSelections sels.clear() sels.add(skt) app.executeTextCommand(u'Commands.Start SketchActivate') vp: adsk.core.Viewport = app.activeViewport vp.fit() execFullSize() except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc())) def execFullSize(): app: adsk.core.Application = adsk.core.Application.get() ui: adsk.core.UserInterface = app.userInterface def getViewLength(length = 100): app: adsk.core.Application = adsk.core.Application.get() vp: adsk.core.Viewport = app.activeViewport p0 = adsk.core.Point3D.create(0,0,0) p1 = adsk.core.Point3D.create(length*0.1,0,0) m0 = vp.modelToViewSpace(p0) m1= vp.modelToViewSpace(p1) return m0.distanceTo(m1) def dumpmsg(s): adsk.core.Application.get().log(s) print(s) try: vp: adsk.core.Viewport = app.activeViewport pixel2millimeter = 0.26458333333333 dist = getViewLength() dumpmsg(f'ViewSpace Dist {dist}-{dist * pixel2millimeter}') viewLength = dist * pixel2millimeter ratio = (viewLength / 100) ** 2 cam: adsk.core.Camera = vp.camera cam.viewExtents = cam.viewExtents * ratio vp.camera = cam vp.refresh() dist = getViewLength() dumpmsg(f'ViewSpace Dist {dist}-{dist * pixel2millimeter}') dumpmsg('**') except: if ui: ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))