请忍受我对 CATIA VBA 的有限知识。我在自定义 CATIA V5 宏以浏览 Excel 坐标点并在 CATIA 中绘制它时遇到了一些困难,只需单击自定义的 CATIA 图标即可。
- 我有一个带有许多 XYZ 坐标的 Excel 文件,我们称之为 ExcelP1(Excel 文件中没有脚本/宏),我想在 CATIA 中开发一个宏来从 ExcelP1 读取和绘制点。
目前我有另一个“带有宏的 Excel 文件”来浏览 ExcelP1,并在 CATIA 中绘制点。但我需要先打开并运行“带有宏的 Excel 文件”来启动 CATIA。脚本如下(我没有开发这个)
Public Filename As String Private Sub Browse_Click() 'Open File Mainform.Hide Filename = Application.GetOpenFilename("Excel Files (*.xls), *.xls") If Filename <> "False" Then Application.Visible = False filenamebox.Value = Filename Else Application.Visible = False Filename = filenamebox.Value End If Mainform.Show End Sub Private Sub ClearButton_Click() Mainform.Hide ActiveWorkbook.Close (False) Application.Visible = False End Sub Private Sub OKButton_Click() 'Set Up Message Labels Title = "Information Message" 'Check for Entered Values If filenamebox.Value <> "" Then Workbooks.Open Filename:=Filename Application.Visible = False 'Start CATIA and add an Open body to the document Start_CATIA Mainform.Hide 'Read Point Data from file and create point in CATIA i = 2 Do Until Worksheets("Sheet1").Range("a" & i).Value = "" x = Worksheets("Sheet1").Range("a" & i).Value y = Worksheets("Sheet1").Range("b" & i).Value z = Worksheets("Sheet1").Range("c" & i).Value Create_Point i = i + 1 Loop i = i - 2 MsgBox i & " Points Created in New Part", , Title Else MsgBox "Enter a Filename", , Title End If ActiveWorkbook.Close (False) Mainform.Show End Sub Private Sub UserForm_Initialize() If Worksheets("Filepath_Location").Range("a1").Value <> "" Then Filename = Worksheets("Filepath_Location").Range("a1").Value filenamebox.Value = Filename End If End Sub
为了让脚本在 CATIA 中运行,我需要添加/修改什么?