Hi
I dont understand why everytime i run this script catia crashes.
i try to instantiate a CATPart and then move it (essentially a axis-axis snap) to a previously defined axis system.
If i record a macro and run it, it works fine.
Any advice would be nice.
Thanks
Varun Gopinath
Sub CATMain()
Set documents1 = CATIA.Documents
Set partDocument1 = documents1.Item("Bez_axis.CATPart")
Set part1 = partDocument1.Part
Set axisSystems1 = part1.AxisSystems
Set axisSystem1 = axisSystems1.Item("Axis_System_3")
Dim originCoord(2)
axisSystem1.GetOrigin originCoord
'msgbox(originCoord(2))
Dim AxisCoordX(2)
axisSystem1.GetXAxis AxisCoordX
Dim AxisCoordY(2) as variant
axisSystem1.GetXAxis AxisCoordY
Dim AxisCoordZ(2)
axisSystem1.GetXAxis AxisCoordZ
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
Dim arrayOfVariantOfBSTR1(0) arrayOfVariantOfBSTR1(0) = "\\fillager.liu.se\vargo025\motor.CATPart"
products1.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"
Dim product2 As Product
Set product2 = products1.Item("Motor.1")
Dim move1 As Move
Set move1 = product2.Move
Set move1 = move1.MovableObject
Dim arrayOfVariantOfDouble1(11) as integer
arrayOfVariantOfDouble1(0) = AxisCoordX(0)
arrayOfVariantOfDouble1(1) = AxisCoordX(1)
arrayOfVariantOfDouble1(2) = AxisCoordX(2)
arrayOfVariantOfDouble1(3) = AxisCoordY(0)
arrayOfVariantOfDouble1(4) = AxisCoordY(1)
arrayOfVariantOfDouble1(5) = AxisCoordY(2)
arrayOfVariantOfDouble1(6) = AxisCoordZ(0)
arrayOfVariantOfDouble1(7) = AxisCoordZ(1)
arrayOfVariantOfDouble1(8) = AxisCoordZ(2)
arrayOfVariantOfDouble1(9) = originCoord(0)
arrayOfVariantOfDouble1(10) = originCoord(1)
arrayOfVariantOfDouble1(11) = originCoord(2)
move1.Apply arrayOfVariantOfDouble1
'product2.referenceproduct.update
End Sub
I dont understand why everytime i run this script catia crashes.
i try to instantiate a CATPart and then move it (essentially a axis-axis snap) to a previously defined axis system.
If i record a macro and run it, it works fine.
Any advice would be nice.
Thanks
Varun Gopinath
Sub CATMain()
Set documents1 = CATIA.Documents
Set partDocument1 = documents1.Item("Bez_axis.CATPart")
Set part1 = partDocument1.Part
Set axisSystems1 = part1.AxisSystems
Set axisSystem1 = axisSystems1.Item("Axis_System_3")
Dim originCoord(2)
axisSystem1.GetOrigin originCoord
'msgbox(originCoord(2))
Dim AxisCoordX(2)
axisSystem1.GetXAxis AxisCoordX
Dim AxisCoordY(2) as variant
axisSystem1.GetXAxis AxisCoordY
Dim AxisCoordZ(2)
axisSystem1.GetXAxis AxisCoordZ
Dim productDocument1 As Document
Set productDocument1 = CATIA.ActiveDocument
Dim product1 As Product
Set product1 = productDocument1.Product
Dim products1 As Products
Set products1 = product1.Products
Dim arrayOfVariantOfBSTR1(0) arrayOfVariantOfBSTR1(0) = "\\fillager.liu.se\vargo025\motor.CATPart"
products1.AddComponentsFromFiles arrayOfVariantOfBSTR1, "All"
Dim product2 As Product
Set product2 = products1.Item("Motor.1")
Dim move1 As Move
Set move1 = product2.Move
Set move1 = move1.MovableObject
Dim arrayOfVariantOfDouble1(11) as integer
arrayOfVariantOfDouble1(0) = AxisCoordX(0)
arrayOfVariantOfDouble1(1) = AxisCoordX(1)
arrayOfVariantOfDouble1(2) = AxisCoordX(2)
arrayOfVariantOfDouble1(3) = AxisCoordY(0)
arrayOfVariantOfDouble1(4) = AxisCoordY(1)
arrayOfVariantOfDouble1(5) = AxisCoordY(2)
arrayOfVariantOfDouble1(6) = AxisCoordZ(0)
arrayOfVariantOfDouble1(7) = AxisCoordZ(1)
arrayOfVariantOfDouble1(8) = AxisCoordZ(2)
arrayOfVariantOfDouble1(9) = originCoord(0)
arrayOfVariantOfDouble1(10) = originCoord(1)
arrayOfVariantOfDouble1(11) = originCoord(2)
move1.Apply arrayOfVariantOfDouble1
'product2.referenceproduct.update
End Sub