1 / 101

The Rationale of Using Object-Oriented Techniques under BIM

The Rationale of Using Object-Oriented Techniques under BIM. Dr. Chien-Cheng Chou National Central University 11/17 in 2012 力學會議 at 中壢. Outlines. .NET Revit Architecture Document and Application Element Parameter Location Material Conclusions. BIM Current Software Tools.

nuala
Télécharger la présentation

The Rationale of Using Object-Oriented Techniques under BIM

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Rationale of Using Object-Oriented Techniques under BIM Dr. Chien-Cheng Chou National Central University 11/17 in 2012力學會議 at 中壢

  2. Outlines • .NET • Revit Architecture • Document and Application • Element • Parameter • Location • Material • Conclusions

  3. BIM Current Software Tools • Autodesk Revit • Use .NET framework to write programs • Bentley MicroStation • Use .NET framework or VBA environments to write programs • GRAPHISOFT ArchiCAD • Use .NET framework to write programs

  4. Evolution of CAD • 2D CAD • Over its first 20 years, CAD was used to automate hand drafting, the creation of 2D drawings such as plans, sections and elevations. Such drawings consisted of lines and shapes without any intelligence about what the lines and shapes represented. • Parametric CAD: AutoCAD w/ LISP • Parametric models permit the relationship between elements to be seen. When a variable is changed, its effect is seen on related elements. Originally developed for the aerospace and automotive industries for designing complex curved forms, parametric modeling works like a numerical spreadsheet. By storing the relationships between the various elements of the design and treating these relationships like mathematical equations, it allows any element of the model to be changed and automatically regenerates the model in much the same way that a spreadsheet automatically recalculates any numerical changes.

  5. Evolution of CAD • 3D CAD • CAD w/ the z dimension • Object-Oriented CAD (BIM) • The idea behind object-oriented CAD is that rich information about building components could be modeled in a form accessible by a wide variety of software applications and used throughout a building’s life cycle without conversion or translation into other formats. Properties including shape, behavior, performance data, and transport requirements, along with embedded links to relevant code requirements and test results, could all be included in an electronic “object.” When an architect adds a door, it will describe not only the physical attributes of the door needed for design by the CAD program, but also the cost, maintenance, supply and installation properties of the door for use in project costing and scheduling, and later for facilities management.

  6. Challenges of Writing Codes inside BIM • It is object-oriented • It is no longer possible to use traditional methods or simply object-based methods to write programs inside BIM • Why?

  7. 幾種類別與物件的嘗試, 套用BIM觀念 • 類別=窗戶 • 物件=實際窗戶 • 類別=窗戶 • 物件=3*3窗戶(每個尺寸都是窗戶類別的物件) • 類別= 3*3窗戶 • 物件=A廠牌窗戶 • 類別= A廠牌窗戶 • 物件=實際窗戶(有實際位置)

  8. .NET

  9. What is .NET? • A Framework in which to run code • A Common Language Runtime (CLR) • runs all programs • C# compiles to Microsoft Intermediate Language • MSIL runs on CLR • Virtual Machine like Java • code written in many languages compiles to MSIL • A Common Language Specification (CLS) • A Common Type System (CTS)

  10. Web Services Building Blocks (e.g. for Services) Sharepoint ... ... .NET Applications Enterprise Servers Languages: C#, Visual Basic, etc SQL Server BizTalk ... Runtime Common Type System Common Language Runtime Services: .NET and COM+ .NET Framework Operating System What is .NET? From MSDN

  11. Base Class Library Support Thread Support COM Marshaler Type Checker Exception Manager Security Engine Debug Engine MSIL to Native Compilers (JIT) Code Manager Garbage Collector (GC) Class Loader What is the CLR? From MSDN

  12. What is the CTS? • A set of common types • any language that runs in CLR should implement • no syntax specified • Languages often define aliases • For example • CTS defines System.Int32 – 4 byte integer • C# defines int as an alias of System.Int32

  13. What is the CTS? From MSDN

  14. What is the CLS? • A specification of language features • how methods may be called • when constructors are called • subset of the types in CTS are allowed • For example • Code that takes UInt32 in a public method • UInt32 is not in the CLS • Can mark classes as CLS-compliant • not marked is assumed to mean not compliant It is all about abstraction for programming languages.

  15. The Class Libraries • The common classes used in many programs • like Java Class Library • eg. • System.Console.WriteLine • XML, Networking, Filesystem, Crypto, containers • Can inherit from many of these classes • Many languages run on .NET framework • C#, C++, J#, Visual Basic • even have Python (see IronPython)

  16. Assemblies • Code contained in files called “assemblies” • code and metadata • .dll as before • to run: public static void Main(string[] args) • types • private: local directory, not accessible by others • eg. Wolfram .NETLink • shared: well-known location, can be GAC • strong names: use crypto for signatures • then can add some versioning and trust

  17. COM vs .NET • Historically, COM provided this integration • support for interfaces and interaction • given a GUID, lookup the type library • dynamically instantiate class • do RPC to make calls in many cases • Difficult to get right • software engineering problems • not type safe at all

  18. ASP.NET and ADO.NET • Use .NET languages in web pages • thus can write typesafe code • server-side or client-side • Sharepoint interactions • can log in • Use the CLR to access databases • in the manner of ODBC • provides classes for access

  19. Revit Architecture

  20. Revit Platform API • All Revit-based products are Parametric Building Information Modeling (BIM) tools. These tools are similar to Computer-Aided Design (CAD) programs but are used to build 3D models as well as 2D drawings. In Revit, you place real-world elements like columns and walls into the model. Once the model is built, you can create model views such as sections and callouts. Views are generated from the 3D physical model; consequently, changes made in one view automatically propagate through all views. This virtually eliminates the need to update multiple drawings and details when you make changes to the model.

  21. What Can You Do with the Revit Platform API You can use the Revit Platform API to: • Gain access to model graphical data. • Gain access to model parameter data. • Create, edit, and delete model elements like floors, walls, columns, and more. • Create add-ins to automate repetitive tasks. • Integrate applications into Revit-based vertical products. Examples include linking an external relational database to Revit or sending model data to an analysis application. • Perform analysis of all sorts using BIM. • Automatically create project documentation.

  22. Requirements • A working understanding of Revit Architecture 2011, Revit Structure 2011, or Revit MEP 2011. • Familiarity with a Common Language Specification compliant language like C# or VB.NET. (C# is the main focus) • Microsoft .NET Framework 3.5. (Be careful!) • The Revit Software Developer‘s Kit (SDK) • The Revit Platform API is installed with Revit Architecture, Revit Structure, and Revit MEP. Any .NET based application will reference the RevitAPI.dll and the RevitAPIUI.dll located in the Revit Program directory. The RevitAPI.dll contains methods used to access Revit‘s application, documents, elements and parameters at the database level. The RevitAPIUI.dll contains the interfaces related to manipulation and customization of the Revit user interface.

  23. Document / Application / Element

  24. Application and Document The top level objects in the Revit Platform API are application and document. These are represented by the classes Application, UIApplication, Document and UIDocument. • The application object refers to an individual Revit session, providing access to documents, options, and other application-wide data and settings. • Autodesk.Revit.UI.UIApplication - provides access to UI-level interfaces for the application, including the ability to add RibbonPanels to the user interface, and the ability to obtain the active document in the user interface. • Autodesk.Revit.ApplicationServices.Application - provides access to all other application level properties.

  25. Document • The document object is a single Revit project file representing a building model. Revit can have multiple projects open and multiple views for one project. • Autodesk.Revit.UI.UIDocument - provides access to UI-level interfaces for the document, such as the contents of the selection and the ability to prompt the user to make selections and pick points • Autodesk.Revit.DB.Document - provides access to all other document level properties • If multiple documents are open, the active document is the one whose view is active in the Revit session. Need to know how to use Revit’s programming help file

  26. Elements • An Element corresponds to a single building or drawing component, such as a door, a wall, or a dimension. In addition, an Element can be a door type, a view, or a material definition. 6 groups: • Model • Sketch • View • Group • Annotation • Information

  27. 1. Model Elements • Model Elements represent physical items that exist in a building project. • Family Instances - Family Instances contain family instance objects. • Host Elements - Host Elements contain system family objects that can contain other model elements, such as wall, roof, ceiling, and floor. • Structure Elements. - Structure Elements contain elements that are only used in Revit Structure.

  28. 2. View Elements • View Elements represent the way you view and interact with other objects in Revit. • 3. Group Elements • Group Elements represent the assistant Elements such as Array and Group objects in Revit. • 4. Annotation and Datum Elements • Annotation and Datum Elements contain non-physical items that are visible. • 5. Sketch Elements • Sketch Elements represent temporary items used to sketch 2D/3D form. • 6. Information Elements • Information Elements contain non-physical invisible items used to store project and application data.

  29. More classifications of elements • Category • The Element.Category property represents the category or subcategory to which an Element belongs. It is used to identify the Element type. • Family • Families are classes of Elements within a category. • Symbol (ElementType) • Symbols are usually non-visible elements used to define instances. • Instance (Component) • Instances are items with specific locations in the building (model instances) or on a drawing sheet (annotation instances). Instance represents transformed identical copies of an ElementType.

  30. Category Rules: • Each family object belongs to a category • Non-family objects, like materials and views, do not belong to a category • An element and its corresponding symbols are usually in the same category. For example, a basic wall and its wall type Generic – 8" are all in the Walls category • The same type of Elements can be in different categories. For example, SpotDimensions has the SpotDimensionType, but it can belong to two different categories: Spot Elevations and Spot Coordinates • Different Elements can be in the same category because of their similarity or for architectural reasons. ModelLine and DetailLine are in the Lines category

  31. Getting categories from document settings (use HelloWorld Example) Settings documentSettings = revit.Application.ActiveUIDocument.Document.Settings; // Get all categories of current document Categories groups = documentSettings.Categories; // Show the number of all the categories to the user String prompt = "Number of all categories in current Revit document:" + groups.Size; // get Floor category according to OST_Floors and show its name Category floorCategory = groups.get_Item(BuiltInCategory.OST_Floors); prompt += floorCategory.Name; // Give the user some information TaskDialog.Show("Revit", prompt);

  32. Category • Category is used to classify elements. The element category determines certain behaviors. For example, all elements in the same category can be included in the same schedule. • Elements have parameters based on their categories. • Categories are also used for controlling visibility and graphical appearance in Revit.

  33. Get the 1st element selected and show its category Element selectedElement = null; foreach (Element e in revit.Application.ActiveUIDocument.Selection.Elements) { selectedElement = e; break; // just get one selected element } // Get the category instance from the Category property Category category = selectedElement.Category; BuiltInCategoryenumCategory = (BuiltInCategory)category.Id.IntegerValue; TaskDialog.Show("Revit", enumCategory.ToString());

  34. Family • Families are classes of Elements within a category. Families can group Elements by the following: • A common set of parameters (properties). • Identical use. • Similar graphical representation. • Most families are component Family files, meaning that you can load them into your project or create them from Family templates. You determine the property set and the Family graphical representation. • Another family type is the system Family. System Families are not available for loading or creating. Revit predefines the system Family properties and graphical representation; they include walls, dimensions, roofs, floors (or slabs), and levels.

  35. Family API • Families in the Revit Platform API are represented by three objects: • Family • Represents an entire family such as a beam. • Represents the entire family file on a disk. • Contains a number of FamilySymbols. • FamilySymbol • represents a specific set of family settings in the Family such as the Type, Concrete-Rectangular Beam: 16x32. • FamilyInstance • is a FamilySymbol instance representing a single instance in the Revit project. For example, the FamilyInstance can be a single instance of a 16x32 Concrete-Rectangular Beam in the project.

  36. Family Rules • Each FamilyInstance has one FamilySymbol. • Each FamilySymbol belongs to one Family. • Each Family contains one or more FamilySymbols.

  37. ElementType • In the Revit Platform API, Symbols are usually non-visible elements used to define instances. Symbols are called Types in the user interface. • A type can be a specific size in a family, such as a 1730 X 2032 door, or an 8x4x1/2 angle. • A type can be a style, such as default linear or default angular style for dimensions. • Symbols represent Elements that contain shared data for a set of similar elements. In some cases, Symbols represent building components that you can get from a warehouse, such as doors or windows, and can be placed many times in the same building. • FamilySymbol is a symbol in the API. It is also called Family Type in the Revit user interface. FamilySymbol is a class of elements in a family with the exact same values for all properties. For example, all 32x78 six-panel doors belong to one type, while all 24x80 six-panel doors belong to another type. Like a Family, a FamilySymbol is also a template.

  38. Instance • Instances are items with specific locations in the building (model instances) or on a drawing sheet (annotation instances). Instance represents transformed identical copies of an ElementType. For example, if a building contains 20 windows of a particular type, there is one ElementType with 20 Instances. Instances are called Components in the user interface.

  39. Element Properties • ElementId • Every element in an active document has a unique identifier represented by the ElementId storage type. ElementId objects are project wide. It is a unique number that is never changed in the element model, which allows it to be stored externally to retrieve the element when needed. // Get the id of the element Autodesk.Revit.DB.ElementIdselectedId = element.Id; intidInteger = selectedId.IntegerValue; // create a new id and set the value Autodesk.Revit.DB.ElementId id = new Autodesk.Revit.DB.ElementId(idInteger); // Get the element Autodesk.Revit.DB.Element first = document.get_Element(id);

  40. Element.UniqueId • Every element has a UniqueId, represented by the String storage type. The UniqueId corresponds to the ElementId. However, unlike ElementId, UniqueId functions like a GUID (Globally Unique Identifier), which is unique across separate Revit projects. UniqueId can help you to track elements when you export Revit project files to other formats. • The ElementId is only unique in the current project. It is not unique across separate Revit projects. UniqueId is always unique across separate projects.

  41. Element.Location • The location of an object is important in the building modeling process. In Revit, some objects have a point location. For example a table has a point location. Other objects have a line location, representing a location curve or no location at all. A wall is an element that has a line location. • The Revit Platform API provides the Location class and location functionality for most elements. For example, it has the Move() and Rotate() methods to translate and rotate the elements. However, the Location class has no property from which you can get information such as a coordinate. In this situation, downcast the Location object to its subclass—like LocationPoint or LocationCurve—for more detailed location information and control using object derivatives.

  42. Element.Level • Levels are finite horizontal planes that act as a reference for level-hosted or level-based elements, such as roofs, floors, and ceilings. The Revit Platform API provides a Level class to represent level lines in Revit. • A number of elements, such as a column, use a level as a basic reference. When you get the column level, the level you retrieve is the Base Level.

  43. Element.Parameter • Every element has a set of parameters that users can view and edit in Revit. The parameters are visible in the Element Properties dialog box (select any element and click the Properties button next to the type selector).

  44. Parameter

  45. Parameters • Revit provides a general mechanism for giving each element a set of parameters that you can edit. In the Revit UI, parameters are visible in the Element Properties dialog box. • 3 ways • By iterating through the Element.Parameters collection of all parameters for an Element. • By accessing the parameter directly through the overloaded Element.Parameter property. • By accessing a parameter by name via the Element.ParametersMap collection.

  46. Getting selected element parameters // Format the prompt information string String prompt = "Show parameters in selected Element:\n"; // iterate element's parameters UIDocumentuidoc = new UIDocument(revit.Application.ActiveUIDocument.Document); Autodesk.Revit.UI.Selection.Selection choices = uidoc.Selection; Reference hasPickOne = choices.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "Select anyone..."); Element element = hasPickOne.Element; foreach (Parameter para in element.Parameters) { prompt += GetParameterInformation(para, revit.Application.ActiveUIDocument.Document) + "\n"; } // Give the user some information TaskDialog.Show("Revit", prompt);

  47. Getting selected element parameters String GetParameterInformation(Parameter para, Document document) { string defName = para.Definition.Name + " | "; // Use different method to get parameter data according to the storage type switch (para.StorageType) { case StorageType.Double: //covert the number into Metric defName += " : " + para.AsValueString(); break; case StorageType.ElementId: //find out the name of the element ElementId id = para.AsElementId(); if (id.IntegerValue >= 0) defName += " : " + document.get_Element(id).Name; else defName += " : " + id.IntegerValue.ToString(); break; case StorageType.Integer: if (ParameterType.YesNo == para.Definition.ParameterType) if (para.AsInteger() == 0) defName += " : " + "False"; else defName += " : " + "True"; else defName += " : " + para.AsInteger().ToString(); break; case StorageType.String: defName += " : " + para.AsString(); break; default: defName = "Unexposed parameter."; break; } return defName; } In the same class (after return Autodesk.Revit.UI.Result.Succeeded;)

  48. Getting selected element parameters • In Revit, some parameters have values in the drop-down list in the Element Properties dialog box. You can get the numeric values corresponding to the enumerated type for the Parameter using the Revit Platform API, but you cannot get the string representation for the values using the Parameter.AsValueString() method.

  49. Definition • The Definition object describes the data type, name, and other Parameter details. There are two kinds of definition objects derived from this object. • InternalDefinitionrepresents all kinds of definitions existing entirely in the Revit database. • ExternalDefinitionrepresents definitions stored on disk in a shared parameter file. • You should write the code to use the Definition base class so that the code is applicable to both internal and external parameter Definitions.

More Related