hansalbi
(Inflearner)
July 10, 2018, 9:11pm
#1
Hello,
I am using this piece of code for zooming in an object until its border
rs.Command('_-SetZoomExtentsBorder _ParallelView=1 _Enter')
and then exporting it to an image
rs.Command("_-ViewCaptureToFile " + chr(34) + imagePath +chr(34) + " _EnterEnd")
the problem is that it zooms only 2 sides and I would like to zoom all 4 sides of the picture.
How to do that?
Thank you
pascal
(Pascal Golay)
July 10, 2018, 9:14pm
#2
Hello - you’d need to do some more work - set the viewport size to the aspect ratio of the objects in that view. I’ll see if I can figure something out that helps.
-Pascal
pascal
(Pascal Golay)
July 10, 2018, 10:10pm
#4
@hansalbi , something like this:
import rhinoscriptsyntax as rs
def test():
ids = rs.AllObjects()
if not ids: return
bb = rs.BoundingBox(ids, rs.ViewCameraPlane(),False)
bbX = rs.Distance(bb[0], bb[1])
bbY = rs.Distance(bb[0], bb[3])
bbRatio = bbX/bbY
size = rs.ViewSize()
w = size[0]; h = size[1]
if bbX > bbY:
w = size[0]; h = size[0]/bbRatio
elif bbX<bbY:
w = size[1]*bbRatio; h = size[1]
else:
if bbRatio < 1:
w = size[0]*bbRatio; h = size[1]
elif bbRatio > 1:
w = size[0]; h = size[1]*bbRatio
rs.Command("_-ViewportProperties Size " + str(int(w)) +" " + str(int(h)) + " _EnterEnd")
rs.ZoomExtents()
test()
?
-Pascal
hansalbi
(Inflearner)
July 11, 2018, 9:22am
#5
Hello Pascal,
still not working as expected.
I’ve sent a PM to you with the code I’m curretly using.