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

Community Tip - Learn all about the Community Ranking System, a fun gamification element of the PTC Community. X

How to get length unit of a model via VB API

Gennaro
4-Participant

How to get length unit of a model via VB API

Hi,

i have an IpfcModel object and i want to know, via vb api, its lenght unit (mm or inch).

Is possible to do it?

Thanks

1 REPLY 1

Just figured this out using VBA. You need to use ipfcSolid.GetPrincipalUnits:

 

Option 1:

Dim model As IpfcModel

Set model = session.CurrentModel

Dim SolidMdl As IpfcSolid

Set SolidMdl = model 'Convert to IpfcSolid to get units

Dim UnitSys As IpfcUnitSystem

Set UnitSys = SolidMdl.GetPrincipalUnits

MsgBox UnitSys.Name

MsgBox UnitSys.GetUnit(EpfcUNIT_LENGTH).Name

 

Option 2:

Dim model As IpfcModel

Set model = session.CurrentModel

Dim SolidMdl As IpfcSolid

Set SolidMdl = model 'Convert to IpfcSolid to get units

MsgBox SolidMdl.GetPrincipalUnits.GetUnit(EpfcUNIT_LENGTH).Name

 

Options for GetUnit:

• EpfcUNIT_LENGTH—Specifies length measurement units.
• EpfcUNIT_MASS—Specifies mass measurement units.
• EpfcUNIT_FORCE—Specifies force measurement units.
• EpfcUNIT_TIME—Specifies time measurement units.
• EpfcUNIT_TEMPERATURE—Specifies temperature measurement units.
• EpfcUNIT_ANGLE—Specifies angle measurement units.

Announcements


Top Tags