Please add a Method or Property to the DrawingDimension object that we can use to get a reference to the DrawingView object that the dimension is associated with. And please add a Method or Property to the DrawingView object that will attempt to get a reference to the DrawingDimension objects that are associated with that view. Right now, the 'Parent' property of a DrawingDimension object returns the Sheet object that the dimension resides on, but does not have any clear or easy way to find out which view it is associated with on that sheet. I don't care if it might sometimes return 'Nothing', but I would prefer if it did not throw an error when trying to use it in situations where no association link(s) could be found. As long as it is there, and will reliably work when it is possible for it to work.
I have seen some people attempt to create their own custom code solutions that attempt to determining this link, and I have been involved with some attempts too. Some of the solutions will work most of the time, but are not as ideal/reliable as we would like, and are not the solution we ultimately want. We want Autodesk to build a robust & reliable solution into Inventor, and its API that we can use in our automation solutions.
Method 1: Some dimensions can actually lead to a reference to the view that they are associated with, when you dig down through their 'Intents' (GeometryIntent objects) that were used to specify what geometry they were supposed to be attached to. But that only works when the GeometryIntent.IntentType is kGeometryIntent. Then the GeometryIntent.Geometry property (returns a generic Object) will usually return a DrawingCurve Type object. Then the DrawingCurve.Parent property will return the DrawingView it is associated with. I like this route best, and use it myself in some situations, due to it leading to a real connection with the desired view. I have also attached one variation of my code for that as a text file. But there are a lot of if's involved in that process though that can break its functionality, and result in no associated view found in a certain percent of cases.
Method 2: Some have attempted to get some physical aspect(s) of the dimension's own geometry, then loop through all the views on the sheet getting a sort of bounding box area on the sheet that the view takes up, then check to see if the dimension's geometry is within the bounds of that view's bounding box area. This works sometimes too, as long as the geometry you get from the dimension is actually within the bounds of a view, and not within the bounds of multiple views whose boundaries may overlap each other. But the dimension line, and its text, can often be positioned outside of the bounds of the view, so it is not always 100% effective.
Method 3: This method uses view suppression, so it dirties the drawing, which is not ideal, but is often effective. With all views and dimensions visible and unsuppressed on the sheet initially, get a collection of all the dimensions available on the sheet. Then suppress one view (or suppress all views except one), then get a collection of all dimensions available on the sheet again. Then compare the two collections. If you suppressed one view, then the dimensions associated with that view will not be included in the second collection. If you suppressed all views but one, then the second collection includes only the dimensions that are associated with the only unsuppressed view.
A method that Autodesk may be able to use in their solution, might be to attach an AttributeSet & Attribute to the dimension and/or view when a dimension is added to geometry (or something) belonging to the view. Then the built-in method could check to see if this DrawingDimension object has a specifically named AttributeSet attached to it containing a specifically named Attribute, with a specific ValueType, then if so retrieve its value to use in whatever Object/Value that the Method or Property returns. I don't really care how the solution is achieved, I'm just throwing some general ideas out there, to help get the ball rolling, so to speak.
Can't find what you're looking for? Ask the community or share your knowledge.