private void CreateIDEAOpenModel() { openStructModel = new OpenModel(); openStructModel.OriginSettings = new OriginSettings() { CrossSectionConversionTable = CrossSectionConversionTable.SCIA }; openStructModel.OriginSettings.ProjectName = "Project 1"; openStructModel.OriginSettings.Author = "Author prj"; openStructModel.OriginSettings.ProjectDescription = "Part 27"; }
/// <summary> /// Add settings to the IDEA open model /// </summary> /// <param name="model">Open model</param> private static void AddSettingsToIOM(OpenModel model) { model.OriginSettings = new OriginSettings(); model.OriginSettings.CrossSectionConversionTable = CrossSectionConversionTable.SCIA; model.OriginSettings.CountryCode = CountryCode.ECEN; model.OriginSettings.ProjectName = "Project"; model.OriginSettings.Author = "IDEA StatiCa s.r.o."; model.OriginSettings.ProjectDescription = "Training example"; model.OriginSettings.CheckEquilibrium = true; }
/// <summary> /// Create member 1D /// </summary> /// <param name="model">Idea open model</param> /// <param name="id">Member id</param> /// <param name="type">Member type</param> /// <param name="element">Element</param> /// <returns>Member 1D</returns> private static Member1D CreateMember1D(OpenModel model, int id, Member1DType type, Element1D element) { Member1D member1D = new Member1D(); member1D.Id = id; member1D.Name = "M" + member1D.Id.ToString(); member1D.Member1DType = type; member1D.Elements1D.Add(new ReferenceElement(element)); return(member1D); }
public void CreateIDEAOpenModel() { openStructModel = new OpenModel(); openStructModel.OriginSettings = new OriginSettings() { CrossSectionConversionTable = CrossSectionConversionTable.SCIA }; openStructModel.OriginSettings.ProjectName = "TrussNode"; openStructModel.OriginSettings.Author = Environment.UserName;// "Rayaan Ajouz"; openStructModel.OriginSettings.ProjectDescription = "test m outt";; openStructModel.OriginSettings.DateOfCreate = DateTime.Now; }
/// <summary> /// Create element 1D /// </summary> /// <param name="model">Idea open model</param> /// <param name="css">Cross section</param> /// <param name="segment">Line segment</param> /// <returns>Element 1D</returns> private static Element1D CreateElement1D(OpenModel model, CrossSection css, LineSegment3D segment) { Element1D element1D = new Element1D(); element1D.Id = model.GetMaxId(element1D) + 1; element1D.Name = "E" + element1D.Id.ToString(); element1D.Segment = new ReferenceElement(segment); element1D.CrossSectionBegin = new ReferenceElement(css); element1D.CrossSectionEnd = new ReferenceElement(css); return(element1D); }
private void CreateIDEAOpenModel() { openStructModel = new OpenModel(); openStructModel.OriginSettings = new OriginSettings() { CrossSectionConversionTable = CrossSectionConversionTable.SCIA }; openStructModel.OriginSettings.ProjectName = "TrussNode"; openStructModel.OriginSettings.Author = "Author PGC"; openStructModel.OriginSettings.ProjectDescription = "TestProjectCreatingTrussnodes"; openStructModel.OriginSettings.DateOfCreate = DateTime.Now; }
private double GetLength(OpenModel openStructModel, Member1D mb) { Element1D el = openStructModel.Element1D.First(c => c.Id == mb.Elements1D[0].Id); LineSegment3D seg = openStructModel.LineSegment3D.First(c => c.Id == el.Segment.Id); Point3D pA = openStructModel.Point3D.First(c => c.Id == seg.StartPoint.Id); Point3D pB = openStructModel.Point3D.First(c => c.Id == seg.EndPoint.Id); Vector3D vector = new Vector3D(); vector.X = pA.X - pB.X; vector.Y = pA.Y - pB.Y; vector.Z = pA.Z - pB.Z; return(Math.Sqrt(((vector.X * vector.X) + (vector.Y * vector.Y) + (vector.Z * vector.Z)))); }
public static ObservableCollection <ProcessUnit> ExtractProcessUnits(Batch batch) { ObservableCollection <ProcessUnit> processUnits = new ObservableCollection <ProcessUnit>(); try { ProcessUnit unit = new ProcessUnit(); ObservableCollection <GenericElement> elements = batch.Target.Elements; for (int i = 0; i < elements.Count; i++) { GenericElement element = elements[i]; string elementType = element.GetType().Name; switch (elementType) { case "OpenModel": OpenModel openModel = element as OpenModel; if (openModel.FileExtension == ".smc") { unit.OpenSolibri = openModel; } else if (openModel.FileExtension == ".ifc") { unit.IfcFiles.Add(openModel); } break; case "BCFReport": unit.BCFReport = element as BCFReport; break; case "SaveModel": unit.SaveSolibri = element as SaveModel; if (unit.IfcFiles.Count > 0) { unit.OpenSolibri = new OpenModel(unit.SaveSolibri.File); } break; case "CloseModel": processUnits.Add(unit); unit = new ProcessUnit(); break; } } } catch (Exception ex) { MessageBox.Show("Failed to extract process units.\n" + ex.Message, "Extract Process Unit", MessageBoxButton.OK, MessageBoxImage.Warning); } return(processUnits); }
public static void Main(string[] args) { IdeaInstallDir = IOM.SteelFrameDesktop.Properties.Settings.Default.IdeaInstallDir; Console.WriteLine("IDEA StatiCa installation directory is '{0}'", IdeaInstallDir); AppDomain currentDomain = AppDomain.CurrentDomain; currentDomain.AssemblyResolve += new ResolveEventHandler(IdeaResolveEventHandler); Console.WriteLine("Start generate example of IOM..."); // create IOM and results OpenModel example = Example.CreateIOM(); OpenModelResult result = Helpers.GetResults(); // save to the files result.SaveToXmlFile("example.xmlR"); example.SaveToXmlFile("example.xml"); var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); var fileConnFileNameFromLocal = Path.Combine(desktopDir, "connectionFromIOM-local.ideaCon"); string ideaConLinkFullPath = System.IO.Path.Combine(IdeaInstallDir, "IdeaStatiCa.IOMToConnection.dll"); var conLinkAssembly = Assembly.LoadFrom(ideaConLinkFullPath); object obj = conLinkAssembly.CreateInstance("IdeaStatiCa.IOMToConnection.IOMToConnection"); dynamic d = obj; // Initializtion var initMethod = (obj).GetType().GetMethod("Init"); initMethod.Invoke(obj, null); Console.WriteLine("Generating IDEA Connection project locally"); // Invoking method Import by reflection var methodImport = (obj).GetType().GetMethod("Import"); object[] array = new object[3]; array[0] = example; array[1] = result; array[2] = fileConnFileNameFromLocal; methodImport.Invoke(obj, array); Console.WriteLine("Writing Idea connection project to file '{0}'", fileConnFileNameFromLocal); // end console application Console.WriteLine("Done. Press any key to exit."); Console.ReadKey(); }
/// <summary> /// Add combinations to the IDEA open model /// </summary> /// <param name="model">OpenModel</param> private static void AddCombinationsToIOM(OpenModel model) { // create first combination input CombiInputEC CI1 = new CombiInputEC(); CI1.Id = model.GetMaxId(CI1) + 1; CI1.Name = "Co.#1"; CI1.Description = "SelfWeight + PernamentLoading + LiveLoad"; CI1.TypeCombiEC = TypeOfCombiEC.ULS; CI1.TypeCalculationCombi = TypeCalculationCombiEC.Linear; CombiItem item = new CombiItem(); item.Id = 1; item.Coeff = 1; item.LoadCase = new ReferenceElement(model.LoadCase.FirstOrDefault(l => l.Name == "SelfWeight")); CI1.Items.Add(item); item = new CombiItem(); item.Id = 2; item.Coeff = 1; item.LoadCase = new ReferenceElement(model.LoadCase.FirstOrDefault(l => l.Name == "PernamentLoading")); CI1.Items.Add(item); item = new CombiItem(); item.Id = 3; item.Coeff = 1; item.LoadCase = new ReferenceElement(model.LoadCase.FirstOrDefault(l => l.Name == "LiveLoad")); CI1.Items.Add(item); model.AddObject(CI1); // create second combination input CombiInputEC CI2 = new CombiInputEC(); CI2.Id = model.GetMaxId(CI2) + 1; CI2.Name = "Co.#2"; CI2.Description = "SelfWeight"; CI2.TypeCombiEC = TypeOfCombiEC.ULS; CI2.TypeCalculationCombi = TypeCalculationCombiEC.Linear; item = new CombiItem(); item.Id = 1; item.Coeff = 1; item.LoadCase = new ReferenceElement(model.LoadCase.FirstOrDefault(l => l.Name == "SelfWeight")); CI2.Items.Add(item); model.AddObject(CI2); }
/// <summary> /// Add cross section to the IDEA open model /// </summary> /// <param name="model">Open model</param> private static void AddCrossSectionToIOM(OpenModel model) { // only one material is in the model MatSteel material = model.MatSteel.FirstOrDefault(); // create first cross section CrossSectionParameter css1 = Helpers.CreateCSSParameter(1, "HE200B", material); // create second cross section CrossSectionParameter css2 = Helpers.CreateCSSParameter(2, "HE240B", material); // add cross sections to the model model.AddObject(css1); model.AddObject(css2); }
/// <summary> /// Create member /// </summary> /// <param name="model">Idea open model</param> /// <param name="id">Member id</param> /// <param name="type">Member type</param> /// <param name="css">Cross section</param> /// <param name="startNode">Start node</param> /// <param name="middleNode">Middle node</param> /// <param name="endNode">End node</param> /// <returns>Connected member</returns> public static ConnectedMember CreateMember(OpenModel model, int id, Member1DType type, CrossSection css, string startNode, string middleNode, string endNode) { // column members have different coordination system in our example bool transformCoordSystem = type == Member1DType.Column ? true : false; // create line segments LineSegment3D segment1 = CreateLineSegment3D(model, startNode, middleNode, transformCoordSystem); model.AddObject(segment1); LineSegment3D segment2 = CreateLineSegment3D(model, middleNode, endNode, transformCoordSystem); model.AddObject(segment2); // create polylines PolyLine3D polyline = new PolyLine3D(); polyline.Id = model.GetMaxId(polyline) + 1; polyline.Segments.Add(new ReferenceElement(segment1)); polyline.Segments.Add(new ReferenceElement(segment2)); model.AddObject(polyline); // create 1D elements Element1D element1 = CreateElement1D(model, css, segment1); model.AddObject(element1); Element1D element2 = CreateElement1D(model, css, segment2); model.AddObject(element2); // create 1D members Member1D member = CreateMember1D(model, id, type, element1, element2); model.Member1D.Add(member); // create and return connected member ConnectedMember connectedMember = new ConnectedMember(); connectedMember.Id = id; connectedMember.MemberId = new ReferenceElement(member); return(connectedMember); }
// ad node to openModel private Point3D AddNodeToOpenModel(StructuralPointConnection conPoint, OpenModel openStructModel, int id = 0) { var pt = openStructModel.Point3D.Find(c => IsEqual(c.X, conPoint.X.GetValueOrDefault(), limits) && IsEqual(c.Y, conPoint.Y.GetValueOrDefault(), limits) && IsEqual(c.Z, conPoint.Z.GetValueOrDefault(), limits)); if (pt != null) { return(pt); } else { IdeaRS.OpenModel.Geometry3D.Point3D point = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = conPoint.X.GetValueOrDefault(), Y = conPoint.Y.GetValueOrDefault(), Z = conPoint.Z.GetValueOrDefault() }; point.Id = (id > 0 ? id : (openStructModel.GetMaxId(point) + 1)); point.Name = point.Id.ToString(); openStructModel.Point3D.Add(point); return(point); } }
public static void CreateOnServer(OpenModel model, OpenModelResult openModelResult, string path) { IdeaRS.OpenModel.OpenModelContainer openModelContainer = new OpenModelContainer() { OpenModel = model, OpenModelResult = openModelResult, }; // serialize IOM to XML var stringwriter = new System.IO.StringWriter(); var serializer = new XmlSerializer(typeof(OpenModelContainer)); serializer.Serialize(stringwriter, openModelContainer); var serviceUrl = viewerURL + "/ConnectionViewer/CreateFromIOM"; Console.WriteLine("Posting iom in xml to the service {0}", serviceUrl); var resultMessage = Helpers.PostXMLData(serviceUrl, stringwriter.ToString()); ResponseMessage responseMessage = JsonConvert.DeserializeObject <ResponseMessage>(resultMessage); Console.WriteLine("Service response is : '{0}'", responseMessage.status); if (responseMessage.status == "OK") { byte[] dataBuffer = Convert.FromBase64String(responseMessage.fileContent); Console.WriteLine("Writing {0} bytes to file '{1}'", dataBuffer.Length, path); if (dataBuffer.Length > 0) { using (FileStream fileStream = new FileStream(path , FileMode.Create , FileAccess.Write)) { fileStream.Write(dataBuffer, 0, dataBuffer.Length); } } else { Console.WriteLine("The service returned no data"); } } }
/// <summary> /// Create line segment /// </summary> /// <param name="model">Idea open model</param> /// <param name="startNode">Start node</param> /// <param name="endNode">End node</param> /// <param name="transformCoordSystem">Tranform coordinate system</param> /// <returns>Line segment 3D</returns> private static LineSegment3D CreateLineSegment3D(OpenModel model, string startNode, string endNode, bool transformCoordSystem = false) { LineSegment3D segment3D = new LineSegment3D(); segment3D.Id = model.GetMaxId(segment3D) + 1; segment3D.StartPoint = new ReferenceElement(model.Point3D.FirstOrDefault(item => item.Name == startNode)); segment3D.EndPoint = new ReferenceElement(model.Point3D.FirstOrDefault(item => item.Name == endNode)); if (transformCoordSystem) { CoordSystemByPoint system = new CoordSystemByPoint(); system.Point = new Point3D() { X = 100000, Y = 0, Z = 0 }; system.InPlane = Plane.ZX; segment3D.LocalCoordinateSystem = system; } return(segment3D); }
/// <summary> /// Add nodes to the IDEA open model /// </summary> /// <param name="model">Open model</param> private static void AddNodesToIOM(OpenModel model) { Point3D N1 = new Point3D() { X = 0, Y = 0, Z = 0 }; N1.Name = "N1"; N1.Id = 1; model.AddObject(N1); Point3D N2 = new Point3D() { X = 0, Y = 0, Z = 3 }; N2.Name = "N2"; N2.Id = 2; model.AddObject(N2); Point3D N3 = new Point3D() { X = 0, Y = 0, Z = 6 }; N3.Name = "N3"; N3.Id = 3; model.AddObject(N3); Point3D N4 = new Point3D() { X = 3, Y = 0, Z = 3 }; N4.Name = "N4"; N4.Id = 4; model.AddObject(N4); }
public static OpenModel CreateIOM() { OpenModel model = new OpenModel(); // add setting AddSettingsToIOM(model); // add nodes AddNodesToIOM(model); // add materials AddMaterialsToIOM(model); // add cross section AddCrossSectionToIOM(model); // add members 1D CreateFrameGeometry(model); // create connection CreateConnectionGeometry(model); return(model); }
public static void Main(string[] args) { Console.WriteLine("Start generate example of IOM..."); // create IOM and results OpenModel example = Example.CreateIOM(); OpenModelResult result = Helpers.GetResults(); // save to the files result.SaveToXmlFile("example.xmlR"); example.SaveToXmlFile("example.xml"); var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); #region Generatig IDEA Connection by web service Console.WriteLine("Generating IDEA Connection project by web service"); var fileConnFileNameFromWeb = Path.Combine(desktopDir, "connectionFromIOM-web.ideaCon"); Example.CreateOnServer(example, result, fileConnFileNameFromWeb); #endregion // end console application Console.WriteLine("Done. Press any key to exit."); Console.ReadKey(); }
protected void AddBeam(ElementAssembly beam, OpenModel openModel) { }
public static ObservableCollection <GenericElement> ConvertToGenericElements(ObservableCollection <ProcessUnit> processUnits) { ObservableCollection <GenericElement> elements = new ObservableCollection <GenericElement>(); try { foreach (ProcessUnit unit in processUnits) { //open models if (!string.IsNullOrEmpty(unit.OpenSolibri.File)) { elements.Add(unit.OpenSolibri); } if (unit.Models.Count > 0) { foreach (InputModel model in unit.Models) { if (model.IsUpdate) { UpdateModel updateModel = new UpdateModel(model); elements.Add(updateModel); } else { OpenModel openModel = new OpenModel(model); elements.Add(openModel); } } } if (unit.Classifications.Count > 0) { foreach (OpenClassification classification in unit.Classifications) { elements.Add(classification); } } if (unit.Rulesets.Count > 0) { foreach (OpenRuleset rule in unit.Rulesets) { elements.Add(rule); } } if (unit.CheckEnabled) { elements.Add(unit.CheckTask); if (!string.IsNullOrEmpty(unit.CheckingReport.PdfFile) || !string.IsNullOrEmpty(unit.CheckingReport.RtfFile)) { elements.Add(unit.CheckingReport); } if (unit.PresentationCreate.IsSelected) { elements.Add(unit.CommentTask); elements.Add(unit.PresentationCreate); } if (unit.PresentationUpdate.IsSelected) { elements.Add(unit.CommentTask); elements.Add(unit.PresentationUpdate); } if (!string.IsNullOrEmpty(unit.PresentationReport.PdfFile) || !string.IsNullOrEmpty(unit.PresentationReport.RtfFile)) { elements.Add(unit.PresentationReport); } if (!string.IsNullOrEmpty(unit.BCFReport.File)) { elements.Add(unit.BCFReport); } if (!string.IsNullOrEmpty(unit.CoordReport.File)) { elements.Add(unit.CoordReport); } } elements.Add(unit.SaveSolibri); elements.Add(new CloseModel()); } } catch (Exception ex) { MessageBox.Show("Failed to convert to generic elements.\n" + ex.Message, "Convert To Generic Elements", MessageBoxButton.OK, MessageBoxImage.Warning); } return(elements); }
static private OpenModel CreateConnectionGeometry(OpenModel openModel) { //Get geometrical point IdeaRS.OpenModel.Geometry3D.Point3D point = openModel.Point3D.Find(p => p.Name.Equals("N2", StringComparison.InvariantCultureIgnoreCase)); //Create a new connection point IdeaRS.OpenModel.Connection.ConnectionPoint connectionPoint = new IdeaRS.OpenModel.Connection.ConnectionPoint(); connectionPoint.Node = new ReferenceElement(point); connectionPoint.Name = point.Name; connectionPoint.Id = openModel.GetMaxId(connectionPoint) + 1; //create the new connection data var newConnectionData = new IdeaRS.OpenModel.Connection.ConnectionData(); //create list for beams newConnectionData.Beams = new List <IdeaRS.OpenModel.Connection.BeamData>(); { //member1D - column var columnMember = openModel.Member1D.Find(x => x.Id == 1); IdeaRS.OpenModel.Connection.ConnectedMember connectedColumn = new IdeaRS.OpenModel.Connection.ConnectedMember { Id = columnMember.Id, MemberId = new ReferenceElement(columnMember), IsContinuous = true, }; connectionPoint.ConnectedMembers.Add(connectedColumn); IdeaRS.OpenModel.Connection.BeamData columnData = new IdeaRS.OpenModel.Connection.BeamData { Name = "Column", Id = 1, OriginalModelId = columnMember.Id.ToString(), IsAdded = false, MirrorY = false, RefLineInCenterOfGravity = false, }; newConnectionData.Beams.Add(columnData); } { //member1D - beam IdeaRS.OpenModel.Connection.BeamData beamData = new IdeaRS.OpenModel.Connection.BeamData { Name = "Beam", Id = 2, OriginalModelId = "2", IsAdded = false, MirrorY = false, RefLineInCenterOfGravity = false, }; newConnectionData.Beams.Add(beamData); var column = openModel.Member1D.Find(x => x.Id == 2); IdeaRS.OpenModel.Connection.ConnectedMember connectedBeam = new IdeaRS.OpenModel.Connection.ConnectedMember { Id = column.Id, MemberId = new ReferenceElement(column), IsContinuous = false, }; connectionPoint.ConnectedMembers.Add(connectedBeam); } openModel.Connections.Add(newConnectionData); openModel.AddObject(connectionPoint); return(openModel); }
public static ObservableCollection <ProcessUnit> ExtractProcessUnits(Batch batch) { ObservableCollection <ProcessUnit> processUnits = new ObservableCollection <ProcessUnit>(); try { ProcessUnit unit = new ProcessUnit(); ObservableCollection <GenericElement> elements = batch.Target.Elements; for (int i = 0; i < elements.Count; i++) { GenericElement element = elements[i]; string elementType = element.GetType().Name; switch (elementType) { case "OpenModel": OpenModel openModel = element as OpenModel; if (openModel.FileExtension == ".smc") { unit.OpenSolibri = openModel; } else if (modelExtensions.Contains(openModel.FileExtension)) { InputModel modeltoOpen = new InputModel(openModel); unit.Models.Add(modeltoOpen); } break; case "UpdateModel": UpdateModel updateModel = element as UpdateModel; InputModel modeltoUpdate = new InputModel(updateModel); unit.Models.Add(modeltoUpdate); break; case "OpenRuleset": OpenRuleset ruleset = element as OpenRuleset; unit.Rulesets.Add(ruleset); break; case "OpenClassification": OpenClassification classification = element as OpenClassification; unit.Classifications.Add(classification); break; case "Check": Check check = element as Check; check.IsSpecified = true; unit.CheckTask = check; break; case "AutoComment": AutoComment comment = element as AutoComment; comment.IsSpecified = true; unit.CommentTask = comment; break; case "WriterReport": unit.CheckingReport = element as WriterReport; break; case "CreatePresentation": CreatePresentation createP = element as CreatePresentation; createP.IsSelected = true; unit.PresentationCreate = createP; break; case "UpdatePresentation": UpdatePresentation updateP = element as UpdatePresentation; updateP.IsSelected = true; unit.PresentationUpdate = updateP; break; case "GeneralReport": unit.PresentationReport = element as GeneralReport; break; case "BCFReport": unit.BCFReport = element as BCFReport; break; case "CoordinationReport": unit.CoordReport = element as CoordinationReport; break; case "SaveModel": unit.SaveSolibri = element as SaveModel; unit.TaskName = System.IO.Path.GetFileNameWithoutExtension(unit.SaveSolibri.File); break; case "CloseModel": processUnits.Add(unit); unit = new ProcessUnit(); break; } } } catch (Exception ex) { MessageBox.Show("Failed to extract process units.\n" + ex.Message, "Extract Process Unit", MessageBoxButton.OK, MessageBoxImage.Warning); } return(processUnits); }
/// <summary> /// Add load cases to the IDEA open model /// </summary> /// <param name="model">Open model</param> private static void AddLoadCasesToIOM(OpenModel model) { // create LG1 LoadGroupEC LG1 = new LoadGroupEC();; LG1.Id = 1; LG1.Name = "PERM1"; LG1.Relation = Relation.Standard; LG1.GroupType = LoadGroupType.Permanent; LG1.GammaQ = 1.35; LG1.Dzeta = 0.85; LG1.GammaGInf = 1; LG1.GammaGSup = 1.35; model.AddObject(LG1); // create LC1 LoadCase LC1 = new LoadCase(); LC1.Id = 1; LC1.Name = "SelfWeight"; LC1.LoadType = LoadCaseType.Permanent; LC1.Type = LoadCaseSubType.PermanentStandard; LC1.Variable = VariableType.Standard; LC1.LoadGroup = new ReferenceElement(LG1); // create LC2 LoadCase LC2 = new LoadCase(); LC2.Id = 2; LC2.Name = "PernamentLoading"; LC2.LoadType = LoadCaseType.Permanent; LC2.Type = LoadCaseSubType.PermanentStandard; LC2.Variable = VariableType.Standard; LC2.LoadGroup = new ReferenceElement(LG1); // create LG2 LoadGroupEC LG2 = new LoadGroupEC();; LG2.Id = 2; LG2.Name = "VAR1"; LG2.Relation = Relation.Exclusive; LG2.GroupType = LoadGroupType.Variable; LG2.GammaQ = 1.5; LG2.Dzeta = 0.85; LG2.GammaGInf = 0; LG2.GammaGSup = 1.5; LG2.Psi0 = 0.7; LG2.Psi1 = 0.5; LG2.Psi2 = 0.3; model.AddObject(LG2); // create LC3 LoadCase LC3 = new LoadCase(); LC3.Id = 3; LC3.Name = "LiveLoad"; LC3.LoadType = LoadCaseType.Variable; LC3.Type = LoadCaseSubType.VariableStatic; LC3.Variable = VariableType.Standard; LC3.LoadGroup = new ReferenceElement(LG2); // add load cases model.AddObject(LC1); model.AddObject(LC2); model.AddObject(LC3); }
/// <summary> /// Add nodes to the IDEA open model /// </summary> /// <param name="model">Open model</param> private static void AddNodesToIOM(OpenModel model) { Point3D N1 = new Point3D() { X = -2, Y = 3, Z = 0 }; N1.Name = "N1"; N1.Id = 1; model.AddObject(N1); Point3D N2 = new Point3D() { X = -2, Y = 3, Z = 3 }; N2.Name = "N2"; N2.Id = 2; model.AddObject(N2); Point3D N3 = new Point3D() { X = 2, Y = 3, Z = 0 }; N3.Name = "N3"; N3.Id = 3; model.AddObject(N3); Point3D N4 = new Point3D() { X = 2, Y = 3, Z = 3 }; N4.Name = "N4"; N4.Id = 4; model.AddObject(N4); Point3D N5 = new Point3D() { X = 6, Y = 3, Z = 0 }; N5.Name = "N5"; N5.Id = 5; model.AddObject(N5); Point3D N6 = new Point3D() { X = 6, Y = 3, Z = 3 }; N6.Name = "N6"; N6.Id = 6; model.AddObject(N6); Point3D N7 = new Point3D() { X = -2, Y = 3, Z = 6 }; N7.Name = "N7"; N7.Id = 7; model.AddObject(N7); Point3D N8 = new Point3D() { X = 2, Y = 3, Z = 6 }; N8.Name = "N8"; N8.Id = 8; model.AddObject(N8); Point3D N9 = new Point3D() { X = 6, Y = 3, Z = 6 }; N9.Name = "N9"; N9.Id = 9; model.AddObject(N9); }
static private OpenModel CreateConnectionGeometry(OpenModel openModel) { //Add connection point IdeaRS.OpenModel.Connection.ConnectionPoint connection = new IdeaRS.OpenModel.Connection.ConnectionPoint(); IdeaRS.OpenModel.Geometry3D.Point3D point = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 3, Z = 3 }; point.Id = openModel.GetMaxId(point) + 1; point.Name = point.Id.ToString(); openModel.Point3D.Add(point); connection.Node = new ReferenceElement(point); connection.Name = point.Name; connection.Id = openModel.GetMaxId(connection) + 1; //add connection openModel.Connections.Add(new IdeaRS.OpenModel.Connection.ConnectionData()); //add Beams openModel.Connections[0].Beams = new List <IdeaRS.OpenModel.Connection.BeamData>(); //member1D 1 IdeaRS.OpenModel.Connection.BeamData beam1Data = new IdeaRS.OpenModel.Connection.BeamData { Name = "M1", Id = 1, OriginalModelId = "1", IsAdded = false, MirrorY = false, RefLineInCenterOfGravity = false, }; openModel.Connections[0].Beams.Add(beam1Data); var member1 = openModel.Member1D.Find(x => x.Id == 1); IdeaRS.OpenModel.Connection.ConnectedMember conMb = new IdeaRS.OpenModel.Connection.ConnectedMember { Id = member1.Id, MemberId = new ReferenceElement(member1), IsContinuous = false, }; connection.ConnectedMembers.Add(conMb); //member1D 3 var member3 = openModel.Member1D.Find(x => x.Id == 3); IdeaRS.OpenModel.Connection.ConnectedMember conMb3 = new IdeaRS.OpenModel.Connection.ConnectedMember { Id = member3.Id, MemberId = new ReferenceElement(member3), IsContinuous = true, }; connection.ConnectedMembers.Add(conMb3); IdeaRS.OpenModel.Connection.BeamData beam2Data = new IdeaRS.OpenModel.Connection.BeamData { Name = "M3", Id = 3, OriginalModelId = member3.Id.ToString(), IsAdded = false, MirrorY = false, RefLineInCenterOfGravity = false, }; openModel.Connections[0].Beams.Add(beam2Data); openModel.AddObject(connection); //add plate IdeaRS.OpenModel.Connection.PlateData plateData = new IdeaRS.OpenModel.Connection.PlateData { Name = "P1", Thickness = 0.02, Id = 11, Material = "S355", OriginalModelId = "11", Origin = new IdeaRS.OpenModel.Geometry3D.Point3D { X = -1.87, Y = 2.88, Z = 2.7 }, AxisX = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = 1, Z = 0 }, AxisY = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = 0, Z = 1 }, AxisZ = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 1, Y = 0, Z = 0 }, Region = "M 0 0 L 0.24 0 L 0.24 0.5 L 0 0.5 L 0 0", }; (openModel.Connections[0].Plates ?? (openModel.Connections[0].Plates = new List <IdeaRS.OpenModel.Connection.PlateData>())).Add(plateData); // add cut openModel.Connections[0].CutBeamByBeams = new List <IdeaRS.OpenModel.Connection.CutBeamByBeamData> { new IdeaRS.OpenModel.Connection.CutBeamByBeamData { CuttingObject = new ReferenceElement(plateData), ModifiedObject = new ReferenceElement(beam1Data), Orientation = CutOrientation.Parallel, WeldType = WeldType.DoubleFillet, IsWeld = true, } }; IdeaRS.OpenModel.Connection.BoltGrid boltGrid = new IdeaRS.OpenModel.Connection.BoltGrid() { Id = 41, ConnectedPartIds = new List <string>(), Diameter = 0.016, HeadDiameter = 0.024, DiagonalHeadDiameter = 0.026, HeadHeight = 0.01, BoreHole = 0.018, TensileStressArea = 157, NutThickness = 0.013, AnchorLen = 0.05, Material = "8.8", Standard = "M 16", }; boltGrid.Origin = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = plateData.Origin.X, Y = plateData.Origin.Y, Z = plateData.Origin.Z }; boltGrid.AxisX = new IdeaRS.OpenModel.Geometry3D.Vector3D() { X = plateData.AxisX.X, Y = plateData.AxisX.Y, Z = plateData.AxisX.Z }; boltGrid.AxisY = new IdeaRS.OpenModel.Geometry3D.Vector3D() { X = plateData.AxisY.X, Y = plateData.AxisY.Y, Z = plateData.AxisY.Z }; boltGrid.AxisZ = new IdeaRS.OpenModel.Geometry3D.Vector3D() { X = plateData.AxisZ.X, Y = plateData.AxisZ.Y, Z = plateData.AxisZ.Z }; boltGrid.Positions = new List <IdeaRS.OpenModel.Geometry3D.Point3D> { new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.87, Y = 2.92, Z = 2.8 }, new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.87, Y = 3.08, Z = 2.8 }, new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.87, Y = 2.92, Z = 3.15 }, new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.87, Y = 3.08, Z = 3.15 } }; boltGrid.ConnectedPartIds = new List <string>() { beam2Data.OriginalModelId, plateData.OriginalModelId }; (openModel.Connections[0].BoltGrids ?? (openModel.Connections[0].BoltGrids = new List <IdeaRS.OpenModel.Connection.BoltGrid>())).Add(boltGrid); //add plate 2 IdeaRS.OpenModel.Connection.PlateData plateData2 = new IdeaRS.OpenModel.Connection.PlateData { Name = "P2", Thickness = 0.02, Id = 12, Material = "S355", OriginalModelId = "12", Origin = new IdeaRS.OpenModel.Geometry3D.Point3D { X = -2.103, Y = 2.88, Z = 2.75 }, AxisX = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 1, Y = 0, Z = 0 }, AxisY = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = 1, Z = 0 }, AxisZ = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = 0, Z = 1 }, Region = "M 0 0 L 0.206 0 L 0.206 0.105 L 0.195 0.115 L 0.011 0.115 L 0.0 0.105 L 0 0", }; (openModel.Connections[0].Plates ?? (openModel.Connections[0].Plates = new List <IdeaRS.OpenModel.Connection.PlateData>())).Add(plateData2); //add weld between memeber 2 and plate 2 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData = new IdeaRS.OpenModel.Connection.WeldData() { Id = 31, ConnectedPartIds = new List <string>() { plateData2.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 2.995, Z = 2.76 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 2.995, Z = 2.76 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; (openModel.Connections[0].Welds ?? (openModel.Connections[0].Welds = new List <IdeaRS.OpenModel.Connection.WeldData>())).Add(weldData); //add weld3 between memeber 2 and plate 2 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData3 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 33, ConnectedPartIds = new List <string>() { plateData2.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2.103, Y = 2.90, Z = 2.76 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2.103, Y = 2.90, Z = 2.76 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData3); //add weld4 between memeber 2 and plate 2 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData4 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 34, ConnectedPartIds = new List <string>() { plateData2.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.897, Y = 2.90, Z = 2.76 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.897, Y = 2.90, Z = 2.76 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData4); //add plate 3 IdeaRS.OpenModel.Connection.PlateData plateData3 = new IdeaRS.OpenModel.Connection.PlateData { Name = "P3", Thickness = 0.02, Id = 13, Material = "S355", OriginalModelId = "13", Origin = new IdeaRS.OpenModel.Geometry3D.Point3D { X = -2.103, Y = 2.88, Z = 3.1 }, AxisX = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 1, Y = 0, Z = 0 }, AxisY = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = 1, Z = 0 }, AxisZ = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = 0, Z = 1 }, Region = "M 0 0 L 0.206 0 L 0.206 0.105 L 0.195 0.115 L 0.011 0.115 L 0.0 0.105 L 0 0", }; openModel.Connections[0].Plates.Add(plateData3); //add weld between memeber 2 and plate 3 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData2 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 32, ConnectedPartIds = new List <string>() { plateData3.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 2.995, Z = 3.11 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 2.995, Z = 3.11 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData2); //add weld5 between memeber 2 and plate 3 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData5 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 35, ConnectedPartIds = new List <string>() { plateData3.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2.103, Y = 2.90, Z = 3.11 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2.103, Y = 2.90, Z = 3.11 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData5); //add weld6 between memeber 2 and plate 3 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData6 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 36, ConnectedPartIds = new List <string>() { plateData3.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.897, Y = 2.90, Z = 3.11 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.897, Y = 2.90, Z = 3.11 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData6); //add plate 4 IdeaRS.OpenModel.Connection.PlateData plateData4 = new IdeaRS.OpenModel.Connection.PlateData { Name = "P4", Thickness = 0.02, Id = 14, Material = "S355", OriginalModelId = "14", Origin = new IdeaRS.OpenModel.Geometry3D.Point3D { X = -2.103, Y = 3.12, Z = 2.75 }, AxisX = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 1, Y = 0, Z = 0 }, AxisY = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = -1, Z = 0 }, AxisZ = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = 0, Z = 1 }, Region = "M 0 0 L 0.206 0 L 0.206 0.105 L 0.195 0.115 L 0.011 0.115 L 0.0 0.105 L 0 0", }; openModel.Connections[0].Plates.Add(plateData4); //add weld7 between memeber 2 and plate 4 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData7 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 37, ConnectedPartIds = new List <string>() { plateData4.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 3.005, Z = 2.76 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 3.005, Z = 2.76 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData7); //add weld8 between memeber 2 and plate 4 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData8 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 38, ConnectedPartIds = new List <string>() { plateData4.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2.103, Y = 3.1, Z = 2.76 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2.103, Y = 3.1, Z = 2.76 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData8); //add weld9 between memeber 2 and plate 4 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData9 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 39, ConnectedPartIds = new List <string>() { plateData4.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.897, Y = 3.1, Z = 2.76 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.897, Y = 3.1, Z = 2.76 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData9); //add plate 5 IdeaRS.OpenModel.Connection.PlateData plateData5 = new IdeaRS.OpenModel.Connection.PlateData { Name = "P5", Thickness = 0.02, Id = 15, Material = "S355", OriginalModelId = "15", Origin = new IdeaRS.OpenModel.Geometry3D.Point3D { X = -2.103, Y = 3.12, Z = 3.1 }, AxisX = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 1, Y = 0, Z = 0 }, AxisY = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = -1, Z = 0 }, AxisZ = new IdeaRS.OpenModel.Geometry3D.Vector3D { X = 0, Y = 0, Z = 1 }, Region = "M 0 0 L 0.206 0 L 0.206 0.105 L 0.195 0.115 L 0.011 0.115 L 0.0 0.105 L 0 0", }; openModel.Connections[0].Plates.Add(plateData5); //add weld10 between memeber 2 and plate 5 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData10 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 40, ConnectedPartIds = new List <string>() { plateData5.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 3.005, Z = 3.11 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2, Y = 3.005, Z = 3.11 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData10); //add weld11 between memeber 2 and plate 5 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData11 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 41, ConnectedPartIds = new List <string>() { plateData5.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2.103, Y = 3.10, Z = 3.11 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -2.103, Y = 3.10, Z = 3.11 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData11); //add weld12 between memeber 2 and plate 5 - stiffener IdeaRS.OpenModel.Connection.WeldData weldData12 = new IdeaRS.OpenModel.Connection.WeldData() { Id = 46, ConnectedPartIds = new List <string>() { plateData5.OriginalModelId, beam2Data.OriginalModelId }, Start = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.897, Y = 3.10, Z = 3.11 }, End = new IdeaRS.OpenModel.Geometry3D.Point3D() { X = -1.897, Y = 3.10, Z = 3.11 }, Thickness = 0.004, WeldType = IdeaRS.OpenModel.Connection.WeldType.DoubleFillet, }; openModel.Connections[0].Welds.Add(weldData12); return(openModel); }
public static void Main(string[] args) { IdeaInstallDir = IOM.SteelFrameDesktop.Properties.Settings.Default.IdeaInstallDir; if (!Directory.Exists(IdeaInstallDir)) { Console.WriteLine("IDEA StatiCa installation was not found in '{0}'", IdeaInstallDir); return; } Console.WriteLine("IDEA StatiCa installation directory is '{0}'", IdeaInstallDir); Console.WriteLine("Select the required example"); Console.WriteLine("1 - Steel frame ECEN"); Console.WriteLine("2 - Simple frame AUS"); var option = Console.ReadLine(); OpenModel iom = null; OpenModelResult iomResult = null; if (option.Equals("2", StringComparison.InvariantCultureIgnoreCase)) { Console.WriteLine("Generating Australian steel frame ..."); // create IOM and results iom = SimpleFrameAUS.CreateIOM(); iomResult = null; } else { Console.WriteLine("Generating ECEN steel frame ..."); // create IOM and results iom = SteelFrameExample.CreateIOM(); iomResult = Helpers.GetResults(); } string iomFileName = "example.xml"; string iomResFileName = "example.xmlR"; // save to the files iom.SaveToXmlFile(iomFileName); if (iomResult != null) { iomResult.SaveToXmlFile(iomResFileName); } else { iomResFileName = string.Empty; } var desktopDir = Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory); var fileConnFileNameFromLocal = Path.Combine(desktopDir, "connectionFromIOM-local.ideaCon"); var calcFactory = new ConnHiddenClientFactory(IdeaInstallDir); var client = calcFactory.Create(); try { // it creates connection project from IOM Console.WriteLine("Creating Idea connection project "); client.CreateConProjFromIOM(iomFileName, iomResFileName, fileConnFileNameFromLocal); Console.WriteLine("Generated project was saved to the file '{0}'", fileConnFileNameFromLocal); } catch (Exception e) { Console.WriteLine("Error '{0}'", e.Message); } finally { if (client != null) { client.Close(); } } // end console application Console.WriteLine("Done. Press any key to exit."); Console.ReadKey(); }
/// <summary> /// 支付 /// </summary> public ActionResult Pay() { //订单id int oid = WebHelper.GetQueryInt("oid"); //订单信息 OrderInfo orderInfo = Orders.GetOrderByOid(oid); if (orderInfo == null || orderInfo.OrderState != (int)OrderState.WaitPaying) { return(Redirect("/mob")); } string code = Request.QueryString["code"]; if (string.IsNullOrEmpty(code)) { string code_url = string.Format("https://open.weixin.qq.com/connect/oauth2/authorize?appid={0}&redirect_uri={1}&response_type=code&scope=snsapi_base&state=lk#wechat_redirect", PayConfig.AppId, string.Format("http://{0}/mob/wechat/pay?oid=" + oid, BSPConfig.ShopConfig.SiteUrl)); LogUtil.WriteLog("code_url:" + code_url); return(Redirect(code_url)); } LogUtil.WriteLog(" ============ 开始 获取微信用户相关信息 ====================="); #region 获取支付用户 OpenID================ string url = string.Format("https://api.weixin.qq.com/sns/oauth2/access_token?appid={0}&secret={1}&code={2}&grant_type=authorization_code", PayConfig.AppId, PayConfig.AppSecret, code); string returnStr = HttpUtil.Send("", url); LogUtil.WriteLog("Send 页面 returnStr 第一个:" + returnStr); OpenModel openModel = JsonConvert.DeserializeObject <OpenModel>(returnStr); url = string.Format("https://api.weixin.qq.com/sns/oauth2/refresh_token?appid={0}&grant_type=refresh_token&refresh_token={1}", PayConfig.AppId, openModel.refresh_token); returnStr = HttpUtil.Send("", url); openModel = JsonConvert.DeserializeObject <OpenModel>(returnStr); LogUtil.WriteLog("Send 页面 access_token:" + openModel.access_token); LogUtil.WriteLog("Send 页面 openid=" + openModel.openid); //url = string.Format("https://api.weixin.qq.com/sns/userinfo?access_token={0}&openid={1}", obj.access_token, obj.openid); //returnStr = HttpUtil.Send("", url); //LogUtil.WriteLog("Send 页面 returnStr:" + returnStr); #endregion LogUtil.WriteLog(" ============ 结束 获取微信用户相关信息 ====================="); LogUtil.WriteLog("============ 单次支付开始 ==============="); #region 支付操作============================ #region 基本参数=========================== //商户订单号 string outTradeNo = orderInfo.Oid.ToString() + Randoms.CreateRandomValue(10, false); //订单名称 string subject = BSPConfig.ShopConfig.SiteTitle + "购物"; //付款金额 string totalFee = ((int)(orderInfo.SurplusMoney * 100)).ToString(); //openId string openId = openModel.openid; //时间戳 string timeStamp = TenpayUtil.getTimestamp(); //随机字符串 string nonceStr = TenpayUtil.getNoncestr(); //服务器异步通知页面路径 string notifyUrl = string.Format("http://{0}/mob/wechat/notify", BSPConfig.ShopConfig.SiteUrl); LogUtil.WriteLog("totalFee" + totalFee); //创建支付应答对象 RequestHandler packageReqHandler = new RequestHandler(System.Web.HttpContext.Current); //初始化 packageReqHandler.init(); //设置package订单参数 具体参数列表请参考官方pdf文档,请勿随意设置 packageReqHandler.setParameter("body", subject); //商品信息 127字符 packageReqHandler.setParameter("appid", PayConfig.AppId); packageReqHandler.setParameter("mch_id", PayConfig.MchId); packageReqHandler.setParameter("nonce_str", nonceStr.ToLower()); packageReqHandler.setParameter("notify_url", notifyUrl); packageReqHandler.setParameter("openid", openId); packageReqHandler.setParameter("out_trade_no", outTradeNo); //商家订单号 packageReqHandler.setParameter("spbill_create_ip", Request.UserHostAddress); //用户的公网ip,不是商户服务器IP packageReqHandler.setParameter("total_fee", totalFee); //商品金额,以分为单位(money * 100).ToString() packageReqHandler.setParameter("trade_type", "JSAPI"); //if (!string.IsNullOrEmpty(this.Attach)) // packageReqHandler.setParameter("attach", this.Attach);//自定义参数 127字符 #endregion #region sign=============================== string sign = packageReqHandler.CreateMd5Sign("key", PayConfig.AppKey); LogUtil.WriteLog("WeiPay 页面 sign:" + sign); #endregion #region 获取package包====================== packageReqHandler.setParameter("sign", sign); string data = packageReqHandler.parseXML(); LogUtil.WriteLog("WeiPay 页面 package(XML):" + data); string prepayXml = HttpUtil.Send(data, "https://api.mch.weixin.qq.com/pay/unifiedorder"); LogUtil.WriteLog("WeiPay 页面 package(Back_XML):" + prepayXml); //获取预支付ID string prepayId = ""; string package = ""; XmlDocument xdoc = new XmlDocument(); xdoc.LoadXml(prepayXml); XmlNode xn = xdoc.SelectSingleNode("xml"); XmlNodeList xnl = xn.ChildNodes; if (xnl.Count > 7) { prepayId = xnl[7].InnerText; package = string.Format("prepay_id={0}", prepayId); LogUtil.WriteLog("WeiPay 页面 package:" + package); } #endregion #region 设置支付参数 输出页面 该部分参数请勿随意修改 ============== RequestHandler paySignReqHandler = new RequestHandler(System.Web.HttpContext.Current); paySignReqHandler.setParameter("appId", PayConfig.AppId); paySignReqHandler.setParameter("timeStamp", timeStamp); paySignReqHandler.setParameter("nonceStr", nonceStr); paySignReqHandler.setParameter("package", package); paySignReqHandler.setParameter("signType", "MD5"); string paySign = paySignReqHandler.CreateMd5Sign("key", PayConfig.AppKey); LogUtil.WriteLog("WeiPay 页面 paySign:" + paySign); #endregion #endregion Dictionary <string, string> model = new Dictionary <string, string>(); model.Add("oid", orderInfo.Oid.ToString()); model.Add("timeStamp", timeStamp); model.Add("nonceStr", nonceStr); model.Add("package", package); model.Add("paySign", paySign); return(PartialView("~/plugins/BrnShop.PayPlugin.WeChat/views/wechat/pay.cshtml", model)); }
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); } }