Example #1
0
        /// <summary>
        /// Exports a railing to IFC railing
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="railing">
        /// The ceiling element to be exported.
        /// </param>
        /// <param name="geomElement">
        /// The geometry element.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        public static void ExportRailingElement(ExporterIFC exporterIFC, Railing railing, ProductWrapper productWrapper)
        {
            if (railing == null)
            {
                return;
            }

            Options         geomOptions = GeometryUtil.GetIFCExportGeometryOptions();
            GeometryElement geomElement = GeometryUtil.GetOneLevelGeometryElement(railing.get_Geometry(geomOptions), 0);

            // If this is a multistory railing, the geometry will contain all of the levels of railing.  We only want one.
            if (geomElement == null)
            {
                return;
            }

            string            ifcEnumType;
            IFCExportInfoPair exportType = ExporterUtil.GetProductExportType(exporterIFC, railing, out ifcEnumType);

            if (exportType.IsUnKnown)
            {
                ifcEnumType = ExporterUtil.GetIFCTypeFromExportTable(exporterIFC, railing);
            }

            ExportRailing(exporterIFC, railing, geomElement, ifcEnumType, productWrapper);
        }
Example #2
0
        /// <summary>
        /// Exports a railing to IFC railing
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="railing">
        /// The ceiling element to be exported.
        /// </param>
        /// <param name="geomElement">
        /// The geometry element.
        /// </param>
        /// <param name="productWrapper">
        /// The IFCProductWrapper.
        /// </param>
        public static void ExportRailingElement(ExporterIFC exporterIFC, Railing railing, IFCProductWrapper productWrapper)
        {
            if (railing == null)
            {
                return;
            }

            Options         geomOptions = GeometryUtil.GetIFCExportGeometryOptions();
            GeometryElement geomElement = GeometryUtil.GetOneLevelGeometryElement(railing.get_Geometry(geomOptions));

            // If this is a multistory railing, the geometry will contain all of the levels of railing.  We only want one.
            if (geomElement == null)
            {
                return;
            }

            string ifcEnumType = CategoryUtil.GetIFCEnumTypeName(exporterIFC, railing);

            ExportRailing(exporterIFC, railing, geomElement, ifcEnumType, productWrapper);
        }
        /// <summary>
        /// Exports a railing to IFC railing
        /// </summary>
        /// <param name="exporterIFC">
        /// The ExporterIFC object.
        /// </param>
        /// <param name="railing">
        /// The ceiling element to be exported.
        /// </param>
        /// <param name="geomElement">
        /// The geometry element.
        /// </param>
        /// <param name="productWrapper">
        /// The ProductWrapper.
        /// </param>
        public static void ExportRailingElement(ExporterIFC exporterIFC, Railing railing, ProductWrapper productWrapper)
        {
            if (railing == null)
                return;

            Options geomOptions = GeometryUtil.GetIFCExportGeometryOptions();
            GeometryElement geomElement = GeometryUtil.GetOneLevelGeometryElement(railing.get_Geometry(geomOptions));

            // If this is a multistory railing, the geometry will contain all of the levels of railing.  We only want one.
            if (geomElement == null)
                return;

            string ifcEnumType = ExporterUtil.GetIFCTypeFromExportTable(exporterIFC, railing);
            ExportRailing(exporterIFC, railing, geomElement, ifcEnumType, productWrapper);
        }
Example #4
0
        Result IExternalCommand.Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
        {
            // Add an EventLogTraceListener object
            System.Diagnostics.Trace.Listeners.Add(
                new System.Diagnostics.EventLogTraceListener("Application"));

            // Lay the hands on the active document
            UIDocument uidoc = commandData.Application.ActiveUIDocument;
            Document   doc   = uidoc.Document;

            // Set up a timer
            Timing myTimer = new Timing();

            myTimer.StartTime();
            try {
                Reference       r        = uidoc.Selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element);
                Railing         railing  = doc.GetElement(r) as Railing;
                GeometryElement geomElem = railing.get_Geometry(new Options {
                    IncludeNonVisibleObjects = true
                });

                RvtRailing  rvtRailing  = new RvtRailing();
                RailingType railingType =
                    doc.GetElement(railing.get_Parameter(BuiltInParameter.ELEM_FAMILY_PARAM).AsElementId())
                    as RailingType;

                // Extract and sort out the railign's parts
                foreach (GeometryObject geomObj in geomElem)
                {
                    if (geomObj is GeometryInstance)
                    {
                        GetRailingParts((GeometryInstance)geomObj, rvtRailing);
                    }
                }

                #region Tracing
                // Just a check on the number of total solids
                // obtained from the railing
                IList <Solid> allSolids = new List <Solid>();

                // Get all solids from the revit railing element
                GetSolid(railing.get_Geometry(new Options {
                    IncludeNonVisibleObjects = true
                }), allSolids);

                StringBuilder strBld = new StringBuilder();
                for (int i = 0; i < allSolids.Count; ++i)
                {
                    strBld.AppendFormat("s{0}.Volume = {1}\n", i, allSolids[i].Volume);
                }

                System.Diagnostics.Trace.Write(strBld.ToString());
                #endregion

                TaskDialog.Show("Parts", string.Format("Top Rails: {0}; Length = {1:F2}\nRails: {2}; Length = {1:F2}; Area = {6:F2}sq ft\nBalusters: {3}; Length = {4:F2}\nAllSolids: {5}",
                                                       rvtRailing.TopRails.Count,
                                                       UnitUtils.ConvertFromInternalUnits(rvtRailing.TopRailLength, DisplayUnitType.DUT_MILLIMETERS),
                                                       rvtRailing.Rails.Count,
                                                       rvtRailing.Balusters.Count,
                                                       UnitUtils.ConvertFromInternalUnits(rvtRailing.BalusterLength, DisplayUnitType.DUT_MILLIMETERS),
                                                       allSolids.Count,
                                                       rvtRailing.Rails[0].Volume / rvtRailing.TopRailLength));

                return(Result.Succeeded);
            }
            catch (Autodesk.Revit.Exceptions.OperationCanceledException) {
                return(Result.Cancelled);
            }
            catch (Exception ex) {
                TaskDialog.Show("Exception",
                                string.Format("{0}\n{1}", ex.Message, ex.StackTrace));
                System.Diagnostics.Trace.Write(string.Format("{0}\n{1}",
                                                             ex.Message, ex.StackTrace));
                return(Result.Failed);
            }
            finally {
                myTimer.StopTime();
                System.Diagnostics.Trace
                .Write(string.Format("Time elapsed: {0}s",
                                     myTimer.Duration.TotalSeconds));
            }
        }