How to zoom a sheet in revit api? - revit-api

I wrote an external command that creates detail views for doors, windows, etc and puts each object in a separate sheet.
Sometimes the new sheets are zoomed-out by default (the yellow circle shows the actual sheet).
I guess it has to do with the witness lines (in the blue circle).
Sheet zoomed out
I tried activating the views and then found their uiView and used the zoom methods but they don't seem to make a difference (possibly because they work in model coordinates and not in sheet outline coordinates).
uv.ZoomToFit();
Manual zoom-to-fit works fine.
Also, the sheet's outline property is correct (not too large).
Any ideas?
Thanks!

You can use the ShowElements method to zoom to an element. That does the same as zoom-to-fit to a specific set of elements. The element may possibly also be the sheet itself.
The Building Coder discusses how that can also be used to Switch View or Document.
Also, look at displaying a text file from a TaskDialog command link.

Related

Object's position moves when selecting multiple in fabric.js

If select one object, there is no problem.
However, if you select two or more objects by dragging, the position of is moved as shown on the screen below.
Why is the value of "top" and "left" changing when you make multiple selections?
After trying n-number of solution I figured out the solution to this problem. It was something related to the zoomed canvas. Now it works fine!

TableWrapData: widgets won't left align properly

My program uses TableWrapLayout with numColumns set to 2. I then have the following code: (background colors are set to show you that the widgets aren't using the blank space).
Label label = toolkit.createLabel(container, "Resource Type":);
label.setLayoutData(new TableWrapData(TableWrapData.LEFT,TableWrapData.MIDDLE));
label.setBackground(DiagramSettings.NODE_BACKGROUND_COLOR);
resourceComboMenu = new Combo(container, SWT.READ_ONLY);
resourceComboMenu.setBackground(DiagramSettings.NODE_BACKGROUND_COLOR);
resourceComboMenu.setLayoutData(new TableWrapData(TableWrapData.LEFT,TableWrapData.MIDDLE));
However as you can see in the picture the combo box refuses to left align properly. But that I mean I want it to start right after the label, not have a bunch of blank space.
One workaround would be to put the row inside it's own Composite just like I do Resource Icon and Geolocation. But I feel like I shouldn't need to since the widgets on this row equals the number of columns set by the layout. I've created this workaround for now but would like to understand this TableWrapData behavior for the future.
Any insight would be helpful, thanks.
I pretty much answered my question in the question. The composite that contains everything in the picture had TableWrapData with columns set to 2. TableWrapData essentially draws a straight, vertical line between each column then makes sure widgets from one column don't cross it.
So to fix this (like I mentioned in my question) you simply make another composite with nested widgets (which in the case would be the resource type label and resourceComboMenu). I just didn't realize that is what you're supposed to do.

Excel print area/formatting issues across different Computers

I programmed a reporting tool in VBA. It does structure some data and then puts together a report. The report only consists of shapes, pictures and charts, i.e. no information is stored in cells.
All elements are either already the report sheet or get positioned by using the .left and .top properties. In the end, the sheet gets exported as a pdf. It is a nice two pager, at least on my computer and a different one I have access to.
However, when a collegue tries to run the code on his computer (exact same Excel version), the output gets distorted. It does not fit on two pages anymore (in height) and some elements (charts and tables inserted as pictures) are not on the exact same positions where they should be.
It looks like the fixed elements that are already on the report sheet are compressed horizontally so that they get to high for the pages (the fit the page width in the output). All the other elements are put where they belong but do not fit the compressed page anymore. I cant show you the real thing, but I made one part of the report unreadable to show it to you. (And I have put red text and arrows to explain the issue)
I dont have access to the computer that produces the flawed output, only to the pdfs it produces.
I have no idea how to solve this problem, as the print area and page properties are defined in the workbook itslef, and should not change. Also .Top and .Left positions should be accurate everywhere.
Maybe somone has experienced something similiar and can give me hint. Thanks.

I wish to apply a background color to ONLY the cells in a specific dataGrid column?

I asked this question on the LiveCode email list. No response, so I figure it must not be possible. I know about editing the template graphic that enables alternating row colors. That doesn't help me.
This lesson is the closest to what I have found, but it only sets the overlay color to empty cells. It also had an unwanted affect, where any data that was present in the grid no longer shows up.
http://lessons.runrev.com/s/lessons/m/datagrid/l/7327-how-do-i-override-the-default-behavior-for-rendering-data-to-a-cell
As a little experiment, since the data became invisible (note that I'm on WinXP), I tried placing an opaque graphic over the column I wish to colorize. I set the ink of the graphic to AddMax or AddOver, and it looked nice, but the text in the cells disappeared. Then I tried setting the ink to AddMin, and it still looks good, but the test shows through!!!!
So, I think this will work fine visually, but how can I pass a double-click through this graphic to the cell underneath (to allow cell editing only within this column)?
Yes, you can do this.
This suggestion comes from Trevor DeVore at http://www.bluemangolearning.com/
Create a custom column template using the property inspector. From there you can edit the behavior of the column to colorize the background color of the field for that column or just edit the field in the template group to change the color.
The background color will only show up in rows that have data, however.

excel exporting to pdf; graph placement offset

I have some trouble with a document when exporting it to pdf with the builtin pdf export function of excel (2010).
I've generated a graph on my worksheet, with some colored cells arround it. Visually it looks good (even if I zoom on it with the ctrl key + mouse wheel). But when exporting, the graph overlap the surrounding cells.
For example, on the image bellow, I take a screenshot of my graph in excel (at top) and in pdf (at bottom). The red part is my graph (I've colored the background of the graph object). The graph have a black border. And just on the top of the graph, I've colored the background of a cell in blue. Normally, the graph must not overlap the blue cell, because I've manually place it bellow (cut the graph, select the cell bellow the blue one, and past the graph to this emplacement).
But we can see that:
the black border overlap the blue cell (in excel and in pdf version; but it's not really my problem; I've understand that the border in excel object is at outside the object; and then overlapp surround objects/cells).
the graph (in red + the border) has not the same place in excel and in pdf, there is a big offset (it's not a resize problem, this offset is present and the left side too). The place of the graph is more on the left and more on the top in pdf version than it can be!
(I'm using this to automatically generate reports; and the result is not visually good)
Is there any way to overcome this problem?
Hmm, I can't replicate your problem, but I've had similar issues exporting Crystal Reports to PDF. Here's 2 suggestions, neither of which is perfect and I couldn't try them first (again, sorry I couldn't replicate the problem):
Add a white row with a very small height between the graph and the cell. It might even be visually more appealing than the 2 objects one on top of the other.
Make your graph's background transparent and hide the border. Maybe add some extra white space at the top of your graph. That way, they'll still overlap, but it won't be as obvious.

Resources