如何添加您的知识

管理零件配置

    内容表格
    No headers

    现在,我们将介绍本教程开头所列出的最后两个话题:

    • 从嵌入式电子表单中读取数据。
    • 设置特征和零部件活动。

    iLogic 可以提供从 Excel 电子表单中读取信息的内置函数。在“系统”选项卡的“代码段”区域中,通过展开“Excel 数据链接”节点即可找到这些函数。

    在本课程中,我们将撰写这样一个规则:基于指定尺寸使用嵌入式 Excel 电子表单中的值为用于控制端口几何图元的参数设定值。规则会在电子表格中查找端口尺寸来确定值所在的行。然后从该行中读取字段来获取相应的参数值。

    三通样式块中包含三个端口。每个端口都在“参数”对话框中列出。但是,在“参数”对话框中更改端口尺寸并不会更改模型中的端口尺寸。我们必须添加规则来驱动端口尺寸的变化。

    第一步就是添加用于设定端口尺寸和每个端口周围螺钉阵列尺寸的规则。在部件中使用螺钉阵列将凸缘固定到块上。

    1. Autodesk Inventor 模型浏览器中,展开树中的“第三方软件”
    2. “嵌入 1”上单击鼠标右键,然后选择“编辑”来访问嵌入的电子表单。
    3. 添加名为 port_size_rule 的规则,然后单击“确定”打开“编辑规则”对话框。

      规则必须要做的第一件事就是在电子表单中找到包含 Port A 所用的值的行。我们要在标签为 port_size 的列中查找与 port_a_size 参数匹配的值。

    4. 在对话框的“系统”选项卡上的“代码段”区域中,找到“Excel 数据链接”节点中标签为“FindRow (嵌入)”的函数。双击该函数将其插入文本区域中。

      复制代码块

      i = GoExcel.FindRow(“3rd Party:Embedding 1”, “Sheet1”, “columnName”, “<=”, 0.2)
    5. 向规则中插入此函数模板后,将 columnName 的第一个引用替换为 port_size,将“<=”的第一个引用替换为“=”,将 0.2 替换为 port_a_size

      复制代码块

      i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port_a_size)

      此代码表示我们要在嵌入式电子表单中找到 port_size 列与 port_a_size 参数值相等的行。

    6. 基于电子表单中此行的单元格的值添加一系列参数。这些参数控制着端口直径、钻孔深度以及螺栓孔之间的距离。使用“代码段”区域的“Excel 数据链接”节点中标签为 CurrentRowValue 的函数。

      复制代码块

       i = GoExcel.CurrentRowValue("columnName")

      如此处所示,编辑代码段副本。

      复制代码块

      port_a_y_dist_between_screw = GoExcel.CurrentRowValue("y_dist_between_screw")
      port_a_x_dist_between_screw = GoExcel.CurrentRowValue("x_dist_between_screw")
      port_a_port_dia = GoExcel.CurrentRowValue("port_dia")
      Port_A_Drill_Depth = GoExcel.CurrentRowValue("tap_drill_depth")
      注意请记住,您可以选择“编辑规则”对话框的“模型”选项卡中的项目来显示各组模型参数。
    7. 若要定义螺纹孔的螺纹,请在“代码段”区域的“特征”节点中插入标签为 ThreadDesignation 的特征。

      复制代码块

      Feature.ThreadDesignation("featurename") = “3/8-16 UNC”

      如此处所示,修改文本。

      复制代码块

      Feature.ThreadDesignation("Port_A_Threads") = GoExcel.CurrentRowValue("tap_dim")

      我们已经说明,应该使用 tap_dim 单元来获取螺栓孔的螺纹规格。

    8. 现在关于端口 A 参数的说明已经完成,请创建端口 B 和端口 C 的说明。复制所创建的规则文本并粘贴两次。在粘贴的第一个副本中,将 port_a 参考更改为 port_b。在粘贴的第二个副本中,将 port_a 参考更改为 port_c。现在,您便建立了三个代码块,每个代码块分别与三个端口之一有关联。

      复制代码块

      i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port_a_size)
      port_a_y_dist_between_screw = GoExcel.CurrentRowValue("y_dist_between_screw")
      port_a_x_dist_between_screw = GoExcel.CurrentRowValue("x_dist_between_screw")
      port_a_port_dia = GoExcel.CurrentRowValue("port_dia")
      Port_A_Drill_Depth = GoExcel.CurrentRowValue("tap_drill_depth")
      Feature.ThreadDesignation("Port_A_Threads") = GoExcel.CurrentRowValue("tap_dim")
      
      i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port_b_size)
      port_b_y_dist_between_screw = GoExcel.CurrentRowValue("y_dist_between_screw")
      port_b_x_dist_between_screw = GoExcel.CurrentRowValue("x_dist_between_screw")
      port_b_port_dia = GoExcel.CurrentRowValue("port_dia")
      Port_B_Drill_Depth = GoExcel.CurrentRowValue("tap_drill_depth")
      Feature.ThreadDesignation("Port_B_Threads") = GoExcel.CurrentRowValue("tap_dim")
      
      i = GoExcel.FindRow("3rd Party:Embedding 1", "Sheet1", "port_size", "=", port_c_size)
      port_c_y_dist_between_screw = GoExcel.CurrentRowValue("y_dist_between_screw")
      port_c_x_dist_between_screw = GoExcel.CurrentRowValue("x_dist_between_screw")
      port_c_port_dia = GoExcel.CurrentRowValue("port_dia")
      Port_C_Drill_Depth = GoExcel.CurrentRowValue("tap_drill_depth")
      Feature.ThreadDesignation("Port_C_Threads") = GoExcel.CurrentRowValue("tap_dim")
    9. 单击 iLogic 规则编辑器中的“确定”来保存您的 port_size_rule。您的模型可能会更新,也可能不更新,具体取决于 iLogic 端口尺寸参数的初始设定方式。

    上一页 | 下一页