代码的总体目标是能够在 Autodesk Inventor 中通过扫描功能从 Microsoft Access 中选择的节点坐标生成模型管道,这些坐标已被导入 Excel,因此 Excel 充当“中间-男人”。换句话说,尝试将 Excel 连接到 Inventor 以从 Excel 导入坐标。
我创建的现有代码将根据节点坐标和手动手动输入 VBA 的弯曲值生成管道。
我曾多次尝试将 Excel 连接到 Inventor,但均未成功。我在下面展示的最有希望的一个,旨在选择一个 excel 文件,尽管我尝试从单元格 A5 中提取值并将其插入到我手动估算的坐标中不起作用。
我尝试过的其他方法包括导入点(事实证明 API 不支持这一点)和操作以下链接中的代码:
但是,无济于事。
'Set up 3D sketch
Dim Sketch2 As Sketch3D
Set Sketch2 = partDef.Sketches3D.Add
'Identify File address path
Dim Path1 As String
Path1 = InputBox("Enter Excel file Path e.g C:\SapWorkDir\Inventor\UpdateOpen.xlsx", "Excel file Path")
' Get the Excel file
Dim Excel As Excel.Application
Dim wb As Workbook
Dim ws As WorkSheet
Set Excel = New Excel.Application'Set wb = Excel.Workbooks.Open(Path1)
Set ws = wb.Sheets(1)
Dim Test As Integer
Test = ws.Range("A5").Select
'input coordinate values (CURRENTLY MANUAL)
Dim oCoor(1 To 8) As WorkPoint
Set oCoor(1) = partDef.WorkPoints.AddFixed(tg.CreatePoint(0, 0, 0))
Set oCoor(2) = partDef.WorkPoints.AddFixed(tg.CreatePoint(100, 100, 0))
Set oCoor(3) = partDef.WorkPoints.AddFixed(tg.CreatePoint(100, 50, 30))
Set oCoor(4) = partDef.WorkPoints.AddFixed(tg.CreatePoint(200, 700, 30))
Set oCoor(5) = partDef.WorkPoints.AddFixed(tg.CreatePoint(600, 700, 70))
Set oCoor(6) = partDef.WorkPoints.AddFixed(tg.CreatePoint(600, 700, 500))
Set oCoor(7) = partDef.WorkPoints.AddFixed(tg.CreatePoint(600, 900, 500))
Set oCoor(8) = partDef.WorkPoints.AddFixed(tg.CreatePoint(600, 2000, 500))
'
这种方法显然不起作用,因为我无法将值“A5”调用到我手动输入的任何坐标值中。
我假设我无法通过这种方法连接到 Excel,那么有人知道怎么做吗?