Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations waross on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Journal: export results of analysis in a xls file ? 1

Status
Not open for further replies.

bastiensegond

Aerospace
Jul 5, 2011
21
FR
Hi,

How can I create a journal to export results of analysis (.sim file) in a Excel file?

NX 7.5.4
VB.NET


Thanks. Bastien.
 
Replies continue below

Recommended for you

Bastien,

I gathered a couple example VB programs and a test model for you. Both of these programs use custom UI. One relies on a DLX and uses standard NX UI created with the Block UI Styler application.

I tried to upload the examples to this post, but I was getting errors. If my attachments failed, try the ftp link below. This requires a Siemens PLM WebKey account to download.

ftp://ftp.ugs.com/scratch/NXOpenResultsAccessExamples.zip

The first example queries all thermal solution sets in a SIM and returns the temperature on a user selected element. The program is limited to selection of the element by ID and it processes 1 element at a time. The program could be enhanced to improve element selection and support multiple elements as input.

Run ProbeAllSolutions.vb in the provided SIM file. It outputs data to the Info window like the following:

---------------------
Getting Element ID and Units from User...

Element: 3570

You have not specified units for the results. The Default units are Celsius.
Units: Celsius

Thermal, Load Case 1, Iteration 1, 549.91

Thermal2, Load Case 1, Iteration 1, 554.936

ThermalStress, No Elemental Temperature Results Found.

---------------------

The second program deforms a mesh based upon displacement results from a selected solution set and step (assuming multiple steps in the solution).

Run DeformMeshFromSolutionResults.vb from the provided SIM file and you will be asked to select a solution/step from a list of applicable solution sets. The example SIM has 2 thermal solution sets and 1 linear statics solution set. So the program only lists the linear statics solution set - the thermal solves have no displacement results. The dialog for this program was created with the Block UI Styler application.

Further to your questions about exporting data to EXCEL, here are some suggestions from our NX Open experts. The example journals do touch on some of these items.

The API does have commands for you to:

1. Access and query results at any node or element.
a. NXOpen.CAE.ResultAccess.AskNodalResult
b. NXOpen.CAE.ResultAccess.AskElementNodalResult

2. Get all Elements or nodes in a mesh:
a. NXOpen.UF.UFSf.LocateElement
b. NXOpen.UF.UFSf.LocateNodesOnMesh

3. Get the entities in a group:
a. NXOpen.CAE.CaeGroup.GetEntities

4. Read/Write to/from Excel:
a. Link to the Microsoft.Office.Interop.Excel library.
b. I believe that there are some capabilities from the NX api. NXOpen.UF.UFXs appears relevant, but not very friendly, updated or capable. The Microsoft library would be a much better choice.


Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
Mark,


thank you for your very comprehensive answer. It helps me a lot.

Do you know how I can extract only the max value of a displacement, of a constraint or a rotation?

Regards. Bastien.
 
Bastien,

I'm glad you were able to retrieve the data.

We have an Envelope Results NX Open routine that I believe first worked in NX 6.0.1. However since you are running NX 7.5.4, you can take advantage of the fully supported envelope results capability in NX CAE post processing. Look for the "Results Manipulation" command on the post processing toolbar. Or use Command Finder with that string and it will launch the command if you have a results file loaded. The What's New in NX 7.5.2 documentation discusses this new feature.

The Envelope capability lets you sort across multiple load cases, iterations, and solutions (i.e. results files) to determine the overall max/min at each location in the model. It operates on scalar data, meaning you can sort components of vectors and tensors, magnitudes of vectors, and invariants of tensors to produce a scalar output. It will not produce a sorted vector or tensor output. For shells and beams you must specify the sorted location since the output will not be multi-valued (top OR bottom of a shell, but not both).

We have a development project to extend support in this area to include full units support (unknown scalar data is output now) and complete data reduction that will let you create results from expressions using components such as RESULT = DISPX*DISPY*SIGMAZ where DISP represents displacement and SIGMA represents stress.

If you have any particular needs in the area of post processing data reduction, I'd appreciate your input. Now is the perfect time for it as we move forward with this project. You can provide information here or through enhancement requests via GTAC.

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
Mark,


Can you take a look at my journal.

I want to extract the maximum stress of my loadcase with the function AskMaximum.

For the moment I'm able to extract only the max displacement. I try to change "Magnitude" by "VonMises" and change the number of "loadCaseIdx" and "iterationIdx", but when I run my journal I have a error message.

-------------------------------------------------

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpen.BlockStyler


Module Module2



Dim theSession As Session = Session.GetSession()
Dim theLW As NXOpen.ListingWindow = theSession.ListingWindow()
Dim theUI As NXOpen.UI = NXOpen.UI.GetUI()
Dim theNXMessageBox As NXMessageBox = theUI.NXMessageBox


Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theLW As NXOpen.ListingWindow
theLW = theSession.ListingWindow()

theLW.Open()
Doit()

End Sub

Sub Doit()

Dim nom_loadcase As String
Dim resultParameters1 As CAE.ResultParameters
Dim theSession As Session = Session.GetSession()
Dim resultManager1 As CAE.ResultManager = theSession.ResultManager
Dim simPart As CAE.SimPart = CType(theSession.Parts.BaseWork, CAE.SimPart)
Dim simulation As CAE.SimSimulation = simPart.Simulation()
Dim workSimPart As CAE.SimPart = CType(theSession.Parts.BaseWork, CAE.SimPart)
Dim solution As CAE.SimSolution = simulation.ActiveSolution()
Dim results As CAE.Result = GetResults(solution)
Dim scale As Double = 1.0
Dim loadCaseIdx As Integer = 0
Dim iterationIdx As Integer = 0
Dim resultAccess As CAE.ResultAccess = GetResultAccess(results, loadCaseIdx, iterationIdx, scale)
Dim noeud_result As Double = resultAccess.AskMaximum
Dim Msg, Stl, Ttle
Msg = noeud_result
Stl = vbOKOnly
Ttle = "Bastien"
MsgBox(Msg, Stl, Ttle)

End Sub

Function GetResultAccess(ByRef results As CAE.Result, ByVal loadCaseIdx As Integer, ByVal iterationIdx As Integer, ByVal scale As Double) As CAE.ResultAccess

Dim part As BasePart = theSession.Parts.BaseWork
Dim theResultManager As CAE.ResultManager = theSession.ResultManager()
Dim unit_length As Unit = Nothing
Dim resultParameter As CAE.ResultParameters = theResultManager.CreateResultParameters()
Dim resultType As CAE.Result.Type
Dim averaging As CAE.Result.Averaging

averaging.DoAveraging = False
averaging.AverageAcrossPropertyIds = True
averaging.AverageAcrossMaterialIds = True
averaging.AverageAcrossElementTypes = True
averaging.AverageAcrossFeatangle = True
averaging.AverageAcrossAnglevalue = 45.0
averaging.IncludeInternalElementContributions = True

resultParameter.SetLoadcaseIteration(loadCaseIdx, iterationIdx)
resultParameter.SetResultType(resultType)
resultParameter.SetResultComponent(CAE.Result.Component.Magnitude)
resultParameter.SetSectionPlyLayer(0, 0, 0)
resultParameter.SetAveragingCriteria(averaging)
resultParameter.SetCoordinateSystem(CAE.Result.CoordinateSystem.AbsoluteRectangular)
resultParameter.SetElementValueCriterion(CAE.Result.ElementValueCriterion.Average)
resultParameter.SetComplexCriterion(CAE.Result.Complex.Amplitude)
resultParameter.SetPhaseAngle(0.0)
resultParameter.SetScale(scale)
resultParameter.SetUnit(unit_length)
Dim solResultsAccess As CAE.ResultAccess = theResultManager.CreateResultAccess(results, resultParameter)
solResultsAccess.SetParameters(resultParameter)

Return solResultsAccess

End Function

Function GetResults(ByRef solution As CAE.SimSolution) As CAE.Result

Dim results As CAE.Result = Nothing
Dim part As BasePart = theSession.Parts.BaseWork
Dim theResultManager As CAE.ResultManager = theSession.ResultManager()
Dim solresults As CAE.SolutionResult = theResultManager.CreateSolutionResult(solution)

results = CType(solresults, CAE.Result)

Return results

End Function


End Module



-----------------------------------------------


Regards. Bastien.

 
Bastien,

To get to the next load case, you increment loadCaseIdx from zero to one. Leave iterationIdx set to 0 if your solution set has no iterations. Mine was a linear statics solution with 2 load cases. It worked for me with this one edit.

Getting to the stresses is proving to be a pain for me. You are kinda lucking out here with respect to displacements as the results calls are defaulting (I think) to the first result (i.e. displacements). I'll have to reply again as I don't have an answer for the call to the stresses yet. It is all related to:

Dim results As CAE.Result = GetResults(solution)
Dim solution As CAE.SimSolution = simulation.ActiveSolution()
Dim results As CAE.Result = GetResults(solution)
Dim resultAccess As CAE.ResultAccess = GetResultAccess(results, loadCaseIdx, iterationIdx, scale)
Function GetResultAccess
Dim resultParameter As CAE.ResultParameters = theResultManager.CreateResultParameters()
resultParameters.SetLoadcaseIteration(loadCaseIdx, iterationIdx)
Dim resultType As CAE.Result.Type

Here you can specify the type and maybe you have to elsewhere... again I'm no developer but trying to learn from examples too.

resultType.Quantity = CAE.Result.Quantity.Stress
resultType.Location = CAE.Result.Location.ElementNodal
resultType.Section = CAE.Result.Section.Maximum
resultParameter.SetResultType(resultType)
resultParameter.SetResultComponent(CAE.Result.Component.VonMises)

Notice the qualifiers on resultType.

I'm on a 4 day weekend, so maybe you'll have this solved before I get back this Tuesday.

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
Mark,

Thank you for your answers. Next week I leave for training for eight weeks. So I would work on the subject of journal on my return in early November.

Bastien.
 
Bastien,

I was able to create 3 VB scripts from your original one. These output maximum von Mises stress for beam, shell, or solid element models. If you have a mix of element types in a single model, then you'd have to sort through the meshes and use the appropriate method for the given mesh type. So, to use these, create models of only 1 element type and then run the appropriate script.


Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
Mark,

Thank you for your answer, the program works correctly. I'm just trying to change to get the max stress in a group. I leave this evening for eight weeks training then I would resume the subject of journals on my return on November 7. Thank you very much for your help and soon.

Bastien.
 
Mark,

Do you know if is it possible to extract max strain in a group? I don't know if is it possible with the function AskMaximum.

Regards.
Bastien.
 
Bastien,

I sure hope so. That was going to be the next thing on my list of items to try. For my beam/shell/solid model I want to identify the maximum stress on the beams, and on the shells, and on the solids all rolled up in one program. At least I have 8 weeks to get you an answer. Enjoy your training!

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
Mark,

Thank you very much for your help. I throw a glance at the forum during my training.

Regards.

Bastien.
 
Hi there, Mark,

Apologies in advance for steering this thread away from its original intent.

I was reading your first reply in this thread and I'm curious about the part where you say that the mesh can be deformed according to the results of an analysis. Is this purely so that the deformed mesh can be used for subsequent analyses or would there be a way to take this deformed mesh and export it as solid/sheet geometry, either to a .prt file or some other format? I am curious because having an 'as deformed' version of a part would be useful to us, on occasion.

Thanks,

Jon

JHTH
NX 7.0.1.7 + TC 2007
 
Jon,

The first response refers to just deforming the mesh. NX supports deformation of CAD data too though. NX 7.5 delivered a new (or updated... can't remember) command in Modeling called Global Deformation. I believe Global Deformation requires a "Die Engineering" license. It may be available through other add-ons as well. Here are characteristics of Global Deformation:

1. Operates on sheet bodies

Don't let that dissuade you. NX can convert solids into sheets with zero free edges. This is really an artificial limitation.

2. Accepts 2 "points" files as input (undeformed/deformed)

There must be a 1-1 correspondence between points in the files.

3. Produces a new sheet body by transforming the selected body from one set of points to the second set of points

NX is able to convert the sheet body back to a solid if needed too.

First I'll describe the manual process of deforming CAD data with Global Deformation. With respect to CAE, the points files are generated from node locations. The first points file is the undeformed nodes. The 2nd points file adds the displacements to the node locations to get the deformed points. NX can output node locations through post processing simply as XYZ location through the Identify command. It also outputs the displacements. The user can then take this data into EXCEL to produce multiple text files for input to Global Deformation.

I uploaded an NX 7.5 Open program that automates the process described above. Here is the program's description from the README file in the attachment:

This program will display a dialog to allow the user to choose a displacement result from one of the solutions in the current simulation. They will also choose the desired outcome - deforming the part and/or exporting data files containing product and sprung point data.

Optional input is the specification of a scaling factor and the deformation box grid size for the global deformation operation.

The code will extract the coordinates of each node and the displacement at each node from the results file. The displacements are added to the coordinates to produce the deformed coordinates.

I also uploaded example data that contains a deformed sheet body from the analysis model. I generated the deformed sheet body from the NX Open program.

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
 http://files.engineering.com/getfile.aspx?folder=7a1260bf-7a39-464d-92f9-d92ce2f9758a&file=DeformedBody.zip
Good morning, Mark, and many thanks for the thoroughness of your post!

I followed the description you gave and it looks like it could be useful to us, though we'll have to weigh up the benefits and number of times we'd use it per year against the cost to buy and maintain the Deformation licence...

Thanks again,

Jon

JHTH
NX 7.0.1.7 + TC 2007
 
Jon,

I got a reply from development regarding licensing of the Global Deformation command. It is available as part of the Advanced Free Form module. Bundles that include Advanced Free Form would be able to access Global Deformation. Additionally it is part of the Die Engineering module.

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
Hi, Mark,

Is the Advanced Free Form module known as nx_freeform_2, as far as the contents of our bundles are concerned? We've got that as part of our licence so that could be an easy way in.

Thanks,

Jon

JHTH
NX 7.0.1.7 + TC 2007
 
Jon,

You are correct... at least my simple test says so. I created a new PRT and poked on the Global Deformation command. Then I checked the LMTOOLS licensing LOG file:

8:15:13 (ugslmd) OUT: "gateway" gelampin@cii6p137
8:22:54 (ugslmd) OUT: "solid_modeling" gelampin@cii6p137
8:23:10 (ugslmd) OUT: "nx_freeform_2" gelampin@cii6p137

Global Deformation checked out the NX_freeform_2 license.

Regards,
Mark

Mark Lamping
CAE Technical Consultant
Siemens PLM Software
 
Perfect, we've got that built into our FEA and CAM bundles. As soon as I get some time to experiment with this (which realistically may be some time around the middle of 2014) I'll have a go and let you know how it went.

Thanks again,

Jon

JHTH
NX 7.0.1.7 + TC 2007
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Top