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.

setProperty{ .... PropertyType.APPEARANCE...} face vs part priority?

S1monS1mon Member Posts: 3,039 PRO
[For background you may want to reference this thread]

I have a custom feature (call it "UM") which successfully sets the color of a part like so:

            setProperty(context, {
                        "entities" : entities,
                        "propertyType" : PropertyType.APPEARANCE,
                        "value" : theColor,
                        "allowFaces" : true
                    });

I'm also using @Evan_Reese 's Part Color (let's call it "PC") feature which uses basically the same setProperty code.

I have a part studio with both PC and UM features. If they both are setting part level colors, then whatever color gets set last (either through UM or PC) will be what the user sees. If either feature (UM or PC) sets faces, then the faces will override the part color, no matter what order the features are in.

Is this expected behavior with part and face color properties?

Is there anyway to code this differently so that part level colors override faces? (I assume I could iterate through all the faces and that would work, but I assume that will be slower than coloring the part)

Comments

  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    That is correct behaviour.
    Senior Director, Technical Services, EMEAI
  • S1monS1mon Member Posts: 3,039 PRO
    @NeilCooke
    Thanks for the quick answer to the first question (unfortunately not a surprise).

    Any thoughts on the second question?
  • EvanReeseEvanReese Member, Mentor Posts: 2,186 ✭✭✭✭✭
    I don't think you need to "iterate" over the faces (I read that as a for loop). You could just pass in a single query for all of the faces, I think. I've thought about adding this as an option to Part Color because sometimes imported parts already have face colors applied. I would still expect it to be less performant, but perhaps negligibly so. If you try a comparison, will you do me a favor and report back here?
    Evan Reese
  • NeilCookeNeilCooke Moderator, Onshape Employees Posts: 5,714
    Just use qOwnedByBody 
    Senior Director, Technical Services, EMEAI
  • S1monS1mon Member Posts: 3,039 PRO
    I could have sworn that I responded to this already, but here's the summary....

    I used
       var partFaces = qOwnedByBody(definition.parts, EntityType.FACE);

    I added a boolean option to color parts by faces or by part. A few interesting things:
    • If I color a part at the part level, it will not override previous face colors (as mentioned in previous posts)
    • Part color is used to drive the onscreen color of a cross-sectioned part
    • If I color by face, it does override the previous face colors, but then the internal part color (xsection) is whatever it was previously
    • With a test part that has 1249 faces, the color by part option takes 2ms, the color by face option takes 6ms
    • (with more simple test parts, there's no consistent time difference)
    • It's quite possible to color the part and its faces to override everything

  • eric_pestyeric_pesty Member Posts: 1,947 PRO
    S1mon said:
    I could have sworn that I responded to this already, but here's the summary....

    I used
       var partFaces = qOwnedByBody(definition.parts, EntityType.FACE);

    I added a boolean option to color parts by faces or by part. A few interesting things:
    • If I color a part at the part level, it will not override previous face colors (as mentioned in previous posts)
    • Part color is used to drive the onscreen color of a cross-sectioned part
    • If I color by face, it does override the previous face colors, but then the internal part color (xsection) is whatever it was previously
    • With a test part that has 1249 faces, the color by part option takes 2ms, the color by face option takes 6ms
    • (with more simple test parts, there's no consistent time difference)
    • It's quite possible to color the part and its faces to override everything

    That seems consistent with what I would have expected.
    Not sure it's relevant to your use case but you might want to keep that in mind, I believe if you added a feature to the part after running the FS, newly created faces would take on the part level color (eg: sides of a cut or a new extruded boss).
  • S1monS1mon Member Posts: 3,039 PRO
    Another thing that the part color (vs coloring all the faces) does: it sets the color of the bounding box that Onshape displays when it hasn't fully loaded all the graphics. I discovered this because all the sudden a bright green block showed up when loading a complex model, and then I remembered I had colored the part green, but then the surfaces gray.
Sign In or Register to comment.