Created
August 12, 2015 19:02
-
-
Save selimb/9ec1a723a46fdbccba3a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void DoIt() | |
{ | |
NXOpen.CAE.Iteration iteration; | |
NXOpen.CAE.BaseResultType[] resultTypes; | |
NXOpen.CAE.BaseResultType velocity, shStress, turbEnergy, turbDiss; | |
// NXOpen.CAE.Result.Quantity qtt; | |
iteration = (Iteration)this.solutionResult.GetLoadcases()[0].GetIterations()[0]; | |
resultTypes = iteration.GetResultTypes(); | |
foreach (NXOpen.CAE.BaseResultType resultType in resultTypes) | |
{ | |
// this.WriteLine("Result Type: " + resultType.ToString()); | |
// this.WriteLine("Quantity: " + resultType.Quantity.ToString()); | |
if (resultType.Quantity == QTT.Velocity) | |
{ | |
this.CreateVelocityGraph(resultType); | |
} | |
if (resultType.Quantity == QTT.ShearStressOnPositiveSide) | |
{ | |
this.CreateShStressGraph(resultType); | |
} | |
if (resultType.Quantity == QTT.TurbulenceEnergy) | |
{ | |
this.CreateTurbEnergyGraph(resultType); | |
} | |
if (resultType.Quantity == QTT.TurbulentSpecificDissipation) | |
{ | |
this.CreateTurbDissGraph(resultType); | |
} | |
} | |
} | |
private void CreateVelocityGraph(NXOpen.CAE.BaseResultType resultType) | |
{ | |
NXOpen.CAE.CaeGroup groupe; | |
NXOpen.CAE.ResultParameters resultParams; | |
NXOpen.CAE.PostGraph postGraph; | |
NXOpen.Point3d origin, unitVector; | |
this.WriteLine("Creating Velocity Profile..."); | |
origin = new NXOpen.Point3d(0.0, 0.0, 0.0); | |
unitVector = new NXOpen.Point3d(0.0, 0.0, 1.0); | |
groupe = this.GetGroupByName("x097"); | |
resultParams = this.resultMgr.CreateResultParameters(); | |
resultParams.SetResultComponent(NXOpen.CAE.Result.Component.X); | |
resultParams.SetGenericResultType(resultType); | |
resultParams.SetUnit(this.unitCollection.GetBase("Velocity")); | |
string title = "Velocity profile"; | |
this.WriteLine(" Graph Title: " + title); | |
this.WriteLine(" Unit: " + resultParams.GetUnit().Abbreviation); | |
postGraph = (NXOpen.CAE.PostGraph)this.CreateGraph( | |
resultParams, | |
title, | |
origin, | |
unitVector, | |
groupe | |
); | |
} | |
private void CreateShStressGraph(NXOpen.CAE.BaseResultType resultType) | |
{ | |
NXOpen.CAE.CaeGroup groupe; | |
NXOpen.CAE.ResultParameters resultParams; | |
NXOpen.CAE.PostGraph postGraph; | |
NXOpen.Point3d origin, unitVector; | |
this.WriteLine("Creating Shear Stress on +ve side Graph..."); | |
origin = new NXOpen.Point3d(0.0, 0.0, 0.0); | |
unitVector = new NXOpen.Point3d(1.0, 0.0, 0.0); | |
groupe = this.GetGroupByName("PlateCenter"); | |
resultParams = this.resultMgr.CreateResultParameters(); | |
resultParams.SetGenericResultType(resultType); | |
resultParams.SetResultComponent(NXOpen.CAE.Result.Component.Scalar); | |
resultParams.SetUnit(this.unitCollection.GetBase("Stress")); | |
this.WriteLine(" Unit: " + resultParams.GetUnit().Abbreviation); | |
string title = "Shear Stress on wall"; | |
this.WriteLine(" Title: " + title); | |
postGraph = (NXOpen.CAE.PostGraph)this.CreateGraph( | |
resultParams, | |
title, | |
origin, | |
unitVector, | |
groupe | |
); | |
} | |
private void CreateTurbEnergyGraph(NXOpen.CAE.BaseResultType resultType) | |
{ | |
NXOpen.CAE.CaeGroup groupe; | |
NXOpen.CAE.ResultParameters resultParams; | |
NXOpen.CAE.PostGraph postGraph; | |
NXOpen.Point3d origin, unitVector; | |
this.WriteLine("Creating Turbulence Energy Graph..."); | |
origin = new NXOpen.Point3d(0.0, 0.0, 0.0); | |
unitVector = new NXOpen.Point3d(0.0, 0.0, 1.0); | |
groupe = this.GetGroupByName("x097"); | |
resultParams = this.resultMgr.CreateResultParameters(); | |
resultParams.SetGenericResultType(resultType); | |
resultParams.SetResultComponent(NXOpen.CAE.Result.Component.Scalar); | |
resultParams.SetUnit( | |
this.unitCollection.GetBase("Energy per Unit Mass") | |
); | |
// Testing | |
NXOpen.CAE.ResultAccess resAc = this.resultMgr.CreateResultAccess(this.solutionResult, resultParams); | |
this.resultMgr.DeleteResultAccess(resAc); | |
// Testing | |
this.WriteLine(" Unit: " + resultParams.GetUnit().Abbreviation); | |
string title = "Turbulence energy profile"; | |
this.WriteLine(" Title: " + title); | |
postGraph = (NXOpen.CAE.PostGraph)this.CreateGraph( | |
resultParams, | |
title, | |
origin, | |
unitVector, | |
groupe | |
); | |
} | |
private void CreateTurbDissGraph(NXOpen.CAE.BaseResultType resultType) | |
{ | |
NXOpen.CAE.CaeGroup groupe; | |
NXOpen.CAE.ResultParameters resultParams; | |
NXOpen.CAE.PostGraph postGraph; | |
NXOpen.Point3d origin, unitVector; | |
this.WriteLine("Creating Turbulence Dissipation Graph..."); | |
origin = new NXOpen.Point3d(0.0, 0.0, 0.0); | |
unitVector = new NXOpen.Point3d(0.0, 0.0, 1.0); | |
groupe = this.GetGroupByName("x097"); | |
resultParams = this.resultMgr.CreateResultParameters(); | |
resultParams.SetGenericResultType(resultType); | |
resultParams.SetResultComponent(NXOpen.CAE.Result.Component.Scalar); | |
resultParams.SetUnit(this.unitCollection.GetBase("Frequency")); | |
this.WriteLine(" Unit: " + resultParams.GetUnit().Abbreviation); | |
string title = "Turbulence Dissipation Profile"; | |
this.WriteLine(" Title: " + title); | |
postGraph = (NXOpen.CAE.PostGraph)this.CreateGraph( | |
resultParams, | |
title, | |
origin, | |
unitVector, | |
groupe | |
); | |
} |
@micampbell If you want to get an array of numbers from a ResultParameters
, you'll have to go through the ResultAccess
class, which you can create like so:
NXOpen.CAE.ResultAccess resAc = this.resultMgr.CreateResultAccess(
this.solutionResult, resultParams
);
ResultAccess
has a bunch of Ask*Result
methods. You'll have to use the correct one based on the result location (which you can query with AskResultLocation
.
Hope this helps.
thanks for getting back to me. I'll have a look.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hey @micampbell . Apologies for the delay... You'll find the code for
CreateGraph
below:Although it doesn't look like this is what you wanted.