예제 #1
0
        private void Stream(ArrayList data, Autodesk.Revit.DB.StructuralAsset asset)
        {
            data.Add(new Snoop.Data.ClassSeparator(typeof(Autodesk.Revit.DB.StructuralAsset)));

            data.Add(new Snoop.Data.String("Behavior", asset.Behavior.ToString()));
            data.Add(new Snoop.Data.Double("ConcreteBendingReinforcement ", asset.ConcreteBendingReinforcement));
            data.Add(new Snoop.Data.Double("ConcreteCompression ", asset.ConcreteCompression));
            data.Add(new Snoop.Data.Double("ConcreteShearReinforcement ", asset.ConcreteShearReinforcement));
            data.Add(new Snoop.Data.Double("ConcreteShearStrengthReduction ", asset.ConcreteShearStrengthReduction));
            data.Add(new Snoop.Data.Double("DampingRatio ", asset.DampingRatio));
            data.Add(new Snoop.Data.Bool("Lightweight ", asset.Lightweight));
            data.Add(new Snoop.Data.Double("MinimumTensileStrength ", asset.MinimumTensileStrength));
            data.Add(new Snoop.Data.Double("MinimumYieldStress ", asset.MinimumYieldStress));
            data.Add(new Snoop.Data.String("Name ", asset.Name));

            data.Add(new Snoop.Data.Xyz("PoissonRatio ", asset.PoissonRatio));
            data.Add(new Snoop.Data.Xyz("ShearModulus ", asset.ShearModulus));
            data.Add(new Snoop.Data.Double("MetalReductionFactor ", asset.MetalReductionFactor));
            data.Add(new Snoop.Data.Double("MetalResistanceCalculationStrength ", asset.MetalResistanceCalculationStrength));
            data.Add(new Snoop.Data.Double("MinimumYieldStress ", asset.MinimumYieldStress));
            data.Add(new Snoop.Data.String("StructuralAssetClass", asset.StructuralAssetClass.ToString()));
            data.Add(new Snoop.Data.String("SubClass ", asset.SubClass));
            data.Add(new Snoop.Data.Xyz("ThermalExpansionCoefficient ", asset.ThermalExpansionCoefficient));
            //        data.Add(new Snoop.Data.Double("UnitWeight (obsolete)", asset.UnitWeight));
            data.Add(new Snoop.Data.Double("Density ", asset.Density));

            data.Add(new Snoop.Data.Double("WoodBendingStrength ", asset.WoodBendingStrength));
            data.Add(new Snoop.Data.String("WoodGrade ", asset.WoodGrade));
            data.Add(new Snoop.Data.Double("WoodParallelCompressionStrength ", asset.WoodParallelCompressionStrength));
            data.Add(new Snoop.Data.Double("WoodParallelShearStrength ", asset.WoodParallelShearStrength));
            data.Add(new Snoop.Data.Double("WoodPerpendicularCompressionStrength ", asset.WoodPerpendicularCompressionStrength));
            data.Add(new Snoop.Data.Double("WoodPerpendicularShearStrength ", asset.WoodPerpendicularShearStrength));
            data.Add(new Snoop.Data.String("WoodSpecies) ", asset.WoodSpecies));

            data.Add(new Snoop.Data.Xyz("YoungModulus ", asset.YoungModulus));
        }
예제 #2
0
        protected override void TrySolveInstance(IGH_DataAccess DA)
        {
            if (!Parameters.Document.GetDataOrDefault(this, DA, "Document", out var doc))
            {
                return;
            }

            // get required input (name, class)
            string name = default;

            if (!DA.GetData("Name", ref name))
            {
                return;
            }

            DB.StructuralAssetClass assetClass = default;
            if (!DA.GetData("Type", ref assetClass))
            {
                return;
            }

            using (var transaction = NewTransaction(doc))
            {
                try
                {
                    // check naming conflicts with other asset types
                    DB.PropertySetElement psetElement = FindPropertySetElement(doc, name);
                    if (psetElement != null && psetElement.Id != DB.ElementId.InvalidElementId)
                    {
                        if (!MatchesPhysicalAssetType(psetElement))
                        {
                            AddRuntimeMessage(
                                GH_RuntimeMessageLevel.Error,
                                $"Thermal asset with same name exists already. Use a different name for this asset"
                                );
                            return;
                        }
                    }

                    transaction.Start();

                    // delete existing matching psetelement
                    if (psetElement != null && psetElement.Id != DB.ElementId.InvalidElementId)
                    {
                        doc.Delete(psetElement.Id);
                    }

                    // creaet asset from input data
                    var structAsset = new DB.StructuralAsset(name, assetClass);

                    // we need to apply the behaviour here manually
                    // otherwise the resultant DB.PropertySetElement will be missing parameters
                    DB.StructuralBehavior behaviour = default;
                    if (DA.GetData("Behaviour", ref behaviour))
                    {
                        structAsset.Behavior = behaviour;
                    }
                    else
                    {
                        structAsset.Behavior = DB.StructuralBehavior.Isotropic;
                    }

                    // set the asset on psetelement
                    psetElement = DB.PropertySetElement.Create(doc, structAsset);

                    // grab asset data from inputs
                    var assetData = CreateAssetDataFromInputs(DA);
                    UpdatePropertySetElementFromData(psetElement, assetData);

                    // send the new asset to output
                    DA.SetData(
                        ComponentInfo.Name,
                        psetElement
                        );
                }
                catch (Exception ex)
                {
                    transaction.RollBack();
                    AddRuntimeMessage(GH_RuntimeMessageLevel.Error, $"Revit API Error | {ex.Message}");
                }

                transaction.Commit();
            }
        }