I am having issues with checking if certain viewports have their bounds inside a drawing sheet.
My current objective is to have the views with a scale that is a multiple of 50 (like 100, 150, 200, 250, etc…) so that, this way, they can be inside the drawing sheet limits.
I have tried the following method:
Is there a way of implementing something along the lines of what I described?
The full script is too big to take a screenshot so here’s the .dyn file, the .rvt file used and the Excel spreadsheets needed for the 3D model creation: bars.xlsx (57.5 KB) nodes.xlsx (30.1 KB) structureV25.dyn (2.4 MB) Template.rvt (3.3 MB)
Hi @joaofmoco!
I’ve done similar task for decreasing scale of viewport. If we have centers of drawing frame and viewport in one point,
we need iteratelely decrease scale of viewport until upper right corner X coordinate will’be smaller, than upper right corner X of drawing frame. You can try to do it with While loop, or just push the list of your scales (100, 150, 200, 250, etc…) and catch first “true” when we have vieport’s corner inside frame.
We can do all of that just with rectangles, or points, avoiding revit transactions. And apply final scale to viewport once at the end.
I thought about a while loop to be honest. I just didn’t really know where to start because it seems more complex than just a while loop. Thank you for making it clearer
Also, here’s the .rvt file with the created views: Template(with model).rvt (5.4 MB)
Then it proceeds to check if the XY values of the viewport are different than the XY values of the sheet in a way that the viewport is not contained inside of the drawing sheet. If there are false values returned, the script extracts the indices of the viewports in the list.
After this, the viewports that are out of the sheets bounds are saved and the view inside them is scaled down (placeholder value as this is where I wanted the scale value to be iterated - Like with that list with multiples of 50). Then, after the scaling is done, the viewport needs to be recentered.
Hello, I’ve made some changes so that it would run on the script and it’s still producing some errors.
Here’s the part of the script I’ve changed. It’s still producing some errors but it’s better now:
Well, veiwport scaling part is independent. All before doesn’t work for me, but scaling is successful (checked twice!). Maybe we need regenerate before starting scaling (red group in script). structureV27-2.dyn (499.6 KB)
I have figured out a solution to this. I calculated the scale ratios and then checked which ratios were the biggest (X or Y) for each view. Then, I proceeded to create a list with all the needed ratios. After this step, I multiplied it times 100 and rounded up the scale value with multiples of 50. Then, I went and set the scale and set the viewport center.