ICollection <ElementId> GetLineStyles(UIApplication m_rvtApp, Document m_rvtDoc) { Transaction tr = new Transaction(m_rvtDoc, "Get Line Styles"); tr.Start(); // Create a detail line View view = m_rvtDoc.ActiveView; XYZ pt1 = XYZ.Zero; XYZ pt2 = new XYZ(10.0, 0.0, 0.0); XYZ[] pts = new XYZ[] { pt1, pt2, }; List <Curve> profile = new List <Curve>(pts.Length); // 2013 for (int ii = 0; ii <= pts.Length - 2; ii++) { profile.Add(Line.CreateBound(pts[ii], pts[ii + 1])); } DetailCurve dc = m_rvtDoc.Create.NewDetailCurve(view, profile[0]); ICollection <ElementId> lineStyles = dc.GetLineStyleIds(); tr.RollBack(); return(lineStyles); }
/// <summary> /// 获取所有线性类别 方法一:通过创建实体线事务,通过事务回滚方式,获取 /// </summary> /// <param name="doc"></param> /// <returns></returns> public static ICollection <ElementId> GetAllLineStyleIdsFromTransaction(Document doc) { ICollection <ElementId> styles = new List <ElementId>(); Transaction transaction = new Transaction(doc); transaction.Start("Create detail line"); try { View view = doc.ActiveView; DetailCurve detailCurve = doc.Create.NewDetailCurve(view, Line.CreateBound(new XYZ(0, 0, 0), new XYZ(10, 0, 0))); styles = detailCurve.GetLineStyleIds(); transaction.RollBack(); } catch (Exception ex) { transaction.RollBack(); } return(styles); }
private void Stream( ArrayList data, DetailCurve detCurve ) { data.Add( new Snoop.Data.ClassSeparator( typeof( DetailCurve ) ) ); data.Add( new Snoop.Data.Object( "Geometry curve", detCurve.GeometryCurve ) ); data.Add( new Snoop.Data.Object( "Sketch plane", detCurve.SketchPlane ) ); data.Add( new Snoop.Data.ElementId( "Line style", detCurve.LineStyle.Id, m_app.ActiveUIDocument.Document ) ); data.Add( new Snoop.Data.Enumerable( "Line styles", detCurve.GetLineStyleIds(), m_app.ActiveUIDocument.Document ) ); DetailArc detArc = detCurve as DetailArc; if( detArc != null ) { Stream( data, detArc ); return; } DetailEllipse detEllipse = detCurve as DetailEllipse; if( detEllipse != null ) { Stream( data, detEllipse ); return; } DetailLine detLine = detCurve as DetailLine; if( detLine != null ) { Stream( data, detLine ); return; } DetailNurbSpline detSpline = detCurve as DetailNurbSpline; if( detSpline != null ) { Stream( data, detSpline ); return; } }