cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

We are working to address an issue with subscription email notifications. In the meantime, be sure to check your favorite boards for new topics.

Units conversion to SI

JB_10220769
7-Bedrock

Units conversion to SI

After embedding excel component within worksheet when an input is provided the excel convert it to SI system if the unit system is set to USCS any suggestions? 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions

Internally Prime stores the values in SI units, regardless of the unit system chosen.

When the data is transferred to Excel (which does not support units), this unit is simply omitted.

To send the data you intend to Excel you simply have to get rid of the unit yourself by dividing by the correct unit.

The same is done in reverse when you transfer data calculated by Excel back to Mathcad - you multiply with the appropriate unit.

Werner_E_0-1648584621206.png

 

 

 

View solution in original post

7 REPLIES 7

Internally Prime stores the values in SI units, regardless of the unit system chosen.

When the data is transferred to Excel (which does not support units), this unit is simply omitted.

To send the data you intend to Excel you simply have to get rid of the unit yourself by dividing by the correct unit.

The same is done in reverse when you transfer data calculated by Excel back to Mathcad - you multiply with the appropriate unit.

Werner_E_0-1648584621206.png

 

 

 

Hi @JB_10220769,

 

Try this little program:

SPauliszyn_1-1657304544301.png

 

If you use ORIGIN=0 (the default), change "2" to a "1" and the index on the bottom outside of the big parenthesis from a "1" to a "0".

 

For any units that you commonly use in your input tables, US and SI, enter them as strings in the first column as you might enter them in a cell in Excel.  The second column in the matrix is the unit as Mathcad understands it.

 

Now when you try to use a string that is recognized in your list, the unit will be properly added to your value.  If the unit label is not recognized, it will simply return the value.  

 

So when I have a HUGE Excel data table like this:

 

SPauliszyn_5-1657305259373.png

 

 

I add the unit labels to a row in the data table (row 2 in this example).  Then when I import the data, I run a simple program that will go row by row and column by column, attempting to convert the values to 'unit values' by using the unit in the units row (row 2 in this case).  I would get something like this:

 

SPauliszyn_3-1657305086271.png

So once all the values have units, it doesn't matter if I do a calculation for a Canadian or US project, Mathcad handles all the conversions (after this point) beautifully.

 

Hope this might help you

 

 

 

 

LucMeekes
23-Emerald III
(To:SPauliszyn)

"If you use ORIGIN=0 (the default), change "2" to a "1" and the index on the bottom outside of the big parenthesis from a "1" to a "0".":

 

I'd suggest to change "2" to "ORIGIN+1" and the index from "1" to "ORIGIN".

Then the function should work as intended for any value of ORIGIN. Note that while ORIGIN is generally chosen as either 0 or 1, it can be set to other values, like -1, or 17.

 

Success!
Luc

Good suggestion @LucMeekes .  Since I keep these functions in separate included sheets, I can make this more versatile for anyone in my company using this.

 

I never thought of using ORIGIN as a simple variable (I have for TOL).  Thanks for the nudge one step further.  😁

LucMeekes
23-Emerald III
(To:SPauliszyn)

You're welcome.

Note that you should set ORIGIN (if ever you want to change it from its default value...) ONLY at the very top of the worksheet (or using the menu), before any other definition; and you should NEVER set ORIGIN in any included sheet.

The definition of str2unit uses the value of ORIGIN known at the point of definition, if you change the value of ORIGIN below the definition of the str2unit function you will get unexpected results when calling the function further down the sheet.

 

Success!
Luc

Yup, that’s exactly how it should be done @LucMeekes. It was present to make sure that it was considered for the user function, but with your suggestion it becomes redundant.


Except you could set it globally at the end of the document as long as it is ahead of other global functions that rely on it.  I like to put my mundane global functions at the end of the document--kind of like an appendix.  That just the way I do it but by no means has to be the standard—it’s a matter of taste😉.  I'm using Prime 8 btw.

 

If in the wrong order...

SPauliszyn_2-1657323126899.png

But if the correct order... success:

SPauliszyn_3-1657323148118.png

 

Oops.  I had second thoughts and I checked one of my sheets (i'm updating my sheets with your suggestion).  So I was lying @LucMeekes.  Forgive me please?

 

I did set the ORIGIN inside of one of my included sheets:

SPauliszyn_0-1657323616582.png

 

And here is my definitions in my main calculation set:

SPauliszyn_3-1657323902811.png

 

But watch what happens when I change the order:

SPauliszyn_2-1657323788270.png

 

Fortunately Mathcad was simply ignoring the ORIGIN declaration in the attached sheet so I never got an error.  The ORIGIN global declaration in the attached sheet is simply redundant.

 

Top Tags