Cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted

Extracting Units from Sim File

Creator
Creator

Hello Team,

 

Is there anyway to extract Output File Units i.e. Force, Length and Mass available in solution. I have trired the below API to extract and it works fine when  solver is Nastran but fails when solver is ANSYS. Can help me out to solve this.

 

soln = workSimPart.Simulation.ActiveSolution

soln.PropertyTable.GetStringPropertyValue("Mass")

 

Please see the attched for more info.

 

 

 

 

6 REPLIES 6

Re: Extracting Units from Sim File

Legend
Legend

Hello Saddam_Ali,

 

Have you tried recording the action and then look into the recorded code?

 

You need to know which String to feed to the 'GetStringPropertyValue' api in the case of ANSYS.

 

While it is called "Mass" in Nastran, it's probably called something different in ANSYS.

 

Regards,

Frederik

Re: Extracting Units from Sim File

Legend
Legend

I recorded the action:

 

I'm not familiar with the ANSYS specifics in NX, but it looks like the units are set via an integer.

 

Dim caeDataContainer1 As NXOpen.CAE.CaeDataContainer = Nothing
caeDataContainer1 = theSession.CaeSession.GetDataContainer()

caeDataContainer1.AddInteger("units", 8)

If you look at the screenshot, the unit I selected ((N)(mm)(tonne)) is the 9th listed. Given the 0 based indexing, I assume that you specify the units via the integer and that you can choose from the list in the screenshot.

 

Regards,

Frederik

 

 

Re: Extracting Units from Sim File

Creator
Creator

Thnaks for the reply,

 

Dim caeDataContainer1 As NXOpen.CAE.CaeDataContainer = Nothing
caeDataContainer1 = theSession.CaeSession.GetDataContainer()

caeDataContainer1.AddInteger("units", 8

But the above api will set the units of solution what I requred is to get the units of the active solution. IS there any way I can extarct units from ACtive existing solution.

 

Thanks

Re: Extracting Units from Sim File

Legend
Legend

Hello Saddam_Ali,

 

I think 

Dim IntegerForUnits As Integer = caeDataContainer1.GetInteger("units")

is what you are looking for.

 

Regards,

Frederik

Re: Extracting Units from Sim File

Creator
Creator

Yes I am looking for some thing like this. But CaeDataconatiner is not linked  in any way with solution. 

 

This will only work when we set some value. Is there any way to get existing data conayiner from solution?

Dim IntegerForUnits As Integer = caeDataContainer1.GetInteger("units")

 

Thanks

 

Re: Extracting Units from Sim File

Legend
Legend

Hello Saddam_Ali,

 

This block of code will show you the IntegerPropertyValue:

        Dim theSession As NXOpen.Session = NXOpen.Session.GetSession()
        Dim workSimPart As NXOpen.CAE.SimPart = CType(theSession.Parts.BaseWork, NXOpen.CAE.SimPart)

        Dim simSimulation1 As NXOpen.CAE.SimSimulation = CType(workSimPart.FindObject("Simulation"), NXOpen.CAE.SimSimulation)

        Dim simSolution1 As NXOpen.CAE.SimSolution = CType(simSimulation1.FindObject("Solution[Solution 1]"), NXOpen.CAE.SimSolution)

        Dim theLW As ListingWindow = theSession.ListingWindow()
        theLW.Open()
        Dim MyString As String = Nothing
        For ii As Integer = 0 To 1000
            Try
                MyString = simSolution1.SolverOptionsPropertyTable.GetPropertyNameByIndex(ii)
                theLW.WriteFullline(MyString & "= " & simSolution1.SolverOptionsPropertyTable.GetIntegerPropertyValue(MyString))
            Catch ex As Exception

            End Try
        Next

Changing the units, you will notice the change in Output File Units= 1

You can do similar things for StringPropertyValue, GetScalarPropertyValue,...

 

Hope this answers your question.

 

Regards,

Frederik