Esempio n. 1
0
        public static IDictionary SendMembers(AxModel AxModel, Boolean b, List <AxMember> axm)
        {
            bool propChanged = false;

            if (b == true)
            {
                AxModel.AxModel_.BeginUpdate();

                //Create material
                int[]            MatID = new int[axm.Count]; //material ID for each structural member
                StringComparison sc    = StringComparison.CurrentCultureIgnoreCase;
                for (int i = 0; i < axm.Count; i++)
                {
                    string Mstr = axm[i].mat;

                    //chcek if this material has already been defined or not
                    bool alreadyDefined = false;
                    for (int j = 0; j < AxModel.Mstrs.Count; j++)
                    {
                        if (AxModel.Mstrs[j].Equals(Mstr, sc))
                        {
                            MatID[i] = AxModel.MIDs[j]; alreadyDefined = true;
                        }
                    }

                    if (!alreadyDefined)
                    {
                        MatID[i] = AxModel.AxMaterials.AddFromCatalog(AxModel.code, Mstr);
                        AxModel.Mstrs.Add(Mstr);
                        AxModel.MIDs.Add(MatID[i]);
                        AxModel.AxMaterial = AxModel.AxMaterials.Item[MatID[i]];
                    }
                }

                //Add cross sections
                int[] SectID = new int[axm.Count]; //section ID for each structural member
                for (int i = 0; i < axm.Count; i++)
                {
                    string CSstr = axm[i].cs;

                    //chcek if this cross-section has already been defined or not
                    bool alreadyDefined = false;
                    for (int j = 0; j < AxModel.CSstrs.Count; j++)
                    {
                        if (AxModel.CSstrs[j].Equals(CSstr, sc))
                        {
                            SectID[i] = AxModel.CSIDs[j]; alreadyDefined = true;
                        }
                    }

                    if (!alreadyDefined)
                    {
                        SectID[i] = Extra.GetCrossSection(CSstr, sc, AxModel.AxCrossSections); //currently limited to pipe, I, Box
                        AxModel.CSstrs.Add(CSstr);
                        AxModel.CSIDs.Add(SectID[i]);
                        AxModel.AxCrossSection = AxModel.AxCrossSections.Item[SectID[i]];
                    }
                }

                //Geometry
                Point    newPt = Point.ByCoordinates(0, 0, 0);
                int      ptId  = -1;
                RPoint3d exc   = new RPoint3d {
                    x = 0, y = 0, z = 0
                };
                int     notValidLineCount = 0;
                Boolean bModify           = false;
                if (AxModel.lns.Count > 0)
                {
                    bModify = true;
                }
                for (int i = 0; i < axm.Count; i++)
                {
                    if (axm[i].ln.Length > 0)
                    {
                        if (bModify)
                        {
                            // modify existing line
                            newPt = axm[i].ln.StartPoint;
                            ptId  = AxModel.sIDs[i];
                            if (ptId != -1)
                            {
                                RPoint3d aPt = new RPoint3d {
                                    x = newPt.X, y = newPt.Y, z = newPt.Z
                                };
                                AxModel.AxNodes.SetNodeCoord(ptId, aPt);
                                AxModel.pts[ptId - 1] = newPt;
                                AxModel.lns[i]        = axm[i].ln;
                            }
                            newPt = axm[i].ln.EndPoint;
                            ptId  = AxModel.eIDs[i];
                            if (ptId != -1)
                            {
                                RPoint3d aPt = new RPoint3d {
                                    x = newPt.X, y = newPt.Y, z = newPt.Z
                                };
                                AxModel.AxNodes.SetNodeCoord(ptId, aPt);
                                AxModel.pts[ptId - 1] = newPt;
                                AxModel.lns[i]        = axm[i].ln;
                            }
                            if (AxModel.membProps[i] != new int[] { SectID[i], MatID[i], 0 })
                            {
                                AxModel.AxLine = AxModel.AxLines.Item[i + 1 - notValidLineCount];
                                string Tstr = axm[i].typ;
                                if (Tstr.Equals("truss"))
                                {
                                    AxModel.AxLine.DefineAsTruss(MatID[i], SectID[i], ELineNonLinearity.lnlTensionAndCompression, 0);
                                }
                                else if (Tstr.Equals("beam"))
                                {
                                    AxModel.AxLine.DefineAsBeam(MatID[i], SectID[i], SectID[i], exc, exc);
                                }
                                else if (Tstr.Equals("rib"))
                                {
                                    AxModel.AxLine.DefineAsRib(MatID[i], SectID[i], SectID[i], exc, exc);
                                }
                            }
                        }
                        else
                        {
                            //create new line
                            newPt = axm[i].ln.StartPoint;
                            if (Extra.GetPointID(AxModel.pts, newPt, 0.001) == -1)
                            {
                                AxModel.pts.Add(newPt);
                                AxModel.AxNodes.Add(newPt.X, newPt.Y, newPt.Z); // add new points to Axis
                            }
                            newPt = axm[i].ln.EndPoint;
                            if (Extra.GetPointID(AxModel.pts, newPt, 0.001) == -1)
                            {
                                AxModel.pts.Add(newPt);
                                AxModel.AxNodes.Add(newPt.X, newPt.Y, newPt.Z); // add new points to Axis
                            }
                            AxModel.sIDs.Add(Extra.GetPointID(AxModel.pts, axm[i].ln.StartPoint, 0.001));
                            AxModel.eIDs.Add(Extra.GetPointID(AxModel.pts, axm[i].ln.EndPoint, 0.001));
                            if ((AxModel.sIDs[i] >= 0) && (AxModel.eIDs[i] >= 0))
                            {
                                AxModel.AxLines.Add(AxModel.sIDs[i], AxModel.eIDs[i], AxModel.geomType, AxModel.geomData);
                                AxModel.AxLine = AxModel.AxLines.Item[i + 1 - notValidLineCount];
                                string Tstr = axm[i].typ;
                                if (Tstr.Equals("truss"))
                                {
                                    AxModel.AxLine.DefineAsTruss(MatID[i], SectID[i], ELineNonLinearity.lnlTensionAndCompression, 0);
                                    AxModel.membProps.Add(new int[] { SectID[i], MatID[i], 0 });
                                }
                                else if (Tstr.Equals("beam"))
                                {
                                    AxModel.AxLine.DefineAsBeam(MatID[i], SectID[i], SectID[i], exc, exc);
                                    AxModel.membProps.Add(new int[] { SectID[i], MatID[i], 1 });
                                }
                                else if (Tstr.Equals("rib"))
                                {
                                    AxModel.AxLine.DefineAsRib(MatID[i], SectID[i], SectID[i], exc, exc);
                                    AxModel.membProps.Add(new int[] { SectID[i], MatID[i], 2 });
                                }
                                ;
                                AxModel.lns.Add(axm[i].ln);
                                AxModel.sw.Add(false);
                            }
                        }
                    }
                    else
                    {
                        notValidLineCount++;
                    }
                }

                //todo: endupdate only if no analysis
                AxModel.AxModel_.EndUpdate();
                //RExtendedDisplayParameters dispextpar = new RExtendedDisplayParameters();
                //long lcID = 0;
                //safearray secID = 0;
                //AxModel.AxWindows.GetStaticDisplayParameters(1, dispextpar, lcID, secIDs);
                //dispextpar
                AxModel.AxApp.Visible = ELongBoolean.lbTrue;
                AxModel.AxApp.BringToFront();

                return(new Dictionary <object, object>()
                {
                    { "AxModel", AxModel },
                    { "Points", AxModel.pts },
                    { "Lines", AxModel.lns },
                });
            }

            return(new Dictionary <object, object>()
            {
                { "AxModel", AxModel },
                { "Points", AxModel.pts },
                { "Lines", AxModel.lns },
            });
        }
Esempio n. 2
0
        public static IDictionary SendLines(AxModel AxModel, Boolean b, List <Line> ln)
        {
            if (b == true)
            {
                AxModel.AxModel_.BeginUpdate();
                Point    newPt = Point.ByCoordinates(0, 0, 0);
                int      ptId  = -1;
                RPoint3d exc   = new RPoint3d {
                    x = 0, y = 0, z = 0
                };
                int     notValidLineCount = 0;
                Boolean bModify           = false;
                if (AxModel.lns.Count > 0)
                {
                    bModify = true;
                }

                for (int i = 0; i < ln.Count; i++)
                {
                    if (ln[i].Length > 0)
                    {
                        if (bModify)
                        {
                            // modify existing line
                            newPt = ln[i].StartPoint;
                            ptId  = AxModel.sIDs[i];
                            if (ptId != -1)
                            {
                                RPoint3d aPt = new RPoint3d {
                                    x = newPt.X, y = newPt.Y, z = newPt.Z
                                };
                                AxModel.AxNodes.SetNodeCoord(ptId, aPt);
                                AxModel.pts[ptId - 1] = newPt;
                                AxModel.lns[i]        = ln[i];
                            }
                            newPt = ln[i].EndPoint;
                            ptId  = AxModel.eIDs[i];
                            if (ptId != -1)
                            {
                                RPoint3d aPt = new RPoint3d {
                                    x = newPt.X, y = newPt.Y, z = newPt.Z
                                };
                                AxModel.AxNodes.SetNodeCoord(ptId, aPt);
                                AxModel.pts[ptId - 1] = newPt;
                                AxModel.lns[i]        = ln[i];
                            }
                        }
                        else
                        {
                            //create new line
                            newPt = ln[i].StartPoint;
                            if (Extra.GetPointID(AxModel.pts, newPt, 0.001) == -1)
                            {
                                AxModel.pts.Add(newPt);
                                AxModel.AxNodes.Add(newPt.X, newPt.Y, newPt.Z); // add new points to Axis
                            }
                            newPt = ln[i].EndPoint;
                            if (Extra.GetPointID(AxModel.pts, newPt, 0.001) == -1)
                            {
                                AxModel.pts.Add(newPt);
                                AxModel.AxNodes.Add(newPt.X, newPt.Y, newPt.Z); // add new points to Axis
                            }
                            AxModel.sIDs.Add(Extra.GetPointID(AxModel.pts, ln[i].StartPoint, 0.001));
                            AxModel.eIDs.Add(Extra.GetPointID(AxModel.pts, ln[i].EndPoint, 0.001));
                            if ((AxModel.sIDs[i] >= 0) && (AxModel.eIDs[i] >= 0))
                            {
                                AxModel.AxLines.Add(AxModel.sIDs[i], AxModel.eIDs[i], AxModel.geomType, AxModel.geomData);
                                AxModel.AxLine = AxModel.AxLines.Item[i + 1 - notValidLineCount];
                                AxModel.lns.Add(ln[i]);
                            }
                        }
                    }
                    else
                    {
                        notValidLineCount++;
                    }
                }

                //todo: endupdate  only if no analysis or if there is analysis results available, it should be deleted
                AxModel.AxModel_.EndUpdate();

                AxModel.AxApp.Visible = ELongBoolean.lbTrue;
                AxModel.AxApp.BringToFront();


                return(new Dictionary <object, object>()
                {
                    { "AxModel", AxModel },
                    { "Points", AxModel.pts },
                    { "Lines", AxModel.lns },
                });
            }

            return(new Dictionary <object, object>()
            {
                { "AxModel", AxModel },
                { "Points", AxModel.pts },
                { "Lines", AxModel.lns },
            });
        }