我正在研究 vba CATIA,我正在尝试创建一个用于翻译操作的函数。但是在将函数的输出分配给对象时出现错误。
期待解决方案。
提前致谢!!
Function CreateTranslate(source As Object, value As Double, direction As Double)
Set partDocument1 = CATIA.ActiveDocument
Set part1 = partDocument1.Part
If direction = 1 Then
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(1#, 0#, 0#)
Else
If direction = 2 Then
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(0#, 1#, 0#)
Else
If direction = 3 Then
Set hybridShapeFactory1 = part1.HybridShapeFactory
Set hybridShapeDirection1 = hybridShapeFactory1.AddNewDirectionByCoord(0#, 0#, 1#)
End If
End If
End If
Set CreateTranslate = hybridShapeFactory1.AddNewEmptyTranslate()
Set reference1 = part1.CreateReferenceFromObject(source)
CreateTranslate.ElemToTranslate = reference1
CreateTranslate.direction = hybridShapeDirection1
CreateTranslate.DistanceValue = value
End Function
调用函数:
Set result_of_translate = hybridShapeFactory1.AddNewEmptyTranslate()
result_of_translate = CreateTranslate(Kotfl, 0, 1)