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

Community Tip - New to the community? Learn how to post a question and get help from PTC and industry experts! X

Unit Conversion

pwilliams-3
12-Amethyst

Unit Conversion

Does anyone know how in Pro/TOOLKIT to take a number value in meters and convert it to inches? I don't want to hard code all sorts of conversion factors and was hoping to use ProUnitConverstionGet() but I'm confused as to how this function works. Technical support isn't very helpful either.

Patrick Williams | Engineering Systems | o: 616.698.3766 | c: 616.947.2110
[cid:image001.jpg@01CD64EB.AAE15A40]


This thread is inactive and closed by the PTC Community Management Team. If you would like to provide a reply and re-open this thread, please notify the moderator and reference the thread. You may also use "Start a topic" button to ask a new question. Please be sure to include what version of the PTC product you are using so another community member knowledgeable about your version may be able to assist.
5 REPLIES 5

Hi Patrick -

I took a quick look at the documentation for this:

> Does anyone know how in Pro/TOOLKIT to take a number value in meters
> and convert it to inches? I don’t want to hard code all sorts of
> conversion factors and was hoping to use ProUnitConverstionGet()
> but I’m confused as to how this function works.

I would suggest testing ProMdlUnitsCollect() on one of your models
and see what comes back. You could then try ProUnitInit() to retrieve
a unit by name, then try ProUnitConversionGet() to retrieve the scale
and offset values to convert between that unit and the Pro/Engineer
standard unit system, which appears (sadly) to be Inches/Pounds/Seconds.

I also looked for other C++ libraries and found Boost Units:

A few months ago, I had to use these routines to replace the Pro/DEVELOP
routines. I found they had less functionality. There were no #defines for
the different unit conversions. I placed a call to tech support but I don't
believe it resulted in an SPR.

Bob

Bob Monat
Jerand Technical Services, Inc.
bob@jerand.com
www.jerand.com
1-317-875-6087


FV
17-Peridot
17-Peridot
(To:pwilliams-3)

Hi all,


Patric,


You were heading in the right direction. ProUnitConversionGet will eventually trace unit conversion to Inch-Pound-Second which is Pro/E default.The sequence of function calls as follows:


Init unit, or access it with ProMdlPrincipalUnitsystemGet, ( writing by memory, check function spelling)


ProUnitInit( mdl, L"mm", &mm_unit);


ProUnitInit( mdl, L"m", &m_unit);


ProUnitInit( mdl, L"cm", &cm_unit);


Then use ProUnitConversionGet, such as:


ProUnitConversionGet( &mm_unit, &convert_factor, &base_unit);


then check what is base_unit. If it is not inch, then call ProUnitConversionGet recursively until you end up at inches.


ProUnitConversionGet( &base_unit, &base_convert_factor, &basebase_unit);


HIH.


Feliks.






In Reply to Patrick Williams:


Does anyone know how in Pro/TOOLKIT to take a number value in meters and convert it to inches? I don't want to hard code all sorts of conversion factors and was hoping to use ProUnitConverstionGet() but I'm confused as to how this function works. Technical support isn't very helpful either.

Patrick Williams | Engineering Systems | o: 616.698.3766 | c: 616.947.2110
[cid:image001.jpg@01CD64EB.AAE15A40]

Bipin,
This example works well but as Feliks said it will only eventually convert the unit into inches. I have a use case where I need to go the other direction inches to millimeters. It seems that the Pro/ENGINEER UI can do this but the Pro/TOOLKIT doesn't contain an API to do this.

Patrick Williams | Engineering Systems | o: 616.698.3766 | c: 616.947.2110
[cid:image001.jpg@01CD65BF.0E7AF330]

Hi @ all,


but when you get out the conversion faktor and use (1 / conv_factor) and get this in as new conv.factor. The output should be the right converted unit?


Only problem is on temperature with the offset problem.


Best regards,


Eike

Announcements


Top Tags