How to create a reference line in revit API

How to create a reference line in revit API

Anonymous
Not applicable
2,919 Views
1 Reply
Message 1 of 2

How to create a reference line in revit API

Anonymous
Not applicable

I'm trying to create a reference line (not a reference plane) between two points on a plane. I couldn't find any method except for one method that changes the type of a model curve to a reference line. How can I do that through API?

 

for instance, please assume these two points:

 

XYZ point1 = new XYZ(30, 12, 0);

XYZ point2 = new XYZ(10, 30, 0);

 

Thanks a lot in advance!

0 Likes
Accepted solutions (1)
2,920 Views
1 Reply
Reply (1)
Message 2 of 2

naveen.kumar.t
Autodesk Support
Autodesk Support
Accepted solution

Hi @Anonymous ,

Try using the below code

 Plane P = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, new XYZ(0, 0, 0));
            SketchPlane sp = SketchPlane.Create(doc, P);
            XYZ startPoint;
            XYZ endPoint;
            Line l1 = Line.CreateBound(startPoint,endPoint);
            ModelLine mLine = doc.FamilyCreate.NewModelCurve(l1,sp) as ModelLine;           
            if (mLine!=null)
            {
                mLine.ChangeToReferenceLine();
            }            

Naveen Kumar T
Developer Technical Services
Autodesk Developer Network