I get this problem too.
Everyone else seems to be generating geometry for some reason and apparently you can't get references to geometry that isn't in the model yet but I'm trying to draw a dim from one end of an existing wall to the other and it still says that the references of both ends of the wall are null.
Source:
https://forums.autodesk.com/t5/revit-api/getendpointreference-null-from-analytical-curve/td-p/513200...
https://groups.google.com/forum/#!topic/revitpythonshell/s5AUDkYL3P8
There's the Geometry Options parameter if I was getting the wall by geometry and, through vector maths and iteration figuring out which GeometryElement I want to base the dim off of but I'm not doing that because all the examples for that method are from 2011 and use outdated API calls so I'm assuming they're outdated as a whole.
Source:
http://thebuildingcoder.typepad.com/blog/2011/02/dimension-walls-by-iterating-faces.html
https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2015/ENU/Revit-API/files/GUID-...
Instead I'm using HostObjectUtils which seems to be a new addition as of 2012.
var sides = HostObjectUtils.GetSideFaces(wall, ShellLayerType.Exterior);
which can be used to grab specifically the exterior side of a wall which I'm now trying to dim.
Source:
http://adndevblog.typepad.com/aec/2012/07/accessing-the-exterior-face-of-a-wall-programmatically.htm...
I can separate the face into edge loops and the edge loops into edges which I can then GetEndPointReference(); from. At no point in that workflow is a Geometry Options asked for. GetEndPointReference() returns null.
I looked up GetEndPointReference() in the API to find out what causes it to return null and it just says
"Returns: Reference to the point or null reference (Nothing in Visual Basic) if reference cannot be obtained."
It doesn't say why a reference might not be able to be obtained or what to do if it can't be obtained. What does it mean that a reference cannot be obtained? Is it something to do with the active view? The ReadOnly properties of the Element? The presence of the Element in the project?
I can even AsCurve() the edge to a curve and use the variables of a curve to create a new line with Line.CreateBound(); which I can pass into the NewDimension() method without issue. The fact that that works leads me to believe that everything else about the Face object I retrieved is fine. But GetEndPointReference() still returns null.
The fact that you can create Dims along entire walls in just two clicks (three if you include clicked the button to begin with) by just hitting the "Aligned Dimension" button in the "Annotate" tab just adds insult to injury. Can't we have access to the method running behind that? It must be a method that takes some variant of Element or Reference as its first parameter and then an offset value as its second to position the dim relative to the target. I'm trying to build a car and I don't want to have start by reinventing the wheel just because no one will let me have one.
Does anyone know what's going on? I'm in Revit 2015.
Sorry if I'm coming across as rude. I've been trying to find a solution to this problem for three days now and it's wearing me down. I hate that it's so easy in the UI and that none of the examples I've seen actually align with what I'm trying to do. I keep finding "Solutions" and thinking "There has to be a better way."
I just want this: https://knowledge.autodesk.com/support/revit-products/learn-explore/caas/CloudHelp/cloudhelp/2016/EN...
but from the API. I want to be able to press buttons in the Revit UI from the API. You can get references to them. You can change their tool tips and names and display images but you can't press them.