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.

import exported enum from another tab

adamohernadamohern Member, OS Professional Posts: 216 PRO
I'm importing exported functions from another tab, and so far everything is working fine.

Now I'd like to offload some of my enum definitions to a separate tab as well, but so far that's not working. Is there a trick to making that work?

Comments

  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,175
    The trick (I suspect without seeing your case) is to prefix the import of the tab with the enum definitions with "export" to re-export the imported definitions.  Otherwise the feature studio sees your enums, but the part studio that's supposed to be supplying them to the feature does not.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • adamohernadamohern Member, OS Professional Posts: 216 PRO
    export import(path : "goober", version : "goobergoober");

    Like this?? Weird. Okay.
  • ilya_baranilya_baran Onshape Employees, Developers, HDM Posts: 1,175
    I know it looks weird, but if you read it as "import all symbols exported from 'goober' and re-export them", I think it makes sense.
    Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc
  • adamohernadamohern Member, OS Professional Posts: 216 PRO
    I guess this springs from my not fully understanding what "export" does. I guess I assumed it was something like the "global" flag in some other languages.

    The idea of needing to "re-export" something feels odd to me. If something is exported inside goober, I would expect it to be likewise in any script that imports it.

    Again, being used to Python and PHP, I'm accustomed to these things being really straightforward: if you import a file, you import its namespace. Apologies if this kind of thing is standard practice in other languages.
  • traveler_hauptmantraveler_hauptman Member, OS Professional, Mentor, Developers Posts: 419 PRO
    Maybe the hover-help for import and export could explain this.
Sign In or Register to comment.