【问题标题】:Controlling Numeric Parameters from a UserForm Window in Inventor从 Inventor 中的用户窗体窗口控制数值参数
【发布时间】:2020-06-09 06:15:09
【问题描述】:

我需要帮助。我想使用“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

【问题讨论】:

    标签: vba autodesk autodesk-inventor


    【解决方案1】:

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

    您可以将值转换为厘米

    oDrop.Value = TextBox1 / 10
    

    或设置参数Expression(字符串),可以指定单位或使用默认文档单位

    oDrop.Expression = TextBox1 & "mm" ' With units [mm]
    oDrop.Expression = TextBox1 ' Default document units
    

    【讨论】:

    • 谢谢!!优雅的解决方案。我在参数表中除以 10。我不知道可以做什么。
    【解决方案2】:

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

    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
    

    【讨论】:

      猜你喜欢
      • 2014-02-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-11
      • 1970-01-01
      • 2012-06-07
      • 1970-01-01
      相关资源
      最近更新 更多