// // (C) Copyright 2003-2009 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Windows.Forms; using Autodesk.Revit.Elements; using Autodesk.Revit; using Autodesk.Revit.Symbols; using Autodesk.Revit.Geometry; namespace Revit.SDK.Samples.CurtainWallGrid.CS { /// /// the class manages the creation operation for the curtain wall /// public class WallGeometry { #region Fields // the document of this sample MyDocument m_myDocument; // the refferred drawing class for the curtain wall private WallDrawing m_drawing; // the selected ViewPlan used for curtain wall creation Autodesk.Revit.Elements.ViewPlan m_selectedView; // the selected wall type WallType m_selectedWallType; // store the start point of baseline (in PointD format) PointD m_startPointD; //store the start point of baseline (in XYZ format) XYZ m_startXYZ; // store the end point of baseline (in PointD format) PointD m_endPointD; //store the end point of baseline (in XYZ format) XYZ m_endXYZ; #endregion #region Properties /// /// the document of this sample /// public MyDocument MyDocument { get { return m_myDocument; } } /// /// the refferred drawing class for the curtain wall /// public WallDrawing Drawing { get { return m_drawing; } } /// /// the selected ViewPlan used for curtain wall creation /// public Autodesk.Revit.Elements.ViewPlan SelectedView { get { return m_selectedView; } set { m_selectedView = value; } } /// /// the selected wall type /// public WallType SelectedWallType { get { return m_selectedWallType; } set { m_selectedWallType = value; } } /// /// store the start point of baseline (in PointD format) /// public PointD StartPointD { get { return m_startPointD; } set { m_startPointD = value; } } /// /// Get start point of baseline /// public XYZ StartXYZ { get { return m_startXYZ; } set { m_startXYZ = value; } } /// /// store the end point of baseline (in PointD format) /// public PointD EndPointD { get { return m_endPointD; } set { m_endPointD = value; } } /// /// Get end point of baseline /// public XYZ EndXYZ { get { return m_endXYZ; } set { m_endXYZ = value; } } #endregion #region Constructors /// /// default constructor /// /// /// the document of the sample /// public WallGeometry(MyDocument myDoc) { m_myDocument = myDoc; m_drawing = new WallDrawing(this); } #endregion #region Public methods /// /// create the curtain wall to the active document of Revit /// /// /// the created curtain wall /// public Wall CreateCurtainWall() { if (null == m_selectedWallType || null == m_selectedView) { return null; } Autodesk.Revit.Creation.Document createDoc = m_myDocument.ActiveDocument.Create; Autodesk.Revit.Creation.Application createApp = m_myDocument.CommandData.Application.Create; //baseline System.Drawing.Point point0 = m_drawing.WallLine2D.StartPoint; System.Drawing.Point point1 = m_drawing.WallLine2D.EndPoint; //new baseline and transform coordinate on windows UI to Revit UI m_startXYZ = new XYZ(m_startPointD.X, m_startPointD.Y, 0); m_endXYZ = new XYZ(m_endPointD.X, m_endPointD.Y, 0); Autodesk.Revit.Geometry.Line baseline = null; try { baseline = createApp.NewLineBound(m_startXYZ, m_endXYZ); } catch (System.ArgumentException) { MessageBox.Show("The start point and the end point of the line are too close, please re-draw it."); } m_myDocument.ActiveDocument.BeginTransaction(); Wall wall = createDoc.NewWall(baseline, m_selectedWallType, m_selectedView.GenLevel, 20, 0, false, false); m_myDocument.ActiveDocument.ShowElements(wall); m_myDocument.ActiveDocument.EndTransaction(); return wall; } #endregion }// end of class }