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.

External Editor

brettmcginbrettmcgin Member Posts: 2
Hello,

Is it possible to open FeatureScripts in an external editor (vs code, sublime, etc)?

Comments

  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    There isn't an easy way of doing this.

    Ideally, we want to make the experience editing FeatureScript inside a Feature Studio great. Feature Studios have some nice features that an offline editor would be missing, like autocomplete of all your imported libraries, versioning with your onshape documents, and automatic rebuilding of Part Studios when you commit.

    If your favorite editor has specific features that you'd like Onshape Feature Studios to also support, please submit an improvement request!
  • lougallolougallo Member, Moderator, Onshape Employees, Developers, csevp Posts: 2,004
    If your really itching i can share my python script to push and pull the fs  code to a local editor. As was stated, many of the goodies are not going to be on the local editor. 
    Lou Gallo / PD/UX - Support - Community / Onshape, Inc.
  • brettmcginbrettmcgin Member Posts: 2
    I get that there are features that simply won't work in an external editor, and thanks for posting. I think people tend to get really use to editors and having the option to sync with a local file would be awesome, or even an api that we could hook into to make a good experience in Vs Code or similar tools.

    I would love to check out the python code, much appreciated.
  • eitan_goldshtromeitan_goldshtrom Member Posts: 6 ✭✭
    I can understand wanting to make Feature Studio good on its own, but modern editors are whole software suites with a lot of features, so it seems like Feature Studio is always going to lag way behind dedicated editors in regards to actual editing features. A plugin could be made for VSCode, for example, that handles syntax highlighting, linting, std lib autocompletion, and even committing to the document on save. I understand that's a big undertaking, but I would love to raise that idea for reconsideration with Onshape product management.

    Is there a way to make a feature request for something like this?
  • George_AndersonGeorge_Anderson Member Posts: 71 ✭✭

    Ideally, we want to make the experience editing FeatureScript inside a Feature Studio great.

    The Onshape editor is disastrously slow for someone accustomed to a lightning-fast editor like Sublime Text. Some examples:
    • Block commenting 100 lines takes 5 seconds, and block commenting 1000 lines means I should go get a coffee.
    • I can see the lag between a keystroke and seeing it on the screen -- typing feels like I'm wading through a mucky bog.
    I surmise that you are attempting to do work in the background (syntax checking, compiling, etc.) that is clogging the pipe. 

    In addition, there are shortcuts that dramatically improve productivity. To me, the most painful is the lack of "multiselect" or "multicursor".
  • alnisalnis Member, Developers Posts: 452 EDU
    @George_Anderson I think something might be misconfigured for performance on your computer. I just tried copying an existing featurescript into a new feature studio (1,800 lines), find all & replacing comment starts & ends with spaces, and then block commenting various-sized sections out (700 lines, the whole thing, small chunk), and it took less than a second in all cases. I also don't have any noticeable lag between typing and seeing text. Could you post the results of https://cad.onshape.com/check ?
    Get in touch: contact@alnis.dev | My personal site: https://alnis.dev
    @alnis is my personal account. @alnis_ptc is my official PTC account.
  • George_AndersonGeorge_Anderson Member Posts: 71 ✭✭
    @alnis_smidchens

    Your browser is compatible with Onshape

    User agent
    Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:81.0) Gecko/20100101 Firefox/81.0
    Platform
    MacOS
    Browser
    Firefox
    Browser Version
    81.0
    Core WebGL
    Float textures
    Anisotropic texture filtering
    32-bit indices

    High precision fragment shaders

    GL renderer
    Intel Iris Pro OpenGL Engine
    GL vendor
    Intel Inc.
    Your system is running an integrated GPU. If you have a dual-GPU system with a discrete chipset (NVIDIA or AMD) you can get better performance by forcing the browser to use the discrete GPU. See Graphics Performance Recommendations for more information.
    Overall performance*
    Measured triangles per second
    130.1 million
    Measured lines per second
    41.3 million

    *For information on graphics performance, visit: Graphics Performance Recommendations
    WebSocket connection
    Location
    Santa Cruz, United States
    Onshape server region
    us-west-2
    Expected server region
    us-west-2

  • George_AndersonGeorge_Anderson Member Posts: 71 ✭✭
    I just confirmed that if I copy 1000+ lines of code into a completely empty document, then I can block comment 1000 lines in less than a second. Typing is still laggy.

    So this seems to confirm that Onshape is most likely doing something as you type code. Could be imports between different featurescript tabs, or running the code on part studios that use it. (I have about 5 part studios in the document as test cases for the featurescript -- they are not super heavy, I made them as lightweight as I could.)
  • alnisalnis Member, Developers Posts: 452 EDU
    Very weird. The check seems all good. I'm not sure what to say, sorry! Is typing in any other web app slow? Google Docs, Slack, etc.
    Get in touch: contact@alnis.dev | My personal site: https://alnis.dev
    @alnis is my personal account. @alnis_ptc is my official PTC account.
  • kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    edited October 2020
    @George_Anderson
    We're aware of the specific performance problem you mention (typing in large Feature Studios) and its fix is pending in a future release of Onshape. I'll update this post when it ships.
  • stuart_robinsonstuart_robinson Member Posts: 37 ✭✭
    +1 for vscode extension
  • dan_bullokdan_bullok Member Posts: 3
    There isn't an easy way of doing this.

    Ideally, we want to make the experience editing FeatureScript inside a Feature Studio great. Feature Studios have some nice features that an offline editor would be missing, like autocomplete of all your imported libraries, versioning with your onshape documents, and automatic rebuilding of Part Studios when you commit.

    If your favorite editor has specific features that you'd like Onshape Feature Studios to also support, please submit an improvement request!

    I don't see an economical path that would make editing FeatureScript inside a Feature Studio "great".  I can't imagine an experienced programmer working within the existing editor being anything other than incredibly frustrated.  I'm not criticizing the existing effort as a bare-bones tool for adding very simple features, but there's no way you can (or should) compete with an editor that's had decades of person-years put in to addressing the needs of programmers.

    Just off the top of my head, the following features are missing:
    • split editor windows (opening in separate tabs is quite cumbersome)
    • search/replace over multiple FeatureScript Files
    • refactoring
    • code folding
    • edit key bindings
    • bookmarking
    • ability to implement new features inside the editor
    These and at least a dozen other features are pretty much expected in even the most basic programmer's editor. 

    Although syntax highlighting, autocomplete, and other features might be initially missing from an external editor, they'd be relatively easy to implement if we had even a rudimentary file/workspace api to interface with Onshape.  FeatureScript has the advantage of being mostly like javascript, so it wouldn't be very hard to tweak existing javascript editors to accommodate FeatureScript.  Most importantly, it's a task that the community could tackle - and we currently CAN'T change the built-in editor as far as I'm aware.


  • dan_bullokdan_bullok Member Posts: 3
    Just to be clear, I'm not suggesting that Onshape create an external editor.  I just want the ability to pull and push updates to FeatureScript files so that I can use a real editor when I have to make major changes.  It looks like maybe that's possible without dissecting the js through the API, but I haven't found an example yet.  I can't be the only one that would like to be able to do this.  The features I mentioned in my previous post have been pretty much standard for a programmer's editor since at least the early 90s (with the possible exception of refactoring).  I'm dating myself by saying this, but most of those features existed before a mouse was standard equipment.
  • Caden_ArmstrongCaden_Armstrong Member Posts: 195 PRO
    Its just two endpoints:
    https://cad.onshape.com/glassworks/explorer/#/FeatureStudio/getFeatureStudioContents
    and
    https://cad.onshape.com/glassworks/explorer/#/FeatureStudio/updateFeatureStudioContents

    I read in a thread from years past that the featurescript IDE is based on a generic web IDE (ace), so the features are likely what came out of the box. Actually, code folding is supported: on windows highlight a section and do alt-L. Wish I knew that earlier...



    www.smartbenchsoftware.com --- fs.place --- Renaissance
    Custom FeatureScript and Onshape Integrated Applications
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,715
    Senior Director, Technical Services, EMEAI
Sign In or Register to comment.