Here the code :
'On vérifie que le document est bien une pièce
If Not ThisApplication.ActiveDocument.DocumentType = kPartDocumentObject Then
MessageBox.Show("Ce document n'est pas un assemblage", "Representation par défaut", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return
End If
' Ce document (assemblage)
Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition
Dim myVertex = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllEntitiesFilter, "Select Point or circular to set as origin:")
ButtonClicked = MessageBox.Show("Rotation autour d'un axe?", "Déplacement d'un corps", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1)
'OUI 6 - NON = 7
Dim myAxe
If ButtonClicked = 6 Then
oRotation = True
myAxe = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllLinearEntities, "Select rotation axe:")
oRotationAngle = InputBox("Angle de rotation", "Déplacement d'un corps", "90")
Else
oRotation = False
End If
Dim myPoint
Dim oEdgeCollection
Dim oWorkPoints As WorkPoints = oCompDef.WorkPoints
Dim i As Long
If myVertex.Type = 67120432 Then 'Point
myPoint = myVertex.Point
Else If myVertex.Type = 67120176 Then 'Edge
oWorkPoints.AddAtCentroid(myVertex)
i = oWorkPoints.Count
Try
myPoint = oWorkPoints.Item(i).Point
oWorkPoints.Item(i).Delete
Catch
MessageBox.Show("Seulement une courbe ou un point peuvent être sélectionnés." & vbCrLf & "Abandon du script", "TEST TEST TEST", MessageBoxButtons.OK, MessageBoxIcon.Warning)
End Try
Else
MessageBox.Show("Seulement une courbe ou un point peuvent être sélectionnés." & vbCrLf & "Abandon du script", "TEST TEST TEST", MessageBoxButtons.OK, MessageBoxIcon.Warning)
Return
End If
Dim oBodies As ObjectCollection
oBodies = ThisApplication.TransientObjects.CreateObjectCollection
' Specify a body to move.
oBodies.Add(oCompDef.SurfaceBodies(1))
' Create a MoveFeatureDefinition.
Dim oMoveDef As MoveDefinition
oMoveDef = oCompDef.Features.MoveFeatures.CreateMoveDefinition(oBodies)
oRangeBox = oBodies.Item(1).RangeBox
oMidX = -1*myPoint.X
oMidY = -1*myPoint.Y
oMidZ = -1*myPoint.Z
' the move operations onto the bodies.
Dim oFreeDrag As FreeDragMoveOperation
oFreeDrag = oMoveDef.AddFreeDrag(oMidX, oMidY, oMidZ)
'Dim oMoveAlongRay As MoveAlongRayMoveOperation
'oMoveAlongRay = oMoveDef.AddMoveAlongRay(oCompDef.WorkAxes(2), True, 2)
If oRotation = True Then
Dim oRotateAboutAxis As RotateAboutLineMoveOperation
oRotateAboutAxis = oMoveDef.AddRotateAboutAxis(myAxe, True, oRotationAngle*(PI/180))
End If
' Create the move feature.
Dim oMoveFeature As MoveFeature
oMoveFeature = oCompDef.Features.MoveFeatures.Add(oMoveDef)
ThisApplication.ActiveView.Fit