Yesterday I wrote a tool to move a viewportlabel to a point. since those labels don’t align to anything except each other, it is really hard to create any sort of consistency.
so the tool works as follows: you click a point then you click a viewport and the viewportlabel moves to the point, simple.
The tool is written in C# without any dependencies other than the RevitAPI.
I don’t know a lot about github and the approval process that goes with it. if someone could help me that would be great.
I think it is a tool a lot of Revit users could benefit from
In the singlePointSelection method you don’t need a transaction to pick a point… it all boils down to `return uiapp.ActiveUIDocument.Selection.PickPoint();
same with the singleViewportSelection, you’re not modifying the database, so you should’t need to create and commit transactions.
In any case, when there’s an error you should’t commit anything, but Rollback()
initalizing objects to null is not needed, just return the selection directly in the try block and return null inside the catch block
the AllowElement method can be a one liner: return element.Category.Name == "Viewports"
you should be more specific about what exception you are catching, especially in the last catch (the only one that should be there). What if the exception causes an error on the functionality of the command? In that case, you should not silence it and return Result.Succeeded…