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.
FeatureScript: Bounding Box Sketch
Answers
-
Indeed it does,
Thank you all for your help, I will use the following workflow:
1) Use: V4.7+ of https://cad.onshape.com/documents/2ce3e64026df1ac7e63b98bd/w/7a2029e15b241c80c591a492/e/466a1aa41fce0c0be07f6436
2) Calculate Smallest on flat pattern
3) Create a secondary sketch and "Use" the result of featurescript
4) Insert into drawings
5) Win
2 -
I noticed someone voted you down, so i added an up vote, turns out the down vote went away. I must have been me to down vote you by accident sorry @mahir!mahir said:I don't know of a pre-existing featurescript that does this, but I would think it's doable. It's just a matter of querying all flatpattern geometry, getting a 3dbox around it, and using the 3dbox parameters to draw a matching sketch. I'm busy at the moment, but I wouldn't be surprised if someone wants to take this and run with it.3 -
@john_mcclaryjohn_mcclary said:Indeed it does,
Thank you all for your help, I will use the following workflow:
1) Use: V4.7+ of https://cad.onshape.com/documents/2ce3e64026df1ac7e63b98bd/w/7a2029e15b241c80c591a492/e/466a1aa41fce0c0be07f6436
2) Calculate Smallest on flat pattern
3) Create a secondary sketch and "Use" the result of featurescript
4) Insert into drawings
5) Win
It doesn't calculate the exact smallest (as that would take a long time). Instead, it calculates it to the nearest degree.
0 -
No worries. I do get the occasional downvote. I even have a random abuse flag under my beltjohn_mcclary said:
I noticed someone voted you down, so i added an up vote, turns out the down vote went away. I must have been me to down vote you by accident sorry @mahir!
But thanks! 0 -
@mbartlett21 thats close enough, I was only able to get it to the nearest endpoint (sometimes tangent wouldn't work on the deformed arcs)
But before auto calculate, the FS wasn't even close
Now it's as close as I was without all the effort from me every time0 -
Now that we can set custom properties in FS, now I can revisit the mass properties FS I was attempting before.john_mcclary said:Today I am just manually adding weight to the properties by measuring each part just before release.
But I have began attempting to make a featurescript to do this automatically by:
evVolume(context, { "entities" : definition.bodyQuery })
then reading the material property (I hope I can extract a density from this directly from the material library.... but I doubt it)
Then I was going to multiply them together and save the result in my custom property.
But luckily I look ahead and saw I couldn't save to a custom property, so I have up after getting the volume...
So how would I get a part's weight in pounds in FS.. all I can see is volume (which is fine) but can't find where I can read a part's density.
or can I read the part weight directly from somewhere?0 -
you can get density form material property, then find the mass in kg and divide it on pound. and set it to your custom property of mass in pounds
0 -
i saw the material property in the documentation, but it looked like you can only set material.
I tried a few guesses like
density = definition.body.material.density;
but obviously I don't know the structure of a part to dig out that info.
can you give me the correct snippet of the code I attempted just now?0 -
whoops
Properties include name, appearance, material, and part number (see<a href="https://cad.onshape.com/FsDoc/library.html#module-properties.fs">PropertyType</a>). They can be set in FeatureScript, but not read.I actually missed this, and thought getProperty() function exists. so this mission is still impossible1 -
alas... like I thought.. Thanks @k@konstantin_shiriazdanovkonstantin_shiriazdanov said:whoops
Properties include name, appearance, material, and part number (see</code></a><code><a href="https://cad.onshape.com/FsDoc/library.html#module-properties.fs" title="Link: https://cad.onshape.com/FsDoc/library.html#module-properties.fs">PropertyType</a>). They can be set in FeatureScript, but not read.I actually missed this, and thought getProperty() function exists. so this mission is still impossible
0 -
well, actually the material and their density is set in a csv file... https://cad.onshape.com/documents/2718281828459eacfeeda11f/w/97628b48cc974c2681faacfc/e/6bbab304a1f64e7d640a2d7d
So, you can create a CSV reference parameter to read the material information ;-)Un saludo,
Eduardo Magdalena C2i Change 2 improve ☑ ¿Por qué no organizamos una reunión online?
Partner de PTC - Onshape Averigua a quién conocemos en común7 -
oh snap! that's right.
Guess I'll have to look into doing that for the first time too
thanks for that hint @emagdalenaC2i
0 -
Dun-dun, dun dun dun dun, biddelboo.... (That's the mission impossible theme for anyone not fluent in idiot.)
Thought we had that sussed, especially as there is a "copy properties" FS on @mbartlett21 's site, clicky, but alas it's cleverly creating a copy of the body and using some boolean functions to transfer the properties "blind" as it were rather than using a get / set transfer.
So close!
Owen S.
Business Systems and Configuration Controller
HWM-Water Ltd0 -
@john_mcclary
You can use this featurescript to set the material and the density or the weight and it can fill a custom property
https://cad.onshape.com/documents/3ca261a95938af152088fca8
0 -
I was looking at that one @mbartlett21
but that looks more like an override mass properties, which is useful for purchased parts.
but I'm looking for something that will read the result of this:
and put it here:
0 -
@john_mcclary
The reason Part Properties (like material) are not readable in FeatureScript is to ensure that changing these properties would not trigger a regeneration. Changes to properties are very common and can happen from outside the document. Generally people don't think of them as costly geometric operations, so it would be surprising if changing the name, part number, material, etc. triggered a lot of slow features to rerun.
The case you describe can be done with a custom feature where the user inputs the density, which is clearly not ideal. It can also be done with the API, which I imagine is also not ideal, since the code calling the API would require a separate server (which you run) to trigger these changes.
Do you want weight as a part property so that it can be displayed in the BOM? If so, I agree that would be great. If we were to implement this, it's possible we wouldn't implement it as a pure part property. We may want a separate concept on our side which lazily computes the mass for all assembly parts when requested, cached for better performance. The other advantage of this is that it would work on any part, not just parts with your special custom feature.
Long story short, custom property setting lets you get lots of things (including bounding dimensions) in the BOM as custom properties, but I don't consider https://forum.onshape.com/discussion/comment/44845 (adding part weight to the BOM) to be fully resolved by the custom property setting. Please continue voting for and commenting on that improvement request.
0







