I am trying to create a graph to move hundreds of view references for a match line. I have a project where the match line moved several feet and would like to be able to move the needed view references without manually doing it. I have done some research here on this forum and found several posts about getting the location of tags and moving them however none of this solution seems to work with view references.
I have downloaded and installed the Revit Lookup (snoop) tool from Jeremy at The Building Coder. It appears I can not access any type of coordinate or location information from view refence tags. Can any one confirm this. I am trying to teach myself to dive deeper into Revit API but I still have limited knowledge and experience and I feel like I am chasing something that is not controllable from the API of Revit.
It seems you correctly identified this limitation to get location point for view references.
A workaround can be finding the bounding box of view references and then using the bbox points.
Use a node that can retrieve view-based bounding boxes.
Example below, the last node is from Clockwork custom package; blue points are those retrieved from bbox min and bbox max, and the node returns them as top right and bot left
@habdirad Thank you for your help. It appears that with Revit 2020 and Dynamo 2.1 the node you used has been deprecated. GitHub says to use Element.BoundingBox (default node) but this does give bounding box of the view reference. At least I know that I can get the bounding box of view reference now I have to find a node that will work or dive into python or can anyone else guide me in a direction?
See attached and sample code:
feed a list of view refs to IN and a list of owner views to IN (lists must have the same length)
viewrefbbox.dyn (6.2 KB)
import clr clr.AddReference("RevitNodes") import Revit from Revit.Elements import * clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.Elements) clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager doc = DocumentManager.Instance.CurrentDBDocument clr.AddReference('RevitAPI') clr.AddReference('RevitAPIUI') from Autodesk.Revit.DB import * from Autodesk.Revit.UI import * clr.ImportExtensions(Revit.GeometryConversion) # FEED LISTS INTO IN and IN elements = UnwrapElement(IN) views = UnwrapElement(IN) bbox = [elements[i].BoundingBox[views[i]].ToProtoType() for i in range(len(elements))] OUT = bbox
@habdirad once again thankyou. I can now get the center of the bounding box and I know the distance that the items can move but I am having trouble actually moving the view reference. My initial approach was to use the Element.MovebyVector but no successes. It seems that this should be simple but I am struggling. I am learning a lot so not a complete loss. I also just completed a 4 hour course on Linked trying to learn Python to see if I can piece something together. I am sure that I could have moved the view reference manually by now but it is the matter of principle that I want to see if I can solve this in Dynamo at this point. Again Thanks for your help in at least getting me this far.
You are welcome
I do not know why these view refs are so stubborn, you can try this code to move them (feed lists of viewrefs and vectors to IN and IN respectively)
import clr clr.AddReference('ProtoGeometry') from Autodesk.DesignScript.Geometry import * clr.AddReference("RevitNodes") import Revit from Revit.Elements import * clr.ImportExtensions(Revit.Elements) clr.AddReference('RevitServices') import RevitServices from RevitServices.Persistence import DocumentManager doc = DocumentManager.Instance.CurrentDBDocument clr.AddReference('RevitAPI') from Autodesk.Revit.DB import * clr.ImportExtensions(Revit.GeometryConversion) from RevitServices.Transactions import TransactionManager TransactionManager.Instance.EnsureInTransaction(doc) viewrefs = UnwrapElement(IN) vects = IN translate = [ElementTransformUtils.MoveElement(doc, viewrefs[i].Id, vects[i].ToRevitType()) for i in range(len(viewrefs))] OUT = viewrefs TransactionManager.Instance.TransactionTaskDone()
@habdirad once again thank you for your help with providing the python code. I am having the same trouble with the python code as I did with the move by vector node in that when trying to move the view references Dynamo does not ever complete and just keeps processing until Revit errors and crashes or just becomes unresponsive. I tried just moving a single view reference and could not get it to move. Revit would just become unresponsive
@habdirad I was able to get your code to work in several other projects. The issue is not with your code but something in the project that I was originally trying to test with. Again thank you for your help.
This thread was great! Was curious if you had any suggestions for changing the “Target view” of the viewrefs as well. I am using View Reference Tags and wanting to reference View3D views, which you can do via the UI just can’t figure it out on the API.