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.
FeatureRequest: FeatureScript expanded to Assembly and/or drawings
Artis_Johnson
Member Posts: 2 ✭
I was walking through the documentation for FeatureScript. I realized that it only functions within the Part Studio. Is there any way that the FeatureScript could be expanded into Assembly and Drawing? Is this something that is being looked into?
There could be created functions that operated between the parts, assemblies and drawings.
There could be created functions that operated between the parts, assemblies and drawings.
Tagged:
5
Comments
Assemblies are not histories. They are collections of parts brought in from PartStudios and constraints between the parts. So while there could be scripting for assemblies, it's not clear it would operate the same way as scripts in a PartStudio.
This is not to dismiss your request, but just a preamble to: what sorts of things would you like to do in Assembly with scripting, that can't be done effectively either with configurations or by scripting in the PartStudio and bringing in the parts thus created.
Same question for Drawings.
I'd love to hear some examples.
www.virtualmold.com
I think they are two good characteristics to start playing in the Assemblies ...
Getting FeatureScript to automate Assemblies and Drawings is much trickier than it would seem. For Part Studios, the feature list is a program and the geometry is its output, which we compute whenever we don't have it and need to display it. For Assembly and Drawing automation, you want FeatureScript to be able to control which parts and drawing elements appear where. That means either having the FeatureScript run on the user's command and modify the tab definition or we would have to introduce some sort of regeneration aspect to these tabs. The former is not super-convenient and the latter is quite challenging.
As for the requests listed, Mirror is something that we definitely plan to have, so no need for automation there. Measure value is interesting: if you automatically assign the distance between two parts to a variable, presumably you want to be able to use that variable to constrain things in the same assembly, causing a circular definition loop. We do plan to make reusing variables easier, so hopefully, we'll be able to measure in-context and then use the measured value in the assembly. That's probably easier to control than via assembly automation.
Auto layout is a good example of the type of thing one might want in assembly automation (although of course there are special nesting apps for this type of thing). What are some other examples? If we had some compelling real-world potential use cases, that would help us narrow down the design space.
I think its somewhat difficult to come up with very compelling use cases without knowing exactly what the capabilities are (I know that's some circular logic, unfortunately), but I'm always amazed at what people come up with for featurescript in part studios. A few things that do come to mind for me:
Our FS script could easily place a mate connector on the part in the centre of the cutout hole and the assembly automation could have a rule saying insert handle to all mate connectors called "handle1234" which are not already mated, insert a catch to those named "catch1234" etc. etc.
Kind of like replicate command but with a ruleset, based on mate names part-refs and explicitly has to be invoked by the user just like replicate.
Other rules which could be useful would be something like insert a rivet into all 4.2mm diameter holes which do not already have one.
FeatureScript, an amazing invention, is based on History. And this is why it does a poor job of handling sketches, because the paradigm is wrong. OnShape Assembly again is based on concurrent constraint solving, and FeatureScript wants a sequential organization. This *can* technically be done, but by introducing a complexity to the assembly modeling scheme. This relates to what @ilya_baran was writing about circularity. If you want to add a scripting element to the system, you need to establish a history ordering within your assembly. At base this is hard because the existing paradigm allows at any moment to add a constraint between any two under-constrained subassemblies to modify the placement of both.
So what you might want then is to define part of the assembly as a collection of parts and constraints on them, and then add a Feature, with input maybe being a part or some subassembly, and maybe parameters the user defines, and the output is additional parts and additional constraints, or modifying some variable values of the input.
But we now have a history element in the middle of the assembly. When does the feature update its definition? Perhaps when any element of the input changes. But remember that assembly modeling allows at any moment to add a constraint, and that constraint might be between an input of the feature and an output of the feature, or things associated with either. And that constraint will naturally amend the input. And now we have a loop; one that could be avoided by fully constraining the input prior to even invoking the script, but obviously that kind of rule limits what can be done.
I imagine doing this for drawings ought to be much easier. A drawing consists of references to the model and other elements drawn about them, some of which, such as dimensions, are driven by the model. There isn't much history within the drawing system, so it would seem to be easy to define a Drawing Feature, taking inputs of whatever selection, and creating any geometry as outputs. Yet perhaps more useful would be deriving things from the model itself. If you do this, the key is to have an associative update. When the source of the feature changes, the feature must recreate its outputs. This doesn't seem hard to me, just needs OnShape to have this update mechanism.
www.virtualmold.com
www.virtualmold.com
Case 1: A custom configuration that automatically reach into inserted paths to see if it can configure them. Perhaps in the form of a query for a specific variable name + other characteristics of the part.
Case 2: Automatic generation of assembly part numbers based on the configuration values. In some projects I am looking at the selected over all length of the assembly is slapped to the end of the part number. This would become trivial. XYZ - #Length
Case 3: Lets imagine I create a part containing a sketch called "floorPlan" with a bunch of points. I drop it into my Assembly and every time I select a point in that sketch I get a list parts to insert there. I select one and have it automatically mated in place.
I'm a french teacher of engineering sciences. My students and I love Onshape and we use during our projects and even during my courses to illustrate mechanicals concepts. I abandoned Solidworks with no regrets...
...except for motion study !
The Animate function of a constrain (revolution for example) is wonderful and the ability to view the motion of all parts of a mechanism and navigate in the view is bluffing.
But in my courses and students activites, I have to talk about movements (motions ? Don't know the english difference...), trajectories, velocity and acceleration vectors.
It would be great if an assembly script language would allow us to create such objects in combination with animations.
Anyway, thanks a lot for this amazing product that Onshape is.
Thomas DUFOUR
Lycée Bernard Palissy
Saintes
FRANCE
Before I go off and write a script to make the entire chain/sprocket "assembly" in a part studio, is there a reason why I should not, other than doctrine?