Files
2024-12-12 09:51:40 +01:00

78 lines
10 KiB
Plaintext

{\rtf1\fbidis\ansi\ansicpg1252\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fswiss\fprq2\fcharset0 Arial;}{\f1\froman\fprq2\fcharset0 Times New Roman;}}
{\colortbl ;\red0\green0\blue255;}
\viewkind4\uc1\pard\ltrpar\nowidctlpar\b\f0\fs20 Application:\b0 RoomSchedule\line\b Revit Platform:\b0 Architecture\line\b Revit Version:\b0 2010.0\line\b First Released For:\b0 2008.2\line\b Last Modified:\b0 01/13/2009\cf1\f1\par
\cf0\b\f0 Modified By:\b0 JJ Autodesk\line\b Programming Language:\b0 C#\line\b Skill Level:\b0 High\line\b Category:\b0 Rooms/Spaces\line\b Type:\b0 ExternalCommand and ExternalApplication\line\line\b Subject:\b0 Room creation and modification; Excel data import and export.\line\b Summary:\b0 \line This sample demonstrates: how to retrieve spread sheet data, how to create rooms without placing them and how to update spreadsheet data with data of rooms mapped to\f1 .\par
\f0\par
\lang1036\b Classes:\b0 \par
\pard\ltrpar\nowidctlpar\fi360 Autodesk.Revit.IExternalCommand\f1\par
\f0 Autodesk.Revit.Document\f1\par
\pard\ltrpar\nowidctlpar\fi180\li180\lang1033\f0 Autodesk.Revit.Elements.Room\par
Autodesk.Revit.Elements.Level\par
Autodesk.Revit.Elements.Phase\par
\pard\ltrpar\nowidctlpar\fi360 Autodesk.Revit.Category\par
\pard\ltrpar\nowidctlpar\fi180\li180 Autodesk.Revit.Parameters.BuildInParameter\f1\par
\f0 Autodesk.Revit.Parameters.Definition\par
Autodesk.Revit.Parameters.DefinitionGroup\f1\par
\f0 Autodesk.Revit.Parameters.InstanceBinding\par
\f1\par
\f0 Autodesk.Revit.ControlledApplication.DocumentSaving\par
Autodesk.Revit.ControlledApplication.DocumentSavingAs\par
Autodesk.Revit.ControlledApplication.DocumentClosed\par
\pard\ltrpar\nowidctlpar\fi360\f1\par
\f0 System.Data.OleDb.OleDbConnection\f1\par
\f0 System.Data.OleDb.OleDbCommand\f1\par
\f0 System.Data.DataTable\par
\pard\ltrpar\nowidctlpar\fi180\li180\f1\par
\pard\ltrpar\nowidctlpar\fi180\f0\par
\pard\ltrpar\nowidctlpar\b Project Files:\b0 \par
Command\f1 .\f0 cs\f1\par
\pard\ltrpar\nowidctlpar\li360\tx720\f0 This file contains the class Command which inherits from IExternalCommand interface and implements the Execute method, this class will pop up Room Schedule form.\f1\par
\pard\ltrpar\nowidctlpar\par
\f0 CtrlApplication.cs\par
\pard\ltrpar\nowidctlpar\li360\tx720 This file contains the class CrtlApplication which implements IExternalApplication interface, this class will subscribe DocumentSaving/SavingAs event in OnStartup method and unregister these events in OnShutdown method.\par
The OnStartup method will subscribe \par
\pard\ltrpar\nowidctlpar\f1\par
\f0 RoomScheduleForm.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\f0 This file contains a Form class which consists of two DataGridView controls and three ComboBox controls. The data from spreadsheet and available rooms, levels and phases will be displayed in these controls\f1 .\f0 \f1\par
\pard\ltrpar\nowidctlpar\par
\f0 RoomsData.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\f0 This file will be used to retrieve available rooms, levels and phases data from current Revit project and generate rooms DataTable data for display in DataGridView control.\f1\par
\pard\ltrpar\nowidctlpar\par
\f0 XlsDBConnector.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\f0 This file will be used to connect to Excel spreadsheet file (.xls), retrieve available tables and generate DataTable data for display in DataGridView control; besides, this class will be used to update spreadsheet data or insert new data to spreadsheet\f1 .\par
\pard\ltrpar\nowidctlpar\par
\f0 EventsReactor.cs\f1\par
\pard\ltrpar\nowidctlpar\li360\f0 This file defines the class EventsReactor which contains three delegates methods for DocumentSaving/SavingAs/Closing events, the delegate methods will implement accordingly update when they are raised.\par
Class EventsReactor also includes methods which implement update for spreadsheet and Revit rooms; when update, related logging information will be dumped to log file(RoomSchedule.log) for your review later.\f1\par
\pard\ltrpar\nowidctlpar\par
\par
\b\f0 Description:\b0 \par
\pard\ltrpar\nowidctlpar\li2 This sample uses OleDb.OleDbConnection, OleDb.OleDbCommand and relevant Revit classes mostly to synchronize spreadsheet based room schedule with Revit rooms. This sample implements two functionalities: import room schedule from spreadsheet and update room area fields in spreadsheet by using data from Revit\f1 .\par
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360\f0 -\tab To deal with .xls file (read, update), use OleDb.OleDbConnection, OleDbCommand, DataTable classes of .NET\f1 .\par
\pard\ltrpar\nowidctlpar\fi-360\li360\f0 -\tab To create rooms in specified phase, use Creation.Document.NewRoom(Phase)\f1 .\par
\f0 -\tab To get specified element you want, use Document.get_Elements(Filter) method.\f1\par
\f0 -\tab To get parameters of room, use Room.get_Parameter(String paramName) method\f1 .\par
\f0 -\tab To get all rooms in each PlanTopology\f1 ,\f0 use PlanTopology.Rooms property.\f1\par
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360\f0 -\tab DocumenSaving/DocumentSavedAs/DocumentClosed of controlled application level subscribed and implements related functionality.\par
-\tab Class DefinitionFile, DefinitionGroup, Definition and InstanceBinding will be used to create shared parameter for rooms.\f1\par
\pard\ltrpar\nowidctlpar\par
\b\f0 Instructions:\cf1\b0 \f1\par
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360\cf0\f0 1.\tab Before running this sample, please make sure the Excel file has a work sheet which must contain \ldblquote ID\rdblquote , \ldblquote Room Area \ldblquote , \ldblquote Room Name\rdblquote , \ldblquote Room Number\rdblquote , \ldblquote Room Comments\rdblquote columns at first row, the ID and Area columns should be number values\f1 ,\f0 the other columns should be text value, and the spreadsheet should be writeable too. Under project folder there is one Excel file named RoomSchedule.xls, you can use this file as example to define your data or import this file directly in below steps. \f1\par
\pard\ltrpar\nowidctlpar\fi-360\li360\f0 2.\tab Run this sample directly, the \ldblquote Room Schedule\rdblquote form will pop up, all the available levels and phases will be listed in ComboBox controls separately.\f1\par
\f0 3.\tab Click \ldblquote Import Excel\f1 ...\f0\rdblquote button will allow you to select one spreadsheet file. This sample will retrieve all available work sheets in this sheet file and list them in ComboBox control. \f1\par
\f0 4.\tab Select the work sheet which defines the rooms, and then all room data in this sheet will be displayed in DataGridView control\f1 .\par
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360\f0 5.\tab Select one phase and click \ldblquote Create Unplaced Rooms\rdblquote will create rooms (without placing them) according to the spread sheet rooms\rquote data (The new unplaced rooms\rquote properties will set by the relevant columns in spreadsheet data)\f1 .\f0 A shared parameter named \ldblquote External Room ID\rdblquote will be added to Room category and the parameter value is mapped to spread sheet rooms\rquote ID\f1 .\f0 Document Save, SaveAs events will be subscribed too after rooms\rquote creation.\f1\par
\f0 6.\tab Check \ldblquote Show All Rooms\rdblquote will display all available rooms (placed and unplaced rooms) in current project; select one level will filter all rooms which are in selected level.\f1\par
\pard\ltrpar\nowidctlpar\fi-360\li360\f0 7.\tab Exit this sample, click the \ldblquote Room\rdblquote in Revit Basic tab, select the created rooms in above steps and place them. Click Save/SaveAs command to save project: After Save dialog this sample will update the \ldblquote Room Area\rdblquote , \ldblquote Room Name\rdblquote , \ldblquote Room Number\rdblquote and \ldblquote Room Comments\rdblquote column data of work sheet by the actual values of mapped and placed room. You can open log file(RoomSchedule.log) to review details of update.\f1\par
\f0 8.\tab If there are new rooms which were created and placed by user manually, these rooms will be added into spreadsheet when save or save as is called, the \ldblquote Room Comments\rdblquote column in spread will be set to \ldblquote <Added from Revit>\rdblquote if the room doesn\rquote t have comments. Besides, the \ldblquote External Room ID\rdblquote parameter of new room will be set to room\rquote s id value after adding.\f1\par
\f0 9.\tab When creating unplaced rooms, the new rooms\rquote name, number and comments properties will be set by the \ldblquote Room Name\rdblquote , \ldblquote Room Number\rdblquote and \ldblquote Room Comments\rdblquote column values in room sheet automatically. \f1\par
\f0 10.\tab If spreadsheet room was already mapped by Revit room, new creation will be skipped (some message will be popped up), because more than one Revit room maps to same one spreadsheet room is not allowed\f1 .\f0 Click \ldblquote Clear External Room ID\rdblquote button will clear the existing maps (all values of shared parameter will to set to null) and allow user to create more unplaced rooms.\f1\par
\pard\ltrpar\nowidctlpar\par
\b\f0 Notes:\cf1\b0 \par
\pard\ltrpar\nowidctlpar\fi-360\li360\tx360\cf0 1.\tab The sample is not supported with 64-bit Revit since there is no 64-bit Jet OLE DB Provider available.\par
\pard\ltrpar\nowidctlpar\fi-360\li360 2.\tab Because of limitations of Excel ISAM driver, if there is both number data and text data in Name, Number or Comments columns in Excel file, please format number data to text type by adding a single quotation in front of data as prefix, text format will make sample\rquote s read and update operations work well. Again, generally the Rooms created manually or by API will have text Name, and the Comments column will be filled with text \ldblquote <null>\rdblquote if Revit room doesn\rquote t have Comments value, so you\rquote d better make sure there is no number data in Name and Comments column. \par
3.\tab The Name and Comments of Room should not contain single quote (\lquote ) because it will conflict with SQL query line. \par
\f1\par
\pard\ltrpar\nowidctlpar\par
}