Language="VBSCRIPT" '因为本操作系统是 windows2000,所以 此宏是用'vbscript编 写的
Sub CATMain()
Dim partDocument1 As Document '创建文件
Set partDocument1 = CATIA.ActiveDocument
Dim part1 As Part '创建部件
Set part1 = partDocument1.Part
dim excel as object ' 调用excel对象
set excel=getobject("d: \外形数据.xls") '飞机外形数据存于d: \外形数据.xls文'件下
'利用循环,读入excel中的数据。此数据为飞机外形上的一些点的坐标值,这些'值分别存于excel的表单1中的B、C、D中,把这些值分别赋给变量x,y,z
i=1
do while x<>””
x=excel.worksheets(1).cells.range("B" & trim(cstr(i))).value
y=excel.worksheets(1).cells.range("C" & trim(cstr(i))).value
z=excel.worksheets(1).cells.range("D" & trim(cstr(i))).value
·
·
·
'定义点坐标
Dim hybridShapePointCoord1 As HybridShapePointCoord
Set hybridShapePointCoord1 = hybridShapeFactory1.AddNewPointCoord(x,y,z)
·
·
·
'输入点
hybridBody1.AppendHybridShape hybridShapePointCoord1
part1.InWorkObject = hybridShapePointCoord1
i=i+1
loop
part1.Update
End sub