Beispiel #1
0
        /// <summary>
        /// Gets ForceCalculationDataDescriptor object for the current structure
        /// </summary>
        /// <param name="data">Service Data</param>
        /// <param name="combinations">List of selected combinations ids </param>
        /// <param name="elementId">Id of Revit element</param>
        /// <returns>Reference to ForceCalculationDataDescriptor</returns>
        protected ForceCalculationDataDescriptor GetForceCalculationDataDescriptor(Autodesk.Revit.DB.CodeChecking.ServiceData data, List <ElementId> combinations, ElementId elementId)
        {
            Tuple <Label, CalculationParameter, BuiltInCategory, Element> intData = GetElementInternalData(data, elementId);
            Label ccLabel = intData.Item1;
            CalculationParameter calculationParameters = intData.Item2;
            BuiltInCategory      category = intData.Item3;
            Element element = intData.Item4;

            List <ForceType> forceTypes = new List <ForceType>();// { ForceType.Fx, ForceType.Fy, ForceType.Fz, ForceType.Mx, ForceType.My, ForceType.Mz };

            forceTypes = GetForceTypes(data, new ElementId[] { elementId });

            ForceCalculationDataDescriptor descriptor = null;

            double elementLength = (element as Autodesk.Revit.DB.Structure.AnalyticalModel).GetCurve().Length;

            elementLength = Autodesk.Revit.DB.UnitUtils.ConvertFromInternalUnits(elementLength, DisplayUnitType.DUT_METERS);
            descriptor    = new ForceCalculationDataDescriptorLinear(elementId, 1.0, calculationParameters.CalculationPointsSelector.GetPointCoordinates(data.Document, true, elementLength, elementId, combinations, forceTypes), true, forceTypes);

            if (descriptor == null)
            {
                descriptor = new ForceCalculationDataDescriptorLinear(elementId);
            }

            if (descriptor == null)
            {
                descriptor = new ForceCalculationDataDescriptor(elementId);
            }

            return(descriptor);
        }
Beispiel #2
0
        /// <summary>
        /// Creates new instance of a user's class with common parameters.
        /// </summary>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <param name="parameters">Instance of base class with common parameters.</param>
        /// <returns>New instance of user implementation of class derived from cref="CommonParametersBase".</returns>
        public CommonParametersBase CreateCommonParameters(Autodesk.Revit.DB.CodeChecking.ServiceData data, CommonParametersBase parameters)
        {
            Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStart(Resources.ResourceManager.GetString("DataPreparation"), 1);

            CommonParameters commonParameters = new CommonParameters(data, parameters);

            List <ForceCalculationDataDescriptor> calculationDataDescriptors = new List <ForceCalculationDataDescriptor>();

            foreach (Tuple <ElementId, ResultStatus> elemStatus in commonParameters.ListElementStatus)
            {
                ForceCalculationDataDescriptor forceCalculationDataDescriptor = GetForceCalculationDataDescriptor(data, parameters.ListCombinationId, elemStatus.Item1);
                ///<structural_toolkit_2015>
                if (forceCalculationDataDescriptor is ForceCalculationDataDescriptorLinear)
                {
                    forceCalculationDataDescriptor.AddBendingForceTypes(new ForceType[] { ForceType.Ux, ForceType.Uy, ForceType.Uz });
                }
                ///</structural_toolkit_2015>
                calculationDataDescriptors.Add(forceCalculationDataDescriptor);
                if (NotificationService.ProgressBreakInvoked())
                {
                    break;
                }
            }

            ForceResultsPackageDescriptor[] vResPackDesc = new ForceResultsPackageDescriptor[] { ForceResultsPackageDescriptor.GetResultPackageDescriptor(data.Document, commonParameters.ActivePackageGuid) };

            // Uncomment the code below to dump to a text file the time spent on accessing ResultsBuilder
            // Int64 forceResultsCacheAccessTime = System.DateTime.Now.Ticks;
            commonParameters.ResultCache = new ForceResultsCache(data.Document, calculationDataDescriptors, vResPackDesc, commonParameters.ListCombinationId, GetInputDataUnitSystem());
            // Uncomment the code below to dump to a text file the time spent on accessing ResultsBuilder
            // forceResultsCacheAccessTime = System.DateTime.Now.Ticks - forceResultsCacheAccessTime;

            foreach (Tuple <ElementId, ResultStatus> elemStatus in commonParameters.ListElementStatus)
            {
                ForceResultsCache.ElementResultsStatus resultStatus = commonParameters.ResultCache.GetElementResultsStatus(elemStatus.Item1);
                if (resultStatus != ForceResultsCache.ElementResultsStatus.ResultsOK)
                {
                    elemStatus.Item2.AddError(Resources.ResourceManager.GetString("ErrStaticResults"));
                }
            }

            // Uncomment the code below to dump to a text file the time spent on accessing ResultsBuilder
            // using (System.IO.StreamWriter writer = new System.IO.StreamWriter(data.Document.PathName + ".RBAccessTimeInfo.txt", true))
            // {
            //    string resultBuilderAccessTime = DateTime.Now.ToString() + " Cache: " + (new System.TimeSpan(forceResultsCacheAccessTime)).TotalSeconds + " RB: " + (new System.TimeSpan(commonParameters.ResultCache.ResultBuilderAccessTime)).TotalSeconds;
            //
            //    writer.WriteLine(resultBuilderAccessTime);
            // }

            Autodesk.Revit.DB.CodeChecking.NotificationService.ProgressStep("");
            return(commonParameters);
        }