// ===================================================================== // (5.1.1) create simple line objects to be displayed in coarse level // ===================================================================== public void addLineObjects() { // // define a simple L-shape detail line object // // 0 // + h = height // | (we also want to draw a vertical line here at point 1) // d | // +-----+ // 1 2 // w // // sizes double w = mmToFeet(600.0); // modified to match reference plane. otherwise, alignment won't work. double d = mmToFeet(600.0); double h = mmToFeet(4000.0); // distance between Lower and Upper Ref Level. double t = mmToFeet(50.0); // slight offset for visbility // define vertices // XYZ[] pts = new XYZ[] { new XYZ((-w / 2.0) + t, d / 2.0, 0.0), new XYZ((-w / 2.0) + t, (-d / 2.0) + t, 0.0), new XYZ(w / 2.0, (-d / 2.0) + t, 0.0) }; XYZ ptH = new XYZ((-w / 2.0) + t, (-d / 2.0) + t, h); // this is for vertical line. // // (2) create a sketch plane // // we need to know the template. If you look at the template (Metric Column.rft) and "Front" view, // you will see "Reference Plane" at "Lower Ref. Level". We are going to create a sketch plane there. // findElement() is a helper function that find an element of the given type and name. see below. // Note: we did the same in creating a profile. // ReferencePlane pRefPlane = findElement(typeof(ReferencePlane), "Reference Plane") as ReferencePlane; //SketchPlane pSketchPlane = _doc.FamilyCreate.NewSketchPlane(pRefPlane.Plane); // Revit 2013 //SketchPlane pSketchPlane = SketchPlane.Create(_doc, pRefPlane.Plane); // Revit 2014 SketchPlane pSketchPlane = SketchPlane.Create(_doc, pRefPlane.GetPlane()); // Revit 2016 // for vertical line, we draw a straight vertical line at the point[1] XYZ normal = new XYZ(1.0, 0.0, 0.0); //Plane pGeomPlaneH = _app.Create.NewPlane( normal, pts[1] ); // Revit 2016 Plane pGeomPlaneH = Plane.CreateByNormalAndOrigin(normal, pts[1]); // Revit 2017 //SketchPlane pSketchPlaneH = _doc.FamilyCreate.NewSketchPlane(pGeomPlaneH); // Revit 2013 SketchPlane pSketchPlaneH = SketchPlane.Create(_doc, pGeomPlaneH); // Revit 2014 // (3) create line objects: two symbolic curves on a plan and one model curve representing a column like a vertical stick. // // Revit 2013 //Line geomLine1 = _app.Create.NewLine(pts[0], pts[1], true); //Line geomLine2 = _app.Create.NewLine(pts[1], pts[2], true); //Line geomLineH = _app.Create.NewLine(pts[1], ptH, true); // Revit 2014 Line geomLine1 = Line.CreateBound(pts[0], pts[1]); Line geomLine2 = Line.CreateBound(pts[1], pts[2]); //Line geomLineH = _app.Create.NewLine(pts[1], ptH, true); // Revit 2013 Line geomLineH = Line.CreateBound(pts[1], ptH); SymbolicCurve pLine1 = _doc.FamilyCreate.NewSymbolicCurve(geomLine1, pSketchPlane); SymbolicCurve pLine2 = _doc.FamilyCreate.NewSymbolicCurve(geomLine2, pSketchPlane); ModelCurve pLineH = _doc.FamilyCreate.NewModelCurve(geomLineH, pSketchPlaneH); // this is vertical line // set the visibilities of two lines to coarse only // FamilyElementVisibility pVis = new FamilyElementVisibility(FamilyElementVisibilityType.ViewSpecific); pVis.IsShownInFine = false; pVis.IsShownInMedium = false; pLine1.SetVisibility(pVis); pLine2.SetVisibility(pVis); FamilyElementVisibility pVisH = new FamilyElementVisibility(FamilyElementVisibilityType.Model); pVisH.IsShownInFine = false; pVisH.IsShownInMedium = false; pLineH.SetVisibility(pVisH); }