By martgreg
#312380
Hi JD and guys:

I am looking at getting v2 of maxwell and wondering have there been any improvements or additions in the plug in for animations....

I am aware in 1.7 we could rotate the camera around the object, ie the whole scene in the back ground would move....

my real question is what are the limitations for 1.7 compared to version 2....

I have been away a long time and want to do a turntable whilst the object is spinning ... is this possible in 1.7 and v2

thanks
#312391
Do you know how to use the VBA editor in SolidWorks? If so, and if you are not running an x64 version of SolidWorks (the plugin script interface won't work under x64), then this may help:

Code: Select all
Option Explicit

Sub main()

    ' create ScriptObject
    'Dim maxwell As New Maxwell_Script.scriptobject
    
    ' successfully created
    'If maxwell Is Nothing Then Exit Sub
    
    ' actually connected?
    'If Not maxwell.IsConnected Then Exit Sub

    Dim app As Object
    Set app = Application.SldWorks
    
    Dim model As Object
    Dim extension As Object

    Set model = app.ActiveDoc
    Set extension = model.extension
    
    Dim motionMgr As Object
    Dim motionStudy As Object

    ' Get the MotionManager

    Set motionMgr = extension.GetMotionStudyManager()
    
    ' motion study manager present?
    If (motionMgr Is Nothing) Then
        MsgBox "MotionStudyManager was not found."
        Exit Sub
    End If
    
    ' get motion study name
    Dim motionStudyName
    motionStudyName = InputBox( _
        "Enter the name of the Motion Study you would like to render.", _
        "Choose Motion Study", "Motion Study 1")

    ' cancelled?
    If motionStudyName = "" Then Exit Sub

    ' get motion study
    Set motionStudy = motionMgr.GetMotionStudy(motionStudyName)

    ' chosen study exists?
    If (motionStudy Is Nothing) Then
        MsgBox motionStudyName + " does not exist."
        Exit Sub
    End If
    
    Dim seconds, fps
    seconds = motionStudy.getduration
    
    
    ' get number of frames
    fps = InputBox( _
        "Enter the number of frames per second to export.", _
        "Frames per second", 25)
        
    If fps = "" Then Exit Sub

    If Not motionStudy.IsActive Then motionStudy.Activate
    
    motionStudy.settime 0
    'maxwell.Rendering.BeginAnimation
    
    Dim i
    For i = 0 To seconds * fps
       'maxwell.Rendering.RenderToMxs
       motionStudy.settime (i / fps)
    Next
    
    'maxwell.Rendering.EndAnimation
    motionStudy.settime 0

End Sub
Running it as-is will just execute the specified motion study using the specified frame-rate; if you un-comment (i.e. remove the apostrophes at the beginning of) the lines that contain 'maxwell', it should export mxs files for each frame. I can't test, since I only have SW x64 installed on this machine, so let me know if I've made any typos - the VBA editor will let you know if there's a problem when you try to run the script.
By JDHill
#312395
Sure, try this:

1. open SW
2. open your assembly
3. set up your motion study
4. Tools > Macro > New
5. enter a name for the macro file
6. click Save
7. in the VBA editor window, replace:
Code: Select all
Dim swApp As Object
Sub main()

Set swApp = Application.SldWorks
End Sub
With the code from my last post:
Code: Select all
Option Explicit

Sub main()

    ' create ScriptObject
    'Dim maxwell As New Maxwell_Script.scriptobject

   [etc.]
    
    'maxwell.Rendering.EndAnimation
    motionStudy.settime 0

End Sub
9. click File > Save
10. hit F5 (or, main menu > Run > Run Sub/UserForm)

If you want to, you can then create a new toolbar button and associate this macro with it. Just let me know if you get lost anywhere along the way.
#318098
The next build will have a 'Motion Study Animation' button/dialog, which will work similar to the existing zoom & turntable animations - you just choose which motion study you want from a drop-down list and set how many frames per second (of the motion study) to export.
#325856
Just make a motion study in Solidworks. I.e. to test... model a cube and use the wizard in Motion Study to rotate it. Then create a camera in Motion Study. Then you will see the option within the Maxwell drop-down for 'Motion Study Animation'. Then export it.

That's it, pretty easy.
Last edited by w i l l on Wed Jun 30, 2010 11:30 pm, edited 1 time in total.

Well.....they must have been proven wrong, as it's[…]

Hello dear customers, We have just released a new[…]

the render does not start

Also open the Console and read through it to see i[…]

Sketchup 2024 Released

I would like to add my voice to this annual reques[…]