Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.

First time visiting? Here are some places to start:
  1. Looking for a certain topic? Check out the categories filter or use Search (upper right).
  2. Need support? Ask a question to our Community Support category.
  3. Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
  4. Be respectful, on topic and if you see a problem, Flag it.

If you would like to contact our Community Manager personally, feel free to send a private message or an email.

Need help with a idea for a time lapse using the feature tree.

Ben_Ben_ OS Professional, Mentor, Developers Posts: 304 PRO
I am not a feature script guy so this is a request. Sometimes I need to record my build and most of the time I forget to hit record, yes it is lame but it happens. Is there a feature script that could walk through each feature, sketch etc and make a screenshot starting at the top of the feature tree. Then I can take that into my editing software and make a pseudo timelapse. 

Comments

  • S1monS1mon Member Posts: 3,521 PRO
    I would love a tool which would step through the feature tree in some sort of controlled fashion. It is possible now to select the roll back bar and use the arrow keys to roll forward (or back). If you just screen record a video of this, it might be close enough to what you want.

    Simon Gatrall | Staff Mechanical Engineer | Carbon, Inc.

  • Paul_J_PremakumarPaul_J_Premakumar Member, Onshape Employees Posts: 234
    edited June 2024
    You could do this using the REST API. Here is an outline of the algorithm & relevant API calls

    1. Get the list of features (https://cad.onshape.com/glassworks/explorer#/PartStudio/getPartStudioFeatures)
    2. For each feature, move the rollback bar by 1. ( https://cad.onshape.com/glassworks/explorer#/PartStudio/updateRollback )
    3. Get a snapshot of the part studio ( https://cad.onshape.com/glassworks/explorer#/PartStudio/getPartStudioShadedViews ) & save to file.
    4. Repeats step 2,3 until you are done with features.

    HTH.
  • javljavl Member Posts: 3
    edited September 1

    @Ben_

    I do something similar on Linux with a little (very hacky) shell script.

    It basically works like this:

    1. Manually set the number of features in your file (55 in my example)
    2. Manually move the rollback bar to the top
    3. Run the script; it will wait for 3 seconds allowing you to select the rollback bar again by clicking on it
    4. The script will fake a 'down arrow' keypress, wait a second, take a screenshot, wait another second and repeats this 55 times until all features are applied.

    I might try to make a little python script that does something similar using the API (so you don't need to set the number of features manually) but for now this works fine for my needs. If you're on Windows / Macos there are many apps that let you control your system in a similar way (for Windows there is AutoIt for example). You could use one of those programs to set up a similar loop.

    In the end I use ffmpeg to combine the frames into an animation (but again there is also GUI based software that can do this for you).
    ffmpeg -framerate 24 -pattern_type glob -i "*.png" -c:v libx264 -pix_fmt yuv420p output.mp4

    My shellscript (also online as a gist on Github )

    #!/bin/bash
    sleep 3
    for i in $(seq 1 55); do
    echo "Iteration: $i of 55"
    # Press the Arrow Down key using xdotool
    xdotool key Down
    sleep 1
    # Replace "Part Studio" with the actual window title or part of it
    WINDOW_ID=$(xdotool search --name "Part Studio" | head -n 1)
    import -window "$WINDOW_ID" ~/screenshots/screenshot_$(date +%Y%m%d_%H%M%S).png
    sleep 1
    done

  • javljavl Member Posts: 3

    I've written a quick test script using the API as described by @Paul_J_Premakumar. The script is very much WIP (but does work), but I like the result less than the 'real' screenshot option; seeing the sketches and some of the UI is a bit more interesting. Might depend on your needs though.

    As this forum doesn't allow formatting code, and Python code breaks when it looses the right indentation, I've made a gist on Github:

    https://gist.github.com/javl/b0ec23ce20e3a06160ed28aada3a5a34

Sign In or Register to comment.