Message 1 of 4
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello All,
I am creating Detail Line in View, I am getting error "System.NullReferenceException: Object reference not set to an instance of an object" at DetailLine line1 = doc.Create.NewDetailCurve(view, geomLine1) as DetailLine;
Please let me know why this error is coming and what is the solution,
Thanks in advance for your kind support in this regards
Rajesh
ExternalCommandData cdata = commandData; m_app = commandData.Application; m_doc = commandData.Application.ActiveUIDocument.Document; view = m_doc.ActiveView; uiApp = commandData.Application; uiDoc = uiApp.ActiveUIDocument; app = m_app.Application; if (null == m_doc) { message = "There is no active document."; return Autodesk.Revit.UI.Result.Failed; } // Create a few geometry lines. These lines are transaction (not in the model), // therefore they do not need to be created inside a document transaction. XYZ Point1 = XYZ.Zero; XYZ Point2 = new XYZ(10, 0, 0); XYZ Point3 = new XYZ(10, 10, 0); XYZ Point4 = new XYZ(0, 10, 0); Line geomLine1 = Line.CreateBound(Point1, Point2); // This geometry plane is also transaction and does not need a transaction XYZ origin = XYZ.Zero; XYZ normal = new XYZ(0, 0, 1); Plane geomPlane = app.Create.NewPlane(normal, origin); using (Transaction transaction = new Transaction(m_doc)) { if (transaction.Start("Create model curves") == TransactionStatus.Started) { // Create a sketch plane in current document SketchPlane sketch = SketchPlane.Create(m_doc, geomPlane); DetailLine line1 = doc.Create.NewDetailCurve(view, geomLine1) as DetailLine; (ERROR I am getting is System.NullReferenceException: Object reference not set to an instance of an object }
}
Solved! Go to Solution.