Page 1 of 2
Animation improvements within solid works
Posted: Mon Oct 19, 2009 8:20 pm
by martgreg
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
Re: Animation improvements within solid works
Posted: Mon Oct 19, 2009 9:51 pm
by JDHill
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 allOption 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.
Re: Animation improvements within solid works
Posted: Mon Oct 19, 2009 10:08 pm
by martgreg
havent used it as yet... but am willing to learn if it isn't too difficult...
any tips on where to start?
Re: Animation improvements within solid works
Posted: Mon Oct 19, 2009 10:23 pm
by JDHill
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 allDim swApp As Object
Sub main()
Set swApp = Application.SldWorks
End Sub
With the code from my last post:
Code: Select allOption 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.
Re: Animation improvements within solid works
Posted: Mon Oct 19, 2009 10:36 pm
by martgreg
ok I will try this out.....
but not till later today or tomorrow thanks for the help
Re: Animation improvements within solid works
Posted: Tue Jan 26, 2010 10:54 am
by w i l l
Any more news on tapping into the Solidworks API to simply set up animations without scripts? I haven't been on the forum for a while.
Cheers,
Will
Re: Animation improvements within solid works
Posted: Tue Jan 26, 2010 3:05 pm
by JDHill
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.
Re: Animation improvements within solid works
Posted: Tue Jan 26, 2010 7:30 pm
by w i l l
Oh ok, when is the next build roughly? A year? A month? Thanks for that.
Re: Animation improvements within solid works
Posted: Tue Jan 26, 2010 8:08 pm
by JDHill
I'm not sure on a date - I'm working on getting rid of the 'abolute coords' switch, along with some other things.
Re: Animation improvements within solid works
Posted: Tue Feb 16, 2010 12:42 pm
by Jukka Laattala
Any updates to when the new plug-in might be released?
Re: Animation improvements within solid works
Posted: Wed Feb 17, 2010 5:28 am
by JDHill
No, I'm still working on it.
Re: Animation improvements within solid works
Posted: Wed Feb 17, 2010 7:06 am
by martgreg
thanks JD we appreciate your efforts
Re: Animation improvements within solid works
Posted: Mon Jun 14, 2010 8:45 pm
by w i l l
Just in case some people are unaware.... THERE IS NOW ANIMATION WITH MOTION STUDY! Cheers JD.
Re: Animation improvements within solid works
Posted: Wed Jun 30, 2010 10:30 pm
by martgreg
So how do we do it ?
tutorial ? or did i miss something again ?
This will be awesome to try out
Thanks
Re: Animation improvements within solid works
Posted: Wed Jun 30, 2010 11:13 pm
by w i l l
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.