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.

Adding items to composite part

glen_dewsburyglen_dewsbury Member, OS Professional Posts: 141 PRO
Have been trying to add a mass to a composite part based on feature script 'set mass'.
Can anything besides native features be added to composite parts.
The imported document is an STL file of an engine. No mass included.

Comments

  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,566
    @glen_dewsbury

    Custom features can operate on composite parts but it is likely that if the 'set mass' custom feature does not allow them as a selection, then that feature is setting is accidentally filtering them out with the selection filter on the selection box in question.  I think that feature has been around since before composite parts, so it's likely that it was just not possible to account for this at the time of its writing. If you post the link to that custom feature here, we can confirm and '@' the owner to see if they want to make a change.
    Jake Rosenfeld - Modeling Team
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,566
    @glen_dewsbury

    Looks like this doc is private.  If it is your document and you are writing the FeatureScript, you will just have to allow BodyType.COMPOSITE in your selection filter, and then when you want to pass this into some evaluation function, you should wrap the selection query like so:
    qBodyType(qFlattenedCompositeParts(definition.userSelection), BodyType.SOLID)
    assuming you just want to call the evaluation on the solid bodies contained by the composite part (remember composite parts can also contain sheets and curves).


    If you would like us to look at your document please either make it public so we can see it and discuss on this forum, or contact support from the '?' menu of your part studio.
    Jake Rosenfeld - Modeling Team
  • glen_dewsburyglen_dewsbury Member, OS Professional Posts: 141 PRO
    Haven't done any scripting myself to date. This is a copy from who I don't remember. I have made public and shared with support.
    Actually added a solid to the part studio which took on the weight from catalog along with location. Quite handy when provided doc is STL or some other form that contains nothing but surfaces. Wanting the new feature to be included with composite part. 
    https://cad.onshape.com/documents/46fe6ca7bf68dfd04e9eb944/w/8bf3c5e4b8115f4ec334249d/e/77324e0deb6bcea7e091d0b6
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,566
    edited February 17
    Looks like this feature was written by @richard_marcus :
    https://cad.onshape.com/documents/18b35cfcf2c6cf5668830f90/w/15216769574e8a81c923173f/e/8542061b7f92df44aaba5399

    A tip @glen_dewsbury :
    You don't have to copy a document to use the custom feature it provides.  It is actually worse to do so because you will not have the opportunity to take advantage of any of the changes made by the original feature author.  You can just add this custom feature by going to the original document and pressing the '+ custom features' button at the top.

    That being said, we can wait and see if Richard shows up and makes the adjustment mentioned above, otherwise I can walk you through the changes necessary to make in your copy.
    Jake Rosenfeld - Modeling Team
  • glen_dewsburyglen_dewsbury Member, OS Professional Posts: 141 PRO
    Thanks Jake. If I remember correctly I was planning to use as a sample to try my hand at scripting but got drawn off in an other direction as usual. That's why the copy.
    Will wait for a bit and see if Richard shows up.
  • MBartlett21MBartlett21 Member Posts: 1,833 EDU
    @glen_dewsbury
    @Jake_Rosenfeld
    I believe they are actually both copies of my own FeatureScript: https://cad.onshape.com/documents/3ca261a95938af152088fca8
    I have just updated my own FeatureScript to allow BodyType.COMPOSITE
    MB - I make FeatureScripts: View FeatureScripts
  • owen_sparksowen_sparks Member, Developers Posts: 2,660 PRO
    Business Systems and Configuration Controller
    HWM-Water Ltd
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,566
    Nice one @MBartlett21 sorry I missed that it was one of yours.

    Does evVolume work correctly on a composite part if the part contains solids and surfaces though?  See above my suggestion to flatten the composite and only take the solids.
    Jake Rosenfeld - Modeling Team
  • glen_dewsburyglen_dewsbury Member, OS Professional Posts: 141 PRO
    Thanks MB
  • MBartlett21MBartlett21 Member Posts: 1,833 EDU
    edited February 19
    Nice one @MBartlett21 sorry I missed that it was one of yours.

    Does evVolume work correctly on a composite part if the part contains solids and surfaces though?  See above my suggestion to flatten the composite and only take the solids.
    @Jake_Rosenfeld

     It works perfectly!
    According to evVolume's documentation, it doesn't error if there is anything apart from solids in the query. For example, it will still work if I give it a surface and solid part.
    MB - I make FeatureScripts: View FeatureScripts
  • Jake_RosenfeldJake_Rosenfeld Moderator, Onshape Employees, Developers Posts: 1,566
    Nice!
    Jake Rosenfeld - Modeling Team
Sign In or Register to comment.