Welcome to the Onshape forum! Ask questions and join in the discussions about everything Onshape.
First time visiting? Here are some places to start:- Looking for a certain topic? Check out the categories filter or use Search (upper right).
- Need support? Ask a question to our Community Support category.
- Please submit support tickets for bugs but you can request improvements in the Product Feedback category.
- 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.
Writing text to a file?
adamohern
Member, OS Professional Posts: 216 PRO
Can a FeatureScript save text to a file in the project? This could be useful for analytical features that check geometry conditions, for example. It could also be useful for exporting BOM's and cut-lists.
4
Best Answers
-
ilya_baran Onshape Employees, Developers, HDM Posts: 1,211A custom feature can't modify anything other than the Part Studio it is in (see security under https://www.onshape.com/featurescript#start ).
But: FeatureScript is just one of the ways we'll have for customizing Onshape with code. Stay tuned!Ilya Baran \ VP, Architecture and FeatureScript \ Onshape Inc5 -
kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565In the mean time, an (admittedly terrible) solution is to print() results.
For the case of a feature which checks for geometry conditions, reportFeatureInfo() might also be what you want. It's intended for popping up short messages though — we'll truncate a message that gets too long.
5
Answers
But: FeatureScript is just one of the ways we'll have for customizing Onshape with code. Stay tuned!
For the case of a feature which checks for geometry conditions, reportFeatureInfo() might also be what you want. It's intended for popping up short messages though — we'll truncate a message that gets too long.
Part Studios in Onshape are intended to contain multiple parts in a single design environment. Importing those parts into an Assembly is useful for motion studies, but otherwise unnecessary.
My specific use-case is for framing: I can create a single FeatureScript that generates an entire frame. With only a few features I can build an entire house frame, for example.
Each framing feature keeps tabs of how much stock it uses when creating a given frame, and saves that information to a set of variables. Each new framing feature adds to those variables, so the totals are cumulative. At the end of the feature list I can add a single feature that reads those variables and outputs a BOM without ever needing to create an Assembly, and, more importantly, it can even create a very accurate cut-list, since it knows exactly what cuts were necessary (unlike an assembly, which could only ever create a simple list of parts).