0

我需要帮助。我想使用“UserForms”来控制“Inventor”部分的一些参数的值,但是已经走到了死胡同。对于初学者,我有一个 TextBox 和 CommandButton 以及一些以 mm 为单位的数字参数 Drope,它们是在发明者参数表中创建的。我设法访问了这个参数,但我无法使用 UserForms 更改它。我该怎么做?提前致谢。 在此处输入图像描述

Public Sub okbtn1_Click()

    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument

    Dim userParams As UserParameters
    Set userParams = partDoc.ComponentDefinition.Parameters.UserParameters

    Dim oDrope As Parameter
    Set oDrope = userParams.Item("Drope")
    Drope = TextBox1

    End
End Sub
4

2 回答 2

0

参数值始终以厘米为单位,因为这是 Inventor 内部单位。

您可以将值转换为厘米

oDrop.Value = TextBox1 / 10

或设置参数表达式(字符串),您可以在其中指定单位或使用默认文档单位

oDrop.Expression = TextBox1 & "mm" ' With units [mm]
oDrop.Expression = TextBox1 ' Default document units
于 2020-03-03T11:59:23.413 回答
0

找到了解决方案,但输入的值以厘米为单位。我正在寻找以 mm 为单位指定它的方法。

Private Sub CmdButtonOk2_Click()

    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument

    Dim userParams As UserParameters
    Set userParams = partDoc.ComponentDefinition.Parameters.UserParameters

    Dim oDrope As Parameter
    Set oDrope = userParams.Item("Drope")
    oDrope.Value = TxtBox2

    End

End Sub
于 2020-02-25T14:11:52.840 回答