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

Editing logic: how to keep track of bodies and why are map keys changing?

jacob_kingeryjacob_kingery Member Posts: 39 EDU
In an editing logic function, I want to be able to determine which, if any, of the bodies selected in the dialog are the same as in the previous definition and retain some of the information from the previous definition for those bodies.  The only way I was able to get this working involved a nested loop comparing evaluated queries between the current definition and the previous, which feels rather inefficient.

To avoid this nested looping, I would like to create a lookup map from each body to an index that can be used to get the information for that body, but my attempts haven't worked out.  I was able to use evaluated queries for each body as keys in the map, but something happens to them between when I create the lookup map and when I try to use it the next time the editing logic function is run.
When I create the map, it looks like this:
{ { queryType : TRANSIENT , transientId : Tr:JHP } : 0 }

But then when this map is in the previous definition, the keys are changed to be like this:

{ JHP : 0 }

Somehow the keys are changing from the transient query itself to the transientId (without the 'Tr:' prefix?).

So, I guess there are a couple questions here.
1.  Is this a reasonable way to approach the problem of keeping track of bodies, or is there a different way that would be better?
2.  Why are the keys in my map changing, and what can I do about it?

Best Answer

Answers

  • Options
    jacob_kingeryjacob_kingery Member Posts: 39 EDU
    I can see how a qIntersection() could help a bit, but I don't think it could eliminate having to loop over things.  I was able to get the map working by using transientQueriesToStrings() to get just the ID strings (e.g. 'JHP') to use for the keys, but things ended up getting restructured to no longer use editing logic.
Sign In or Register to comment.