/// <summary>
        /// Add materials to the IDEA open model
        /// </summary>
        /// <param name="model">Open model</param>
        private static void AddMaterialsToIOM(OpenModel model)
        {
            MatSteelEc2 material = new MatSteelEc2();

            material.Id                         = 1;
            material.Name                       = "S355";
            material.E                          = 210000000000.00003;
            material.G                          = material.E / (2 * (1 + 0.3));
            material.Poisson                    = 0.3;
            material.UnitMass                   = 7850;
            material.SpecificHeat               = 0.6;
            material.ThermalExpansion           = 0.000012;
            material.ThermalConductivity        = 45;
            material.IsDefaultMaterial          = false;
            material.OrderInCode                = 0;
            material.StateOfThermalExpansion    = ThermalExpansionState.Code;
            material.StateOfThermalConductivity = ThermalConductivityState.Code;
            material.StateOfThermalSpecificHeat = ThermalSpecificHeatState.Code;
            material.StateOfThermalStressStrain = ThermalStressStrainState.Code;
            material.StateOfThermalStrain       = ThermalStrainState.Code;
            material.fy                         = 355000000.00000006;
            material.fu                         = 510000000.00000006;
            material.fy40                       = 335000000.00000006;
            material.fu40                       = 470000000.00000006;
            material.DiagramType                = SteelDiagramType.Bilinear;

            model.AddObject(material);
        }
Exemplo n.º 2
0
        private void AddMaterialsToOpenModel()
        {
            MatSteelEc2 matOM = new MatSteelEc2();

            matOM.Id                  = openStructModel.GetMaxId(matOM) + 1;
            matOM.Name                = "S275";
            matOM.E                   = 210000000;
            matOM.G                   = matOM.E / (2 * (1 + 0.3));
            matOM.Poisson             = 0.3;
            matOM.UnitMass            = 7850 / 9.81;
            matOM.fu                  = 430000000;
            matOM.fy                  = 275000000;
            matOM.fu40                = 410000000;
            matOM.fy40                = 255000000;
            matOM.SpecificHeat        = 0.49;
            matOM.ThermalConductivity = 50.2;
            matOM.ThermalExpansion    = 0.000012;

            openStructModel.AddObject(matOM);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Serializes the openmodel  object and returns it as a memory stream
        /// </summary>
        /// <returns>memory stream containing the openmodel  serialized in xml format</returns>



        private void AddMaterialSteelToOpenModel(MaterialSteel material)
        {
            MatSteelEc2 matOM = new MatSteelEc2();

            matOM.Id                  = material.id;
            matOM.Name                = material.name;
            matOM.E                   = 210000000;
            matOM.Poisson             = 0.3;
            matOM.UnitMass            = 7870 / 9.81;
            matOM.fu                  = material.fu * Math.Pow(10, 6);   // 430000000;
            matOM.fy                  = material.fy * Math.Pow(10, 6);   // 275000000;
            matOM.fu40                = material.fu40 * Math.Pow(10, 6); // 410000000;
            matOM.fy40                = material.fy40 * Math.Pow(10, 6); // 255000000;
            matOM.SpecificHeat        = 0.49;
            matOM.ThermalConductivity = 50.2;
            matOM.ThermalExpansion    = 0.000012;
            matOM.G                   = matOM.E / (2 * (1 + matOM.Poisson));

            openModel.AddObject(matOM);
        }
Exemplo n.º 4
0
        protected override ModelBIM ImportActive(CountryCode countryCode, RequestedItemsType requestedType)
        {
            try
            {
                if (_selectedObjects?.Count == 0)
                {
                    Debug.Fail("Nothing selected");
                    return(null);
                }

                var materials        = new Dictionary <string, MatSteelEc2>();
                var crossSections    = new Dictionary <string, CrossSectionParameter>();
                var pointConnections = _selectedObjects.OfType <StructuralPointConnection>().ToList();
                var curveMembers     = _selectedObjects.OfType <StructuralCurveMember>().ToList();
                var assemblies       = _selectedObjects.OfType <ElementAssembly>().ToList();
                if (pointConnections.Count == 0)
                {
                    MessageBoxHelper.ShowInformation("please select a PointConnection object to identify the connectionPoint", null);
                    return(null);
                }

                // read all nodes (maybe it's esier)
                var nodes = _integrationBase.ApiCore.DtObjects.GetObjects <StructuralPointConnection>(
                    _integrationBase.CurrentProject.Id, false, false, true);



                OpenModel openModel = new OpenModel
                {
                    OriginSettings = new OriginSettings()
                    {
                        CrossSectionConversionTable = IdeaRS.OpenModel.CrossSectionConversionTable.NoUsed, CountryCode = countryCode
                    }
                };


                int ccsId    = 1;
                int matId    = 1;
                int lsId     = 1;
                int memberId = 1;
                // ConnectionPoint
                ConnectionPoint connectionPoint = null;
                foreach (var point in pointConnections)
                {
                    // ad main node to openModel
                    connectionPoint = new ConnectionPoint();
                    if (point.NodeId.HasValue)
                    {
                        ConnectionPointId = point.NodeId.Value;
                    }
                    Point3D node = AddNodeToOpenModel(point, openModel, ConnectionPointId);
                    connectionPoint.Node = new ReferenceElement(node);

                    connectionPoint.Id              = ConnectionPointId;
                    connectionPoint.Name            = string.Format("Conn-{0}", ConnectionPointId);
                    connectionPoint.ProjectFileName = Path.Combine(".\\Connections", connectionPoint.Name + ".ideaCon");
                }


                // try to add Member1D objects if they are not selected by user
                foreach (var assembly in assemblies)
                {
                    if (assembly.Connections == null)
                    {
                        continue;
                    }
                    foreach (var c in assembly.Connections)
                    {
                        var ce = c as RelConnectsElements;
                        if (ce == null || curveMembers.Find(x => x.Id == ce.RelatedElement.Value) != null)
                        {
                            continue;
                        }
                        var cm = _integrationBase.ApiCore.DtObjects.GetObjectInternal(ce.RelatedElement.Value) as StructuralCurveMember;
                        if (cm != null)
                        {
                            foreach (var cm1 in pointConnections[0].ConnectsStructuralMembers)
                            {
                                if (cm.Id.ToString() == cm1.RelatingStructuralMember.GetValueOrDefault().ToString())
                                {
                                    curveMembers.Add(cm);
                                }
                            }
                        }
                    }
                }
                // create Element1D from StructuralCurveMember
                foreach (var element in curveMembers)
                {
                    var matName = element.GetStringProperty(TableNames.contentAttributes, MaterialAttributeId) ?? "S355";
                    if (!materials.ContainsKey(matName))
                    {
                        MatSteelEc2 material = new MatSteelEc2();

                        // set properties
                        material.Id                         = matId++;
                        material.Name                       = matName;
                        material.E                          = 210000000000;
                        material.G                          = material.E / (2 * (1 + 0.3));
                        material.Poisson                    = 0.3;
                        material.UnitMass                   = 7850;
                        material.SpecificHeat               = 0.6;
                        material.ThermalExpansion           = 0.000012;
                        material.ThermalConductivity        = 45;
                        material.IsDefaultMaterial          = false;
                        material.OrderInCode                = 0;
                        material.StateOfThermalExpansion    = ThermalExpansionState.Code;
                        material.StateOfThermalConductivity = ThermalConductivityState.Code;
                        material.StateOfThermalSpecificHeat = ThermalSpecificHeatState.Code;
                        material.StateOfThermalStressStrain = ThermalStressStrainState.Code;
                        material.StateOfThermalStrain       = ThermalStrainState.Code;
                        material.fy                         = 355000000;
                        material.fu                         = 510000000;
                        material.fy40                       = 335000000;
                        material.fu40                       = 470000000;
                        material.DiagramType                = SteelDiagramType.Bilinear;

                        // add material to the model
                        openModel.AddObject(material);
                        materials.Add(matName, material);
                    }

                    var crossSection = element.GetStringProperty(TableNames.contentAttributes, CrossSectionAttributeId) ?? "HE200";
                    crossSection = crossSection.Replace("HE200B", "HEB200");
                    crossSection = crossSection.Replace("HE240B", "HEB240");
                    if (!crossSections.ContainsKey(crossSection))
                    {
                        CrossSectionParameter css = new CrossSectionParameter
                        {
                            Id   = ccsId++,
                            Name = crossSection,
                            CrossSectionRotation = 0,
                            CrossSectionType     = CrossSectionType.RolledI,
                            Material             = new ReferenceElement(materials[matName])
                        };
                        css.Parameters.Add(new ParameterString()
                        {
                            Name = "UniqueName", Value = crossSection
                        });

                        // add cross sections to the model
                        openModel.AddObject(css);
                        crossSections.Add(crossSection, css);
                    }

                    if (element?.ConnectedBy.Count != 2)
                    {
                        continue;
                    }

                    var node = nodes.Find(x => x.Id == element?.ConnectedBy[0].RelatedStructuralConnection.Value);
                    if (node == null)
                    {
                        continue;
                    }
                    Point3D ptA = AddNodeToOpenModel(node, openModel, node.NodeId.GetValueOrDefault());

                    node = nodes.Find(x => x.Id == element?.ConnectedBy[1].RelatedStructuralConnection.Value);
                    Point3D ptB = AddNodeToOpenModel(node, openModel, node.NodeId.GetValueOrDefault());

                    var member1d = new Member1D
                    {
                        Id   = memberId++,
                        Name = element.Name
                    };

                    IdeaRS.OpenModel.Geometry3D.PolyLine3D polyLine3D = new IdeaRS.OpenModel.Geometry3D.PolyLine3D
                    {
                        Id = member1d.Id
                    };

                    var start      = new WM.Point3D(ptA.X, ptA.Y, ptA.Z);
                    var end        = new WM.Point3D(ptB.X, ptB.Y, ptB.Z);
                    var dirVectort = end - start;

                    GetAngles(dirVectort, out double alpha, out double beta);
                    beta *= -1;

                    CI.Geometry3D.Matrix44 lcsSegmentMatrix = new CI.Geometry3D.Matrix44();

                    if (!IsZero(beta))
                    {
                        // gamma pitch
                        lcsSegmentMatrix.Rotate(beta, new CI.Geometry3D.Vector3D(0, 1, 0));
                    }

                    if (!IsZero(alpha))
                    {
                        // beta direction
                        lcsSegmentMatrix.Rotate(alpha, new CI.Geometry3D.Vector3D(0, 0, 1));
                    }

                    IdeaRS.OpenModel.Geometry3D.LineSegment3D ls = new IdeaRS.OpenModel.Geometry3D.LineSegment3D
                    {
                        Id                    = member1d.Id,
                        StartPoint            = new ReferenceElement(ptA),
                        EndPoint              = new ReferenceElement(ptB),
                        LocalCoordinateSystem = new IdeaRS.OpenModel.Geometry3D.CoordSystemByVector()
                        {
                            VecX = new IdeaRS.OpenModel.Geometry3D.Vector3D()
                            {
                                X = lcsSegmentMatrix.AxisX.DirectionX,
                                Y = lcsSegmentMatrix.AxisX.DirectionY,
                                Z = lcsSegmentMatrix.AxisX.DirectionZ,
                            }
                            ,
                            VecY = new IdeaRS.OpenModel.Geometry3D.Vector3D()
                            {
                                X = lcsSegmentMatrix.AxisY.DirectionX,
                                Y = lcsSegmentMatrix.AxisY.DirectionY,
                                Z = lcsSegmentMatrix.AxisY.DirectionZ,
                            }
                            ,
                            VecZ = new IdeaRS.OpenModel.Geometry3D.Vector3D()
                            {
                                X = lcsSegmentMatrix.AxisZ.DirectionX,
                                Y = lcsSegmentMatrix.AxisZ.DirectionY,
                                Z = lcsSegmentMatrix.AxisZ.DirectionZ,
                            }
                        },
                    };
                    polyLine3D.Segments.Add(new ReferenceElement(ls));

                    openModel.PolyLine3D.Add(polyLine3D);
                    openModel.LineSegment3D.Add(ls);

                    Element1D element1d = new Element1D
                    {
                        Id                = member1d.Id,
                        Name              = element.Id.ToString(), //element.Name, Its esier for mapping Element1D with bimplus Structuralcurvemember
                        RotationRx        = element.GetDoubleProperty(TableNames.contentAttributes, RotationAttributeId) ?? 0,
                        CrossSectionBegin = new ReferenceElement(crossSections[crossSection]),
                        CrossSectionEnd   = new ReferenceElement(crossSections[crossSection]),
                        Segment           = new ReferenceElement(ls)
                    };
                    openModel.Element1D.Add(element1d);

                    member1d.Elements1D.Add(new ReferenceElement(element1d));

                    openModel.Member1D.Add(member1d);

                    if (connectionPoint != null)
                    {
                        ConnectedMember conMb = new ConnectedMember
                        {
                            Id           = member1d.Id,
                            MemberId     = new ReferenceElement(member1d),
                            IsContinuous = false,
                        };

                        connectionPoint.ConnectedMembers.Add(conMb);
                    }

                    BeamData beamData = new BeamData
                    {
                        Id                       = member1d.Id,
                        Name                     = element1d.Name,
                        OriginalModelId          = member1d.Id.ToString(), // member1d.Name,
                        IsAdded                  = false,
                        MirrorY                  = false,
                        RefLineInCenterOfGravity = true,
                    };

                    if (openModel.Connections.Count == 0)
                    {
                        openModel.Connections.Add(new ConnectionData());
                    }
                    (openModel.Connections[0].Beams ?? (openModel.Connections[0].Beams = new List <BeamData>())).Add(beamData);
                }

                // create Member1D from assemblies

                /* foreach (var assembly in assemblies)
                 * {
                 *   var member1d = new Member1D
                 *   {
                 *       Id = assembly.OrderNumber.GetValueOrDefault(),
                 *       Name = assembly.Name
                 *   };
                 *   foreach (var c in assembly.Connections)
                 *   {
                 *       var ce = c as RelConnectsElements;
                 *       var element = openModel.Element1D.Find(x => x.Name == ce.RelatedElement.ToString());
                 *       if (element == null) continue;
                 *       member1d.Elements1D.Add(new ReferenceElement(element));
                 *       openModel.Member1D.Add(member1d);
                 *   }
                 * }*/

                /*if (connectionPoint != null)
                 * {
                 *   var p0t = pointConnections.Find(x => x.NodeId.GetValueOrDefault() == ConnectionPointId);
                 *   if (p0t != null && p0t.ConnectsStructuralMembers != null)
                 *   {
                 *       foreach (var cm in p0t.ConnectsStructuralMembers)
                 *       {
                 *           var member = openModel.Element1D.Find(x => x.Name == cm.RelatingStructuralMember.GetValueOrDefault().ToString());
                 *           if (member == null)
                 *               continue;
                 *           ConnectedMember conMb = new ConnectedMember
                 *           {
                 *               Id = member.Id,
                 *               MemberId = new ReferenceElement(member),
                 *               IsContinuous = false,
                 *           };
                 *           connectionPoint.ConnectedMembers.Add(conMb);
                 *
                 *           // BEAM DATA - definition
                 *           BeamData bData = new BeamData
                 *           {
                 *               Id = conMb.Id,
                 *               OriginalModelId = "???", // ass.Id.ToString(), is it important?
                 *               IsAdded = false,
                 *               MirrorY = false,
                 *               RefLineInCenterOfGravity = false,
                 *           };
                 *           if (openModel.Connections.Count == 0)
                 *           {
                 *               openModel.Connections.Add(new ConnectionData { Beams = new List<BeamData>() });
                 *           }
                 *           openModel.Connections[0].Beams.Add(bData);
                 *       }
                 *   }
                 *
                 * }*/
                openModel.AddObject(connectionPoint); // important !!!

                OpenModelResult openModelResult =
                    new OpenModelResult()
                {
                    ResultOnMembers = new System.Collections.Generic.List <ResultOnMembers>()
                    {
                        new ResultOnMembers()
                    }
                };
                OpenMessages openMessages = new OpenMessages();

                return(new ModelBIM()
                {
                    Items = new List <BIMItemId>()
                    {
                        new BIMItemId()
                        {
                            Id = connectionPoint.Id, Type = BIMItemType.Node
                        }
                    },
                    Model = openModel,
                    Results = openModelResult,
                    Messages = openMessages,
                    Project = AllplanBimplusDemo.Properties.Settings.Default.IdeaDefaultWorkingDir,
                });
            }
            catch (Exception e)
            {
                MessageBoxHelper.ShowInformation(e.Message, null);
                return(null);
            }
        }