コード例 #1
0
ファイル: EngineData.cs プロジェクト: Jamesbdsas/RevitSDK
        /// <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);
        }
コード例 #2
0
        /// <summary>
        /// Returns a copy of this instance with the specified parameter added.
        /// <para>
        /// If this instance already has a parameter with the query type, it will be replaced.
        ///
        /// </para>
        /// </summary>
        /// <param name="parameter">  the parameter to add </param>
        /// <returns> the new instance based on this with the parameter added </returns>
        public CalculationParameters with(CalculationParameter parameter)
        {
            IDictionary <Type, CalculationParameter> map = new Dictionary <Type, CalculationParameter>(parameters);

            map[parameter.queryType()] = parameter;
            return(of(map));
        }
コード例 #3
0
ファイル: EngineData.cs プロジェクト: Jamesbdsas/RevitSDK
        /// <summary>
        /// Reads calculation parameters from revit data base.
        /// </summary>
        /// <param name="data">Acces to cref="ServiceData".</param>
        /// <returns>User calculation parameters schema object.</returns>
        public Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass ReadCalculationParameter(Autodesk.Revit.DB.CodeChecking.ServiceData data)
        {
            Autodesk.Revit.DB.CodeChecking.Storage.StorageService  service         = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService();
            Autodesk.Revit.DB.CodeChecking.Storage.StorageDocument storageDocument = service.GetStorageDocument(data.Document);
            CalculationParameter calculationParameter = storageDocument.CalculationParamsManager.CalculationParams.GetEntity <CalculationParameter>(data.Document);

            return(calculationParameter);
        }
 private TradeCounterpartyCalculationParameter(Type queryType, IDictionary <StandardId, CalculationParameter> parameters, CalculationParameter defaultParameter)
 {
     JodaBeanUtils.notNull(queryType, "queryType");
     JodaBeanUtils.notNull(parameters, "parameters");
     JodaBeanUtils.notNull(defaultParameter, "defaultParameter");
     this.queryType_Renamed = queryType;
     this.parameters        = ImmutableMap.copyOf(parameters);
     this.defaultParameter  = defaultParameter;
 }
コード例 #5
0
ファイル: EngineData.cs プロジェクト: Jamesbdsas/RevitSDK
        private Tuple <Label, CalculationParameter, BuiltInCategory, Element> GetElementInternalData(Autodesk.Revit.DB.CodeChecking.ServiceData data, ElementId elementId)
        {
            Element              element              = data.Document.GetElement(elementId);
            BuiltInCategory      category             = Autodesk.Revit.DB.CodeChecking.Tools.GetCategoryOfElement(element);
            StorageDocument      storageDocument      = Autodesk.Revit.DB.CodeChecking.Storage.StorageService.GetStorageService().GetStorageDocument(data.Document);
            CalculationParameter calculationParameter = storageDocument.CalculationParamsManager.CalculationParams.GetEntity <CalculationParameter>(data.Document);
            Label ccLabel = storageDocument.LabelsManager.GetLabel(element);

            return(new Tuple <Label, CalculationParameter, BuiltInCategory, Element>(ccLabel, calculationParameter, category, element));
        }
 public override Optional <CalculationParameter> filter(CalculationTarget target, Measure measure)
 {
     if (target is Trade)
     {
         Trade trade = (Trade)target;
         Optional <StandardId> idOpt = trade.Info.Counterparty;
         if (idOpt.Present)
         {
             StandardId           id    = idOpt.get();
             CalculationParameter value = parameters.getOrDefault(id, defaultParameter);
             return(value.filter(target, measure));
         }
     }
     return(defaultParameter.filter(target, measure));
 }
        //-------------------------------------------------------------------------
        /// <summary>
        /// Obtains an instance from the specified parameters.
        /// <para>
        /// The map provides a lookup from the <seealso cref="CalculationTarget"/> implementation type
        /// to the appropriate parameter to use for that target. If a target is requested that
        /// is not in the map, the default parameter is used.
        ///
        /// </para>
        /// </summary>
        /// <param name="parameters">  the parameters, keyed by target type </param>
        /// <param name="defaultParameter">  the default parameter </param>
        /// <returns> the target aware parameter </returns>
        public static TradeCounterpartyCalculationParameter of(IDictionary <StandardId, CalculationParameter> parameters, CalculationParameter defaultParameter)
        {
            ArgChecker.notEmpty(parameters, "values");
            ArgChecker.notNull(defaultParameter, "defaultParameter");
            Type queryType = defaultParameter.queryType();

            foreach (CalculationParameter value in parameters.Values)
            {
                if (value.queryType() != queryType)
                {
                    throw new System.ArgumentException(Messages.format("Map contained a parameter '{}' that did not match the expected query type '{}'", value, queryType.GetType().Name));
                }
            }
            return(new TradeCounterpartyCalculationParameter(queryType, ImmutableMap.copyOf(parameters), defaultParameter));
        }
コード例 #8
0
 public double Div([FromForm] CalculationParameter p)
 {
     return(p.A / p.B);
 }
コード例 #9
0
 public double Mul([FromBody] CalculationParameter p)
 {
     return(p.A * p.B);
 }
コード例 #10
0
        public override Optional <CalculationParameter> filter(CalculationTarget target, Measure measure)
        {
            CalculationParameter value = parameters.getOrDefault(target.GetType(), defaultParameter);

            return(value.filter(target, measure));
        }
コード例 #11
0
 // example: https://5001/api/calculations/div
 // body: HTML <form> element
 public double Div([FromForm] CalculationParameter calculationParameter)
 {
     return(calculationParameter.A / calculationParameter.B);
 }
コード例 #12
0
 // example: https://5001/api/calculations/mul
 // body: raw->json->{"a":100,"b":5}
 public double Sub([FromBody] CalculationParameter calculationParameter)
 {
     return(calculationParameter.A * calculationParameter.B);
 }