line.GetEndPointReference returning NULL

Hi can any one shy me light why im getting NULLS please

I do create line from 2 points in dynamo then do .ToRevitType but cant get end reference see below

Can any one here help me please

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
from Revit.Elements import *

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

dataEnteringNode = IN

doc = DocumentManager.Instance.CurrentDBDocument


line = IN[0].ToRevitType()


refsi = ReferenceArray()
refsi.Append(line.GetEndPointReference(0));
refsi.Append(line.GetEndPointReference(1));





OUT = refsi

You’re calling the wrong method. The method you’re using should be used in Family documents where Revit reference points have been used to construct a curve. Since you are converting a Dynamo curve, the result is a curve defined by XYZs… so try GetEndPoint()

Thanks for your time

If I try your method I get error

referror

line = IN[0].ToRevitType()


refsi = ReferenceArray()
refsi.Append(line.GetEndPoint(0));
refsi.Append(line.GetEndPoint(1));

All I want is to get points for my dimension.

I do have points that I used to construct line how can I convert them to reference for dimension???

Regards

You’ll need to check what the inputs are for the dimension method you intend to call and then work backwards to obtain the references.

Thanks again

According to API

public Dimension NewDimension(
View view,
Line line,
ReferenceArray references
)
Dimension CreateNewDimensionAlongLine(Autodesk.Revit.DB.Document document, Line line)
{
    // Use the Start and End points of our line as the references  
    // Line must come from something in Revit, such as a beam
    ReferenceArray references = new ReferenceArray();
    references.Append(line.GetEndPointReference(0));
    references.Append(line.GetEndPointReference(1));

    // create the new dimension
    Dimension dimension = document.Create.NewDimension(document.ActiveView,
                                                        line, references);
    return dimension;
}

The Revit API comments regarding the References input:

references: An array of geometric references to which the dimension is to be bound. You must supply at least two references, and all references supplied must be parallel to each other and perpendicular to the extension line.

When one dimensions in Revit they pick edges, so that gives a good indication of what geometric references the API is referring to. A good strategy is to test what you intend to do manually first, then find a way of emulating this procedure via the API. Using Revit Lookup is also invaluable and gives the developer lots of clues. Alternatively, you could use the dimension nodes widely available in packages and save yourself the effort!

Thanks again

Say I do have Points and line. How can I convert Points to reference
Regards

You cant as that method us used for obtaining references to Point class objects which can only be created in Family documents. Plus your curve starts its life as a Dynamo curve which is converted to a Revit API Curve, so even if you’re in a Family document, this method still wont work, as the line has no Point references.

Thanks again

So only way i see i can do this is to draw curve line in revit then take points from there.

Not perfect but works

Regards