Reverse Curve Script not running

3ddd
2011-10-03
2013-06-05
  • 3ddd

    3ddd - 2011-10-03

    Hi All

    Sorry about this but i am asking about something else; only becuase i am now using AOI
    for many uses at work and using more of AOI's features.

    I amtrying to run "Peteihis's" Reverse Curve script but it is giving me error reports, maybe it needs to be updated
    to be able to run in AOI 2.8.1 i am not sure. I am selecting the curve object but when applying the Revers Curev tool script it gives me the following error message:

    java.lang.ArrayStoreException: java.lang.IllegalArgumentException: array element type mismatch
    at bsh.Reflect.setIndex(Unknown Source)
    at bsh.LHS.assign(Unknown Source)
    at bsh.BSHAssignment.eval(Unknown Source)
    at bsh.BSHBlock.evalBlock(Unknown Source)
    at bsh.BSHBlock.eval(Unknown Source)
    at bsh.BSHBlock.eval(Unknown Source)
    at bsh.BSHForStatement.eval(Unknown Source)
    at bsh.BSHBlock.evalBlock(Unknown Source)
    at bsh.BSHBlock.eval(Unknown Source)
    at bsh.BSHBlock.eval(Unknown Source)
    at bsh.BSHForStatement.eval(Unknown Source)
    at bsh.BSHBlock.evalBlock(Unknown Source)
    at bsh.BSHBlock.eval(Unknown Source)
    at bsh.BshMethod.invokeImpl(Unknown Source)
    at bsh.BshMethod.invoke(Unknown Source)
    at bsh.BshMethod.invoke(Unknown Source)
    at bsh.This.invokeMethod(Unknown Source)
    at bsh.This.invokeMethod(Unknown Source)
    at bsh.XThis$Handler.invokeImpl(Unknown Source)
    at bsh.XThis$Handler.invoke(Unknown Source)
    at $Proxy2.execute(Unknown Source)
    at artofillusion.script.ExecuteScriptWindow.executeScript(ExecuteScriptWindow.java:146)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
    at java.lang.reflect.Method.invoke(Unknown Source)
    at buoy.internal.EventLinkRecord.dispatchEvent(EventLinkRecord.java:83)
    at buoy.event.EventSource.dispatchEvent(EventSource.java:140)
    at buoy.widget.Widget.dispatchEvent(Widget.java:326)
    at buoy.widget.BButton$1.actionPerformed(BButton.java:50)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.awt.EventQueue$1.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.awt.EventQueue$2.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)

    Not sure if anybody may know what may be wrong. Maybe the author Peteihis may read this forum and can help.

    If anybody would like me to post the code for the script to have a look at i can post it to the forum.

    Thanks as always.

    Gary.

     
  • Peter Eastman

    Peter Eastman - 2011-10-04

    If anybody would like me to post the code for the script to have a look at i can post it to the forum.

    Sure, it might be something obvious.

    Peter

     
  • 3ddd

    3ddd - 2011-10-04

    Hi Peter and All

    Please find below a copy of the Reverse Curve script code:

    /*
    <?xml version='1.0' standalone='yes' ?>
    <!-  xml header for scripts and plugin manager ->
    <script>
    <name>Reverse Curve</name>
    <author>Petri Ihalainen (peteihis@users.sourceforge.net)</author>
    <version>1.0</version>
    <date>12/04/2008</date>
    <description>
    Chances the direction in which a curve is read
    </description>
    <comments>
    </comments>
    </script>
    */

    // Getting the scene and the selected objects list for the script
    scene=window.getScene();
    selection=scene.getSelection();
    //

    // Check if any objects vere selected. If not, exit with message.

    if (selection.length < 1)
    {
       new MessageDialog(window, "Select at least one curve first!");
       return;
    }

    // Check if all selected objects are curves

    nonCurves = 0;

    for (i = 0; i < selection.length; i++)
    if (scene.getObject(selection_).object instanceof Curve==false)
    nonCurves = 1;

    if (nonCurves == 1)
    {
    new MessageDialog(window, "Please select only curves.");
      return;
    }

    //------------------------------
    // The reversing action
    //------------------------------

    // Loop through the selection
    for (i = 0; i < selection.length; i++)
    {
    curveInfo=scene.getObject(selection);
    curve = curveInfo.object;
    verticesCurve = curve.getVertices();

    // Create an new array of vertices but in a reversed order

    verticesReversed = new MeshVertex;
    for (j = 0; j < verticesCurve.length; j++)
    {
    verticesReversed = verticesCurve;
    }

    // Feed the reversed array back into the original array

    for (j = 0; j < verticesCurve.length; j++)
    {
    verticesCurve = verticesReversed;
    }

    // Updating the scene with the changed curve.
    // Please note that this is not absolutely necessary as
    // the changes were made directly into the original curve
    // and they don't change it's appearance.
    // However if you actually edit the points by the script,
    // this forces the canges to be seen on the screen

    scene.replaceObject(curve, curve.duplicate(), null);

    }

    //--------------------------
    // And displaying the statistics…. :)
    //--------------------------

    {
    new MessageDialog(window, selection.length + " curves were reversed");
      return;
    }

    The script reverses the direction of a curve which is useful when animating a camera
    along a curve and you want to reverse the direction.

    Thanks.

    Gary.

    _

     
  • Harald G

    Harald G - 2011-10-04

    It's easier than that!
    Install the advanced curves plugin from Troy.
    Convert your curve to an advanced curve.
    Open it in it's editor (doubleclick is just fine),
    then  use CURVE -> Reihenfolge der Punkte umkehren which means "change the order of the points".
    You'll get visual feedback immediately - so you'll know about the direction due to a small yellow arrow on the end of the curve.

    HTH
    Harald
    PS: But it doensn't hurt to have a working script anyway.

     
  • Pete

    Pete - 2011-10-04

    We'll I did not expect to run into this one again… :)

    Here is the original one: http://www.kuukahvila.com/peteihis/AOI/script/Reverse%20Curve.bsh

    For some reason, though it was workin in 2008, it's not working now. The error appears where the scipt is copying the vertices to a new array in a reversed order. So the vertices of a curve are not of the type MeshVertex any more?

    Anyhow a pretty rustic fix can be done this way: Comment out the line  

        verticesReversed = new MeshVertex;

    and write there two instead:

    ghostCurve = curve.duplicate();
    verticesReversed = ghostCurve.getVertices();

    Duplicate() or clone() are'n working for the array, so I chose to make another copy of the curve and get the new array from there.

    And I'd also like to point out that the scene.replaceObject(curve, curve.duplicate(), null); by the end of the script is not only unnecessary, but also the wrong way of performing the update. I think Peter set some directions how to do it correctly in the original thread, but I don't remember where that thread was and at least it did not jump onto my face when I was looking for it…

    BR

    -P-

     
  • Pete

    Pete - 2011-10-04

    Or shorter:

    Change this: verticesReversed = new MeshVertex;
    into this: verticesReversed = curve.duplicate().getVertices();

    -P-

     
  • 3ddd

    3ddd - 2011-10-04

    Hi Petihis and Vidiot (Harald)

    Many thanks for your replies, seems that you both have solved my question; i will change the lines you mention
    in the script. Also i had the Advanced curves script installed but did not realise you could reverse the points.

    Thanks.

    Cheers.

    Gary.

     
  • 3ddd

    3ddd - 2011-10-05

    Hi Peteihis

    I tried to change the Original Reverse Curve script as you suggested but the line you suggest to replace in the
    script does not exist.

    Change this: verticesReversed = new MeshVertex;    …………….this line does not exist

    into this: verticesReversed = curve.duplicate().getVertices();

    Cheers.

    Gary.

     
  • 3ddd

    3ddd - 2011-10-05

    Hi Peteihis

    OK maybe i am getting confused as the line you suggest to change:

    verticesReversed = new MeshVertex;

    does exist, but i have tried to change the code as you suggest but either way you have suggested
    does not seem to work for me.

    Cheers.

    Gary.

     
  • Pete

    Pete - 2011-10-06

    Well, it seemed to work for me, but never mind: Here is version 2.0 of the script.

    http://www.kuukahvila.com/peteihis/AOI/script/Reverse%20Curve.bsh (Same link as before, but with updated content).

    At least this one was working now and it is not using the 'new MeshVertex' thing any more. The swaps happen in a more old school way, that does not care about the types :)

    @ Peter 1) Something funny seems to be related to the MeshVertex class: If I create an array of MeshVertex as above, the content is not recognized as placeholders for MeshVertex objects. Also I did not get the constructors of MeshVertex to vork in a script.

    @ Peter 2) By the end of the script I used the scene.objectModified(curve) method, as you advised at the time, this was made but that and/or the rest of the update methods do not update the appearance of the curve. I tested that by changing one vertex. I have to open it in the curve editor to see the changes.

    BR

    -P-

     
  • 3ddd

    3ddd - 2011-10-07

    Hi Peteihis

    Many thanks for the update to the Reverse Curve script, i have downloaded the script and installed it into
    AOI 2.8.1 and runs OK, its great to have the script back and working again as even though i now know that you
    can reverse the points of the Advanced Curve tool, your script allows me to reverse the camera path of any
    curve shape for example the Helix or Coil shape on the fly.

    Thanks again.

    Gary.

    P.S Its amazing what you can do with AOI and all of its Plugins and Scripts, my job role has changed at work and
    i am now using AOI for many projects from modeling and animation of characters to motion graphics.
    Thanks to all as always for a great program and all the script and plugin creators.

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks