Maxwell Render

Maxwell Render Information Repository
It is currently Fri May 24, 2013 1:38 am

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next
Author Message
 Post subject:
PostPosted: Mon Oct 20, 2008 5:56 pm 
User avatar

Joined: Wed Nov 16, 2005 3:02 am
Posts: 7578
Location: desk #861
Sure, I'm happy to try to work something up, but it may take me a few days to find some time to do it.

_________________
Next Limit Team


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 20, 2008 6:05 pm 
User avatar

Joined: Sat Aug 20, 2005 8:54 pm
Posts: 1516
Location: Back home for once
Yeah, no probs - cheers JD.

_________________
Product Design
Linkedin


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 2:54 pm 
User avatar

Joined: Sat Aug 20, 2005 8:54 pm
Posts: 1516
Location: Back home for once
JD - you didnt have time to do this did you by any chance? I still need to do the Solidworks zoom in.

If not, no worries I don't want to be a pest.

_________________
Product Design
Linkedin


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 3:05 pm 
User avatar

Joined: Wed Nov 16, 2005 3:02 am
Posts: 7578
Location: desk #861
Hi Will, no I didn't - to be honest, being busy with the new Cinema plugin release, I had forgotten about this thread...let me see what I can do.

_________________
Next Limit Team


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 10, 2008 8:27 pm 
User avatar

Joined: Wed Nov 16, 2005 3:02 am
Posts: 7578
Location: desk #861
Pretty similar to the turntable one, just try this out and let me know if it does what you're looking for:

Code:
Sub MaxwellZoomAnimation()
    On Error GoTo handle_error
   
    'dialog title
    Dim dialogTitle As String
    dialogTitle = "Maxwell Turntable Animation"
   
    'get SW
    Set swApp = Application.SldWorks
    If swApp Is Nothing Then
      MsgBox "Unable to connect to SolidWorks", vbOKOnly, dialogTitle
      Exit Sub
    End If
   
    'get active doc
    Dim doc As ModelDoc2
    Set doc = swApp.ActiveDoc
    If doc Is Nothing Then
      MsgBox "There is no active document.", vbOKOnly, dialogTitle
      Exit Sub
    End If
   
    'get active view
    Dim view As ModelView
    Set view = doc.ActiveView
    If view Is Nothing Then
      MsgBox "There is no active view.", vbOKOnly, dialogTitle
      Exit Sub
    End If
   
    'get view camera
    Dim cam As Camera
    Set cam = view.Camera
    If cam Is Nothing Then
      MsgBox "The active view has no SolidWorks camera - " & _
      "please add one, or choose a viewport which does.", vbOKOnly, dialogTitle
      Exit Sub
    End If
   
    'Maxwell.Script ScriptObject
    Dim maxwell As Object
    Set maxwell = CreateObject("Maxwell.Script.ScriptObject")
   
    'ScriptObject is created?
    If maxwell Is Nothing Then
      MsgBox "Unable to create Maxwell.Script.ScriptObject.", vbOKOnly, dialogTitle
      Exit Sub
    End If
   
    'ScriptObject is connected?
    If Not maxwell.IsConnected Then
      MsgBox "There is no current Maxwell Scene.", vbOKOnly, dialogTitle
      Exit Sub
    End If
   
    'declare a bunch of variables
    Dim viewportRect(0 To 3) As Long
    Dim originalPosition As MathPoint
    Dim cameraTarget As MathPoint
    Dim distance As MathVector
    Dim framePosition As MathPoint
    Dim strFrameCount As String
    Dim frameCount As Integer
    Dim meshesWereCached As Boolean
    Dim i As Integer
   
    'get viewport for refreshing
    viewportRect(0) = view.FrameLeft
    viewportRect(1) = view.FrameTop
    viewportRect(2) = view.FrameWidth
    viewportRect(3) = view.FrameHeight
   
    'initialize previous frameCount
    If previousFrameCount < 2 Then
      previousFrameCount = 24
    End If
   
    'get number of frames from user
get_frameCount:
    strFrameCount = InputBox("Specify the number of frames to render.", _
                             dialogTitle, previousFrameCount)
    'cancelled by user?
    If strFrameCount = "" Then Exit Sub
   
    'validate to numeric input
    If Not IsNumeric(strFrameCount) Then
      MsgBox "Please enter a number.", vbOKOnly, dialogTitle
      'try again
      GoTo get_frameCount
    End If
   
    'validate specified number of frames
    If CInt(strFrameCount) < 2 Then
      MsgBox "Please enter a number greater than one.", vbOKOnly, dialogTitle
      'try again
      GoTo get_frameCount
    End If
   
    'set framecount
    frameCount = CDbl(strFrameCount)
   
    'check for crazy number of frames
    If frameCount > 360 Then
      If Not MsgBox("That sure is alot of frames (" & _
                    frameCount & "). Do you really want " & _
                    "continue?", vbYesNo, dialogTitle) = vbYes Then
        Exit Sub
      End If
    End If
   
    'store as previous count
    previousFrameCount = frameCount
    'current position/target
    Set originalPosition = cam.GetPosition
    Set cameraTarget = cam.TargetPointPosition
    'save current value of Cache MXS Meshes option
    meshesWereCached = maxwell.PlugInOptions.CacheMXSMeshes
    'enable Cache MXS Meshes
    maxwell.PlugInOptions.CacheMXSMeshes = True
    'start plugin animation loop
    maxwell.Rendering.BeginAnimation

    For i = 1 To frameCount
      'write MXS
      maxwell.Rendering.RenderToMxs
      'get distance vector again
      Set distance = originalPosition.Subtract(cameraTarget)
      'scale by frameCount
      Set distance = distance.Scale(1# - (i / frameCount))
      'add scaled distance to original target
      Set framePosition = cameraTarget.AddVector(distance)
      'set new position
      cam.SetPositionCartesian framePosition.ArrayData(0), _
                               framePosition.ArrayData(1), _
                               framePosition.ArrayData(2)
      'refresh viewport
      view.GraphicsRedraw (viewportRect)
    Next

    'end plugin animation loop
    maxwell.Rendering.EndAnimation
    'reset camera exactly where it was before
    cam.SetPositionCartesian originalPosition.ArrayData(0), _
                             originalPosition.ArrayData(1), _
                             originalPosition.ArrayData(2)
    'refresh viewport
    view.GraphicsRedraw (viewportRect)
    'restore Cache MXS Meshes option to previous value
    maxwell.PlugInOptions.CacheMXSMeshes = meshesWereCached
   
    'done
    Exit Sub
   
    'something went wrong
handle_error:     MsgBox "An unexpected error occurred (" & Err.Description & ")"

End Sub


To test it without rendering, just comment-out (i.e. put an apostrophe at the front of the line) the BeginAnimation, RenderToMxs, and EndAnimation lines.

_________________
Next Limit Team


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 30, 2008 3:52 pm 
User avatar

Joined: Sat Aug 20, 2005 8:54 pm
Posts: 1516
Location: Back home for once
Yeah thats good - thanks!

I've noticed that within Solidworks using the Maxwell plugin that if I type a number say '1' for example it actually types '111' (3x the number). Is there some setting that I need to change? This doesn't happen in any other software.

_________________
Product Design
Linkedin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 30, 2008 6:31 pm 
User avatar

Joined: Wed Nov 16, 2005 3:02 am
Posts: 7578
Location: desk #861
Hi Will, where do you mean? There are some places where the plugin tries to keep names unique, so it may be appending a '1' in an effort to do that, but I'd need to know where you're seeing it to say for sure.

_________________
Next Limit Team


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 30, 2008 6:49 pm 
User avatar

Joined: Sat Aug 20, 2005 8:54 pm
Posts: 1516
Location: Back home for once
Well everywhere that you can input a value i.e. Sun Power or camera f-Stop.... anywhere. It's actually 4x so if I type 9 I get 9999. Maybe it's a keyboard problem, but it only happens in the Maxwell plugin.

_________________
Product Design
Linkedin


Top
 Profile  
 
 Post subject:
PostPosted: Sun Nov 30, 2008 7:11 pm 
User avatar

Joined: Wed Nov 16, 2005 3:02 am
Posts: 7578
Location: desk #861
Hmm, well there's nothing in the code to make it do that, so I'd look at whether there might be some other application running that would have a hook for monitoring/altering keystrokes, or else try repairing or updating the .Net Framework on your machine.

_________________
Next Limit Team


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 14, 2009 6:55 pm 
User avatar

Joined: Sat Aug 20, 2005 8:54 pm
Posts: 1516
Location: Back home for once
Haven't checked this forum for a while... just wondering if Next Limit are any closer to convincing Solidworks to allow integration of Maxwell into Solidworks MotionManager for animation?

I get asked quite a lot to do product animation and still don't like the idea of converting Solidworks models and importing to Cinema 4D etc for animation.

_________________
Product Design
Linkedin


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 14, 2009 7:26 pm 
User avatar

Joined: Wed Nov 16, 2005 3:02 am
Posts: 7578
Location: desk #861
I believe that I'll be able to make that work, it's just that along with integrating the texture-mapping feature of SW2009, this involves replacing almost all of the plugin's code and dropping support for earlier SW versions. I expected this to happen prior to yesterday's new release, but it was not yet possible, so I decided to release as-is and allow SW2007+ users to also get the benefit of the improvements that the new version provides. So it's going to take more time, and I don't have a definite ETA.

_________________
Next Limit Team


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 14, 2009 7:47 pm 
User avatar

Joined: Sat Aug 20, 2005 8:54 pm
Posts: 1516
Location: Back home for once
Ah ok nice one.

_________________
Product Design
Linkedin


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 12:08 am 
User avatar

Joined: Tue Apr 19, 2005 10:35 pm
Posts: 325
Location: Auckland New Zealand
Looking forward to the motion integration, that will be the day that I upgrade from swx 2008 to 2009

_________________
John Layne

http://www.solidengineering.co.nz

"The mass of men lead lives of quiet desperation"
Henry David Thoreau 1854


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 4:29 pm 

Joined: Mon Aug 25, 2008 3:11 pm
Posts: 35
Location: Liechtenstein
I´m struggling to get the example scripts running.
I followed the steps carefully and even prepared a maxwell scene, camera, etc.

The script tells me that: "There is no current Maxwell Scene"

Did I miss something? - please help


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 15, 2009 4:57 pm 
User avatar

Joined: Wed Nov 16, 2005 3:02 am
Posts: 7578
Location: desk #861
If you are running version 1.8.2 of the plugin, you don't need these scripts - I put them directly in the plugin. Just look in the plugin's menu/toolbar for the turntable and zoom animation buttons.

_________________
Next Limit Team


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 37 posts ]  Go to page Previous  1, 2, 3  Next

All times are UTC + 1 hour [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group