public string StartAx(List <Line> ln) { AxisVMApplication AxApp = new AxisVMApplication(); AxisVMModels AxModels = new AxisVMModels(); AxisVMModel AxModel = new AxisVMModel(); AxisVMNodes AxNodes = new AxisVMNodes(); AxisVMLines AxLines = new AxisVMLines(); AxisVMLine AxLine = new AxisVMLine(); ELineGeomType geomType = new ELineGeomType(); RLineGeomData geomData = new RLineGeomData(); //Show AxisVM GUI and setup AxisVM to remain opened when COM client finished AxApp.CloseOnLastReleased = ELongBoolean.lbFalse; //Axis doesn't exit when script finishes AxApp.AskCloseOnLastReleased = ELongBoolean.lbFalse; //Show close dialog before exit AxApp.Visible = ELongBoolean.lbFalse; //set on lbFalse can improve speed //Check if COM client is loaded, otherwise wait until loaded int k = 0; ELongBoolean loaded = ELongBoolean.lbFalse; while ((k < 30) && (loaded == ELongBoolean.lbFalse)) { k++; System.Threading.Thread.Sleep(2 * 1000); //wait for 2 sec, total waiting time is limited to 1 minute loaded = ((IAxisVMApplication)AxApp).Loaded; } //Create new model AxModels = AxApp.Models; AxModel = AxModels.Item[1]; //create nodes AxNodes = AxModel.Nodes; List <Point3d> pt = new List <Point3d>(); Point3d newPt = new Point3d(); for (int i = 0; i < ln.Count; i++) { if (ln[i].Length > 0) { newPt = ln[i].From; if (GetPointID(pt, newPt, 0.001) == -1) { pt.Add(newPt); } newPt = ln[i].To; if (GetPointID(pt, newPt, 0.001) == -1) { pt.Add(newPt); } } } for (int i = 0; i < pt.Count; i++) { AxNodes.Add(pt[i].X, pt[i].Y, pt[i].Z); } //create lines, elements AxLines = AxModel.Lines; RPoint3d exc = new RPoint3d { x = 0, y = 0, z = 0 }; int IDs = -1; int IDe = -1; int notValidLineCount = 0; for (int i = 0; i < ln.Count; i++) { if (ln[i].Length > 0) { IDs = GetPointID(pt, ln[i].From, 0.001); IDe = GetPointID(pt, ln[i].To, 0.001); if ((IDs >= 0) && (IDe >= 0)) { AxLines.Add(IDs, IDe, geomType, geomData); AxLine = AxLines.Item[i + 1 - notValidLineCount]; } else { return("node list is not complete"); } } else { notValidLineCount++; } } AxApp.Visible = ELongBoolean.lbTrue; AxApp.BringToFront(); return("ok"); }
public string StartAx(List <GH_AxMember> mb) { AxisVMApplication AxApp = new AxisVMApplication(); AxisVMModels AxModels = new AxisVMModels(); AxisVMModel AxModel = new AxisVMModel(); AxisVMMaterials AxMaterials = new AxisVMMaterials(); AxisVMMaterial AxMaterial = new AxisVMMaterial(); ENationalDesignCode code = new ENationalDesignCode(); AxisVMCrossSections AxCrossSections = new AxisVMCrossSections(); AxisVMCrossSection AxCrossSection = new AxisVMCrossSection(); AxisVMNodes AxNodes = new AxisVMNodes(); AxisVMLines AxLines = new AxisVMLines(); AxisVMLine AxLine = new AxisVMLine(); ELineGeomType geomType = new ELineGeomType(); RLineGeomData geomData = new RLineGeomData(); AxisVMMembers AxisMembers = new AxisVMMembers(); AxisVMNodalSupports AxNodalSupports = new AxisVMNodalSupports(); AxisVMMembers AxMembers = new AxisVMMembers(); AxisVMMember AxMember = new AxisVMMember(); //RRelease AxRelease = new RRelease(); //Show AxisVM GUI and setup AxisVM to remain opened when COM client finished AxApp.CloseOnLastReleased = ELongBoolean.lbFalse; //Axis doesn't exit when script finishes AxApp.AskCloseOnLastReleased = ELongBoolean.lbFalse; //Show close dialog before exit AxApp.Visible = ELongBoolean.lbFalse; //set on lbFalse can improve speed //Check if COM client is loaded, otherwise wait until loaded int k = 0; ELongBoolean loaded = ELongBoolean.lbFalse; while ((k < 30) && (loaded == ELongBoolean.lbFalse)) { k++; System.Threading.Thread.Sleep(2 * 1000); //wait for 2 sec, total waiting time is limited to 1 minute loaded = ((IAxisVMApplication)AxApp).Loaded; } //Create new model AxModels = AxApp.Models; AxModel = AxModels.Item[1]; //Create material code = ENationalDesignCode.ndcEuroCode; //currently limited to Eurocode AxMaterials = AxModel.Materials; int[] MatID = new int[mb.Count]; //material ID for each structural member List <string> Mstrs = new List <string>(); // list of material names already loaded List <int> MIDs = new List <int>(); // list of material IDs already loaded StringComparison sc = StringComparison.CurrentCultureIgnoreCase; for (int i = 0; i < mb.Count; i++) { string Mstr = mb[i].Value.MatType; //chcek if this material has already been defined or not bool alreadyDefined = false; for (int j = 0; j < Mstrs.Count; j++) { if (Mstrs[j].Equals(Mstr, sc)) { MatID[i] = MIDs[j]; alreadyDefined = true; } } if (!alreadyDefined) { MatID[i] = AxMaterials.AddFromCatalog(code, Mstr); Mstrs.Add(Mstr); MIDs.Add(MatID[i]); AxMaterial = AxMaterials.Item[MatID[i]]; } } //Add cross sections AxCrossSections = AxModel.CrossSections; int[] SectID = new int[mb.Count]; //section ID for each structural member List <string> CSstrs = new List <string>(); // list of sect names already loaded List <int> CSIDs = new List <int>(); // list of sect IDs already loaded for (int i = 0; i < mb.Count; i++) { string CSstr = mb[i].Value.SectType; //chcek if this cross-section has already been defined or not bool alreadyDefined = false; for (int j = 0; j < CSstrs.Count; j++) { if (CSstrs[j].Equals(CSstr, sc)) { SectID[i] = CSIDs[j]; alreadyDefined = true; } } if (!alreadyDefined) { SectID[i] = GetCrossSection(CSstr, sc, AxCrossSections); //currently limited to pipe, I, Box CSstrs.Add(CSstr); CSIDs.Add(SectID[i]); AxCrossSection = AxCrossSections.Item[SectID[i]]; } } //create nodes AxNodes = AxModel.Nodes; List <Point3d> pt = new List <Point3d>(); Point3d newPt = new Point3d(); for (int i = 0; i < mb.Count; i++) { newPt = mb[i].Value.Ln.From; if (GetPointID(pt, newPt, 0.001) == -1) { pt.Add(newPt); } newPt = mb[i].Value.Ln.To; if (GetPointID(pt, newPt, 0.001) == -1) { pt.Add(newPt); } } for (int i = 0; i < pt.Count; i++) { AxNodes.Add(pt[i].X, pt[i].Y, pt[i].Z); } //create lines, elements AxLines = AxModel.Lines; RPoint3d exc = new RPoint3d { x = 0, y = 0, z = 0 }; int IDs = -1; int IDe = -1; int notValidLineCount = 0; //... ezt meg kell ugy csinalni, mint a ExportLine-nal? for (int i = 0; i < mb.Count; i++) { IDs = GetPointID(pt, mb[i].Value.Ln.From, 0.001); IDe = GetPointID(pt, mb[i].Value.Ln.To, 0.001); if ((IDs >= 0) && (IDe >= 0)) { AxLines.Add(IDs, IDe, geomType, geomData); AxLine = AxLines.Item[i + 1]; string Tstr = mb[i].Value.ElementType; if (Tstr.Equals("truss")) { AxLine.DefineAsTruss(MatID[i], SectID[i], ELineNonLinearity.lnlTensionAndCompression, 0); } else if (Tstr.Equals("beam")) { AxLine.DefineAsBeam(MatID[i], SectID[i], SectID[i], exc, exc); } else if (Tstr.Equals("rib")) { AxLine.DefineAsRib(MatID[i], SectID[i], SectID[i], exc, exc); } ; } else { return("node list is not complete"); } } //set the specified releases - assume rigid connections //AxMember = AxMembers.Item[0]; //AxRelease.ReleaseType = EReleaseType.rtRigid; //RReleases AxReleases = new RReleases //{ // x = AxRelease, // y = AxRelease, // z = AxRelease, // xx = AxRelease, // yy = AxRelease, // zz = AxRelease //}; //AxMember.SetStartReleases(AxReleases); //AxMember.SetEndReleases(AxReleases); //set supports //RNonLinearity NonLinearity = new RNonLinearity //{ // x = ELineNonLinearity.lnlTensionAndCompression, // y = ELineNonLinearity.lnlTensionAndCompression, // z = ELineNonLinearity.lnlTensionAndCompression, // xx = ELineNonLinearity.lnlTensionAndCompression, // yy = ELineNonLinearity.lnlTensionAndCompression, // zz = ELineNonLinearity.lnlTensionAndCompression //}; //RResistances Resistances = new RResistances //{ // x = 0, // y = 0, // z = 0, // xx = 0, // yy = 0, // zz = 0 //}; //RStiffnesses Stiffness = new RStiffnesses //{ // x = 1e10, // y = 1e10, // z = 1e10, // xx = 1e10, // yy = 1e10, // zz = 1e10 //}; //AxNodalSupports.AddNodalBeamRelative(Stiffness, NonLinearity, Resistances, 1, 1); AxApp.Visible = ELongBoolean.lbTrue; AxApp.BringToFront(); return("ok"); }