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

Question: How to use PersistentCoordSystem?

antlu65antlu65 Member Posts: 61 EDU
edited July 3 in FeatureScript

Looking for some clarification on how to use the PersistentCoordSystem type to track transformations applied to an entity.

I've set up a document with a minimal example here to illustrate my confusion.

In the document, I have created a new PersistentCoordSystem and assign it to a body entity by setting an attribute on the entity.

I then apply a transform to the body entity.

Now, when I retrieve the PersistentCoordSystem from the attribute attached the entity, the value of the PersistentCoordSystem does not appear to be updated or reflect the transform applied to the entity. If anyone could, please point me in the right direction.

(Documentation for PersistentCoordSystem)

Comments

  • jnewthjnewth Member, OS Professional Posts: 57 PRO

    You're working against a few challenges here:

    1. The persistent coord system stuff is not well-documented.
    2. FS type system is weird.
    3. Type system fails in weird ways when used in conjunction with setAttribute. I filed a bug on this a while back so maybe @_anton can add some detail / correct my ignorance.

    Here's a few things I did to your example:
    1. Attach the persistentCoordSys to a face, not a body.

    2. Wrap your id with toString(id + "whatever"); the persistent cs stuff takes a string not an id. This is not consistent with most of the std library but that's how it is.

    3. When recovering the coordinate system at the end, you have to make up for the attribute system stripping your type tags. A coordinate system is a map with keys "origin", "xAxis", and "zAxis". The origin is a point in real space, so it has units. So it's a Vector of ValueWithUnits. The axes are just directions, so they are just Vectors of numbers. When the attribute system returns it to you, the origin, xAxis, and zAxis are returned as arrays - not at all what you want. So you have to recreate the coordinate system by reapplying type tags.

    This makes it work:

    000135.png


    Check it out: https://cad.onshape.com/documents/9f0d51b5b054698f3b0dcec2/w/08edea7dd826af4c3dceff92/e/aea4ec9ab6007589bef2a9f4

  • antlu65antlu65 Member Posts: 61 EDU

    Perfect, exactly what I was looking for, thank you!

Sign In or Register to comment.