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.

Options

FeatureScript: Bounding Box Sketch

2»

Answers

  • Options
    john_mcclaryjohn_mcclary Member, Developers Posts: 3,896 PRO
    Answer ✓
    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
  • Options
    john_mcclaryjohn_mcclary Member, Developers Posts: 3,896 PRO
    edited June 2018
    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.
    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!
  • Options
    MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,034 EDU
    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
    @john_mcclary

    It doesn't calculate the exact smallest (as that would take a long time). Instead, it calculates it to the nearest degree. :)
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • Options
    mahirmahir Member, Developers Posts: 1,291 ✭✭✭✭✭
    john_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!
    No worries. I do get the occasional downvote. I even have a random abuse flag under my belt  :D But thanks!
  • Options
    john_mcclaryjohn_mcclary Member, Developers Posts: 3,896 PRO
    @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 time
  • Options
    john_mcclaryjohn_mcclary Member, Developers Posts: 3,896 PRO
    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...
    Now that we can set custom properties in FS, now I can revisit the mass properties FS I was attempting before.

    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?
  • Options
    konstantin_shiriazdanovkonstantin_shiriazdanov Member Posts: 1,221 ✭✭✭✭✭
    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
  • Options
    john_mcclaryjohn_mcclary Member, Developers Posts: 3,896 PRO
    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?
  • Options
    john_mcclaryjohn_mcclary Member, Developers Posts: 3,896 PRO
    oh snap! that's right.

    Guess I'll have to look into doing that for the first time too :)

    thanks for that hint @emagdalenaC2i
  • Options
    owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    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 Ltd
  • Options
    MBartlett21MBartlett21 Member, OS Professional, Developers Posts: 2,034 EDU
    @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
    mb - draftsman - also FS author: View FeatureScripts
    IR for AS/NZS 1100
  • Options
    john_mcclaryjohn_mcclary Member, Developers Posts: 3,896 PRO
    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:

  • Options
    kevin_o_toole_1kevin_o_toole_1 Onshape Employees, Developers, HDM Posts: 565
    @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.

Sign In or Register to comment.