I try to move selected parts or products with Vb macro. First one should go -5 mm on Y-axis and the second one should go +5mm on Y-Axis can you help me guys?
I tried to choose move selected Products with function of Move but I cant.
Sub Kaydir()
Dim Selection As Selection
Set Selection = CATIA.ActiveDocument.Selection
Dim product As Product
Set product = Selection.Item(1).Value
' Y ekseni boyunca 5mm kaydırma
Dim YDistance As Double
YDistance = 5 ' Kaydırma mesafesi (mm)
' Yönünü belirtmek için oluşturulan Vector
Dim Vector(8) As Double
Vector(0) = 0
Vector(1) = YDistance
Vector(2) = 0
' Ürünün mevcut pozisyonunu almak
Dim currentPosition(11) As Double
currentPosition = product.GetPosition
' Yeni pozisyonu hesaplamak
Dim newPosition(11) As Double
For i = 0 To 5
newPosition(i) = currentPosition(i) + Vector(i)
Next i
' Yeni pozisyonu ayarlamak
product.Move newPosition
End Sub
Dim oProd As Product
Set oProd = CATIA.ActiveDocument.Selection.Item(1).Value
Dim oMove As Move
Set oMove = oProd.Move
'variant array for the transformation matrix, last 3 are the translation
Dim xform(11)
xform(0) = 1#
xform(1) = 0#
xform(2) = 0#
xform(3) = 0#
xform(4) = 1#
xform(5) = 0#
xform(6) = 0#
xform(7) = 0#
xform(8) = 1#
xform(9) = 0#
xform(10) = 5#
xform(11) = 0#
'VBA: because you are passing an array, a variant object is required
Dim vMove As Variant
Set vMove = oMove
Call vMove.Apply(xform)