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 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 }, }); }
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"); }
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 }, }); }