import exported enum from another tab

adamohern
adamohern 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_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,278 image
    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
  • adamohern
    adamohern Member, OS Professional Posts: 216 PRO
    export import(path : "goober", version : "goobergoober");

    Like this?? Weird. Okay.
  • ilya_baran
    ilya_baran Onshape Employees, Developers, HDM Posts: 1,278 image
    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
  • adamohern
    adamohern 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_hauptman
    traveler_hauptman Member, OS Professional, Mentor, Developers Posts: 423 PRO
    Maybe the hover-help for import and export could explain this.