Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Dual dimensions in general table

1 REPLY 1
Reply
Message 1 of 2
ksturner.01
758 Views, 1 Reply

Dual dimensions in general table

When creating a general table that includes model parameters ie lengths widths etc.  is it possible to get the table to apply dual units?  For example have it display mm [in] like 50,8mm as 50,8 [2.0] as in the drawing?  We are making alot of iparts and this would save us time rather than entering the extra units manually.

Inventor 2011 Pro
Intel Core I7 3.07GHz
8GB RAM
Win 7 64-bit
1 REPLY 1
Message 2 of 2
bobvdd
in reply to: ksturner.01

You could duplicate the column and set different units on the duplicated column or you could run attached macro that I have put together.

 

Before you run the macro, select a table first and make sure to change the headertext string "Column 4" to whatever the column you want to treat is called.

 

Sub dual_units_table()
Dim altprecision  As Integer
altprecision = 3
Dim headertext As String
headertext = "Column 4"

Dim odoc As DrawingDocument
Set odoc = ThisApplication.ActiveDocument
Dim ohtable As CustomTable

'Get the UNits of measure
Dim uom As UnitsOfMeasure
Set uom = odoc.UnitsOfMeasure

'get the default units as defined in teh standard
Dim ounits As UnitsTypeEnum
ounits = odoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle.LinearUnits

'get the default alternate units
Dim oaltunits As UnitsTypeEnum
oaltunits = odoc.StylesManager.ActiveStandardStyle.ActiveObjectDefaults.LinearDimensionStyle.AlternateLinearUnits

Dim sAltLengthUnit As String
sAltLengthUnit = uom.GetStringFromType(oaltunits)

'Select a bend table first
On Error Resume Next
If Not TypeOf odoc.SelectSet.Item(1) Is CustomTable Then
    MsgBox "A table must be selected first."
    Exit Sub
Else
    Set ohtable = odoc.SelectSet.Item(1)
End If

Dim column As column
Dim index As Integer
Dim i As Integer
index = 0
i = 1

For Each column In ohtable.Columns

    If column.Title = headertext Then
        index = i
        Exit For
    Else
        i = i + 1
    End If
Next column

If index > 0 Then
 Dim row As row
 For Each row In ohtable.Rows
    Dim pos As Integer
    pos = InStr(row.Item(index).value, "[")
    If pos > 0 Then row.Item(index).value = Left(row.Item(index).value, pos - 1)
    Dim value As Double
    value = uom.GetValueFromExpression(row.Item(index).value, ounits)
    Dim altvalue As Double
    altvalue = Int(uom.ConvertUnits(value, kCentimeterLengthUnits, oaltunits) * 10 ^ altprecision) / 10 ^ altprecision
    row.Item(index).value = row.Item(index).value + "[" + Str(altvalue) + " " + sAltLengthUnit + "]"
 Next row
End If
ohtable.Update
End Sub

 

Cheers

bob 




Bob Van der Donck


Principal UX designer DMG group

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report