Thanks for the link, I have several other projects that would find that function useful.
As fro the X axis – I never assume anything <!– s;) –><img src="{SMILIES_PATH}/icon_e_wink.gif" alt="" title="Wink" /><!– s;) –>
so here is the final script… and it seems to work OK
just copy and paste this code into your edit script window and save – again beware of lines wrapping around…
[pre class=’ip-ubbcode-code-pre’]
Language = VBScript
‘*********************************************************************************
‘ Purpose: Set all animation positions to the current selected object position
‘*********************************************************************************
Option Explicit andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;’require variable declarations
Sub Main (3DCApp)
andnbsp; andnbsp;Dim Scene, Object, Group, GP, T
andnbsp; andnbsp;Dim ActiveObjectCount
andnbsp; andnbsp;Dim X, Y, Z, I
andnbsp; andnbsp;Dim PX, PY, PZ, OX, OY, OZ, OW, angle, sa
andnbsp; andnbsp;Dim dx, dy, dz, ux, uy, uz, ax, ay, az
andnbsp; andnbsp;Dim Reply
andnbsp; andnbsp;’get the scene
andnbsp; andnbsp;Set Scene = 3DCApp.GetActiveScene
andnbsp; andnbsp;’get the active object count
andnbsp; andnbsp;ActiveObjectCount = Scene.GetActiveObjectCount
andnbsp; andnbsp;’only proceed if there is an active object
andnbsp; andnbsp;If ActiveObjectCount = 0 Then
andnbsp; andnbsp; andnbsp; andnbsp;MsgBox andquot;Please select an object.andquot;
andnbsp; andnbsp;Else
andnbsp; andnbsp; andnbsp; andnbsp;Set Object = Scene.GetActiveObject(0)
andnbsp; andnbsp; andnbsp; andnbsp;Set Group = Object.GetParentGroup()
andnbsp; andnbsp; andnbsp; andnbsp;Set GP = Group.GetParent()
andnbsp; andnbsp; andnbsp; andnbsp;Reply = MsgBox(andquot;Set all key frame positions for Group andquot; andamp; Group.GetName() andamp; andquot; to the current
position? (no undo available)andquot;, vbYesNo)
andnbsp; andnbsp; andnbsp; andnbsp;If Reply = vbYes Then
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Group.GetPosition GP, X, Y, Z
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;For I = Group.GetOrientationKeyFrameCount() – 1 To 0 Step -1
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Group.GetOrientationKeyFrame I, T, OX, OY, OZ, OW
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;angle = -ArcCos(OW) * 2
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;sa = Sqr(1 – OW * OW)
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;If (Abs(sa) andlt; 0.0000001) Then sa = 0.0000001
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;ax = OX / sa
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;ay = OY / sa
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;az = OZ / sa
andnbsp; andnbsp;
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;3DCApp.RotatePoint 0, 0, 1, ax, ay, az, angle, dx, dy, dz
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;3DCApp.RotatePoint 0, 1, 0, ax, ay, az, angle, ux, uy, uz
andnbsp; andnbsp;
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Group.SetPosition GP, T, X, Y, Z
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Group.SetOrientation GP, T, dx, dy, dz, ux, uy, uz
andnbsp; andnbsp; andnbsp; andnbsp; andnbsp; andnbsp;Next
andnbsp; andnbsp; andnbsp; andnbsp;End If
andnbsp; andnbsp;End If
End Sub
Function ArcCos(ByVal X)
andnbsp; andnbsp;If X = 1 Then
andnbsp; andnbsp; andnbsp; andnbsp;ArcCos = 0
andnbsp; andnbsp;ElseIf X = -1 Then
andnbsp; andnbsp; andnbsp; andnbsp;ArcCos = Atn(1) * 4 ‘pi
andnbsp; andnbsp;Else
andnbsp; andnbsp; andnbsp; andnbsp;ArcCos = Atn(-X / Sqr(-X * X + 1)) + 2 * Atn(1)
andnbsp; andnbsp;End If
End Function
[/pre]
Regards
Paul