Esempio n. 1
0
        private Base BeamToSpeckle(DB.FamilyInstance revitBeam)
        {
            var baseGeometry = LocationToSpeckle(revitBeam);
            var baseLine     = baseGeometry as ICurve;

            if (baseLine == null)
            {
                Report.Log($"Beam has no valid baseline, converting as generic element {revitBeam.Id}");
                return(RevitElementToSpeckle(revitBeam));
            }
            var symbol = Doc.GetElement(revitBeam.GetTypeId()) as FamilySymbol;

            var speckleBeam = new RevitBeam();

            speckleBeam.family      = symbol.FamilyName;
            speckleBeam.type        = Doc.GetElement(revitBeam.GetTypeId()).Name;
            speckleBeam.baseLine    = baseLine;
            speckleBeam.level       = ConvertAndCacheLevel(revitBeam, BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);
            speckleBeam.displayMesh = GetElementMesh(revitBeam);

            GetAllRevitParamsAndIds(speckleBeam, revitBeam);

            //Report.Log($"Converted Beam {revitBeam.Id}");
            return(speckleBeam);
        }
Esempio n. 2
0
        public List <ApplicationPlaceholderObject> AnalyticalStickToNative(Element1D speckleStick)
        {
            List <ApplicationPlaceholderObject> placeholderObjects = new List <ApplicationPlaceholderObject> {
            };
            XYZ offset1 = VectorToNative(speckleStick.end1Offset);
            XYZ offset2 = VectorToNative(speckleStick.end2Offset);
            List <ApplicationPlaceholderObject> placeholders = new List <ApplicationPlaceholderObject> {
            };

            switch (speckleStick.type)
            {
            case ElementType1D.Beam:
                RevitBeam revitBeam = new RevitBeam();
                //This only works for CSIC sections now for sure. Need to test on other sections
                revitBeam.type     = speckleStick.property.name.Replace('X', 'x');
                revitBeam.baseLine = speckleStick.baseLine;
                //Beam beam = new Beam(speckleStick.baseLine);
                placeholders = BeamToNative(revitBeam);
                DB.FamilyInstance    nativeRevitBeam = (DB.FamilyInstance)placeholders[0].NativeObject;
                AnalyticalModelStick analyticalModel = (AnalyticalModelStick)nativeRevitBeam.GetAnalyticalModel();
                analyticalModel.SetReleases(true, Convert.ToBoolean(speckleStick.end1Releases.stiffnessX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end1Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZZ));
                analyticalModel.SetReleases(false, Convert.ToBoolean(speckleStick.end2Releases.stiffnessX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end2Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZZ));
                analyticalModel.SetOffset(AnalyticalElementSelector.StartOrBase, offset1);
                analyticalModel.SetOffset(AnalyticalElementSelector.EndOrTop, offset2);
//analyticalModel.
                return(placeholders);

            case ElementType1D.Brace:
                RevitBrace revitBrace = new RevitBrace();
                revitBrace.type     = speckleStick.property.name.Replace('X', 'x');
                revitBrace.baseLine = speckleStick.baseLine;
                //Brace brace = new Brace(speckleStick.baseLine);
                placeholders = BraceToNative(revitBrace);
                DB.FamilyInstance nativeRevitBrace = (DB.FamilyInstance)placeholders[0].NativeObject;
                analyticalModel = (AnalyticalModelStick)nativeRevitBrace.GetAnalyticalModel();
                analyticalModel.SetReleases(true, Convert.ToBoolean(speckleStick.end1Releases.stiffnessX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end1Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZZ));
                analyticalModel.SetReleases(false, Convert.ToBoolean(speckleStick.end2Releases.stiffnessX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end2Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZZ));
                analyticalModel.SetOffset(AnalyticalElementSelector.StartOrBase, offset1);
                analyticalModel.SetOffset(AnalyticalElementSelector.EndOrTop, offset2);
                return(placeholders);

            case ElementType1D.Column:
                RevitColumn revitColumn = new RevitColumn();
                revitColumn.type     = speckleStick.property.name.Replace('X', 'x');
                revitColumn.baseLine = speckleStick.baseLine;
                placeholders         = ColumnToNative(revitColumn);
                DB.FamilyInstance     nativeRevitColumn  = (DB.FamilyInstance)placeholders[0].NativeObject;
                AnalyticalModelColumn analyticalModelCol = (AnalyticalModelColumn)nativeRevitColumn.GetAnalyticalModel();
                analyticalModelCol.SetReleases(true, Convert.ToBoolean(speckleStick.end1Releases.stiffnessX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end1Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end1Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end1Releases.stiffnessZZ));
                analyticalModelCol.SetReleases(false, Convert.ToBoolean(speckleStick.end2Releases.stiffnessX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZ), Convert.ToBoolean(speckleStick.end2Releases.stiffnessXX), Convert.ToBoolean(speckleStick.end2Releases.stiffnessYY), Convert.ToBoolean(speckleStick.end2Releases.stiffnessZZ));
                analyticalModelCol.SetOffset(AnalyticalElementSelector.StartOrBase, offset1);
                analyticalModelCol.SetOffset(AnalyticalElementSelector.EndOrTop, offset2);
                return(placeholders);

                //Column column = new Column(speckleStick.baseLine);
                return(ColumnToNative(revitColumn));
            }
            return(placeholderObjects);
        }
Esempio n. 3
0
        private RevitBeam BeamToSpeckle(DB.FamilyInstance revitBeam)
        {
            var baseGeometry = LocationToSpeckle(revitBeam);
            var baseLine     = baseGeometry as ICurve;

            if (baseLine == null)
            {
                throw new Exception("Only line based Beams are currently supported.");
            }

            var speckleBeam = new RevitBeam();

            speckleBeam.type            = Doc.GetElement(revitBeam.GetTypeId()).Name;
            speckleBeam.baseLine        = baseLine;
            speckleBeam.level           = ConvertAndCacheLevel(revitBeam, BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);
            speckleBeam["@displayMesh"] = GetElementMesh(revitBeam);

            GetAllRevitParamsAndIds(speckleBeam, revitBeam);

            return(speckleBeam);
        }
Esempio n. 4
0
        private Base BeamToSpeckle(DB.FamilyInstance revitBeam)
        {
            var baseGeometry = LocationToSpeckle(revitBeam);
            var baseLine     = baseGeometry as ICurve;

            if (baseLine == null)
            {
                return(RevitElementToSpeckle(revitBeam));
            }

            var speckleBeam = new RevitBeam();

            speckleBeam.type        = Doc.GetElement(revitBeam.GetTypeId()).Name;
            speckleBeam.baseLine    = baseLine;
            speckleBeam.level       = ConvertAndCacheLevel(revitBeam, BuiltInParameter.INSTANCE_REFERENCE_LEVEL_PARAM);
            speckleBeam.displayMesh = GetElementMesh(revitBeam);

            GetAllRevitParamsAndIds(speckleBeam, revitBeam);

            return(speckleBeam);
        }
Esempio n. 5
0
        public List <ApplicationPlaceholderObject> BraceToNative(Brace speckleBrace)
        {
            //reuse ConversionLog.Addic in Beam class, at these are basically the same thing
            if (speckleBrace is RevitBrace rb)
            {
                var speckleBeam = new RevitBeam
                {
                    baseLine   = rb.baseLine,
                    type       = rb.type,
                    level      = rb.level,
                    family     = rb.family,
                    parameters = rb.parameters,
                };

                return(BeamToNative(speckleBeam, StructuralType.Brace));
            }
            else
            {
                var speckleBeam = new Beam();
                speckleBeam.baseLine = speckleBrace.baseLine;
                return(BeamToNative(speckleBeam, StructuralType.Brace));
            }
        }