Community
Meshmixer
Welcome to Autodesk’s Meshmixer Forums. Share your knowledge, ask questions, and explore popular Meshmixer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Very inconsistent results with mmapi.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
eliot543
172 Views, 2 Replies

Very inconsistent results with mmapi.

Hi I have two functions I've been testing and I've run into this problem for a long time. It seems that meshmixer returns diffrent results if you use key commands before. I wrote function test1 which does simple assigning object ids in scene to vector objects, theres one more function getCurrentId which will return id to selected right now object. By themselves they are working fine but when you try to run them one after  another in test3 getCurrentId starts acting up and returning not consistent values and more inconsistent it is as more you add key functions. I suspect it has something to do in the way keys are set because when I printed them out they all were 0. If anybody had this problem let me know.

 

Cheers

Labels (1)
2 REPLIES 2
Message 2 of 3
eliot543
in reply to: eliot543

It needed a bit of sleep time between functions to properly function.

Message 3 of 3
waqas_khan667898
in reply to: eliot543

Meshmixer is related to state management and possibly how input events (like key commands) are affecting the program's internal state. This could be particularly tricky when testing functions like test1 and getCurrentId if there are asynchronous processes or cached states that aren't being reset properly between function calls, especially after key events.

Here are some potential causes and troubleshooting steps to consider:

1. Key Event Handlers Interference:

  • If getCurrentId or test1 depends on object selection or the active state in Meshmixer, key events could modify that state, causing unexpected behavior. For example, certain key commands might alter the internal selection state or interfere with the rendering of object IDs.
  • Troubleshooting Tip: After running key commands, try resetting the scene or refreshing the selection state before running getCurrentId. You might need to clear any cached input or selections after each function call.

2. Timing and Asynchronous Behavior:

  • Meshmixer might have asynchronous processes (e.g., GUI updates, object loading) that can cause race conditions. When you run your functions in quick succession, the selection state might not be updated by the time getCurrentId runs.
  • Troubleshooting Tip: Introduce delays between key commands and function calls to ensure that Meshmixer has enough time to update the scene. You can add sleep timers or explicit event synchronization points between the two function calls.

3. State Resetting Issue:

  • When key commands modify the state of Meshmixer, they might affect global states like selected objects or active tools. If getCurrentId depends on these states, it might return inconsistent results based on the previous commands.
  • Troubleshooting Tip: Add print/debug statements to inspect the internal state before and after running key commands to ensure consistency.

4. Meshmixer's API and Selection State:

  • The inconsistency might be rooted in how Meshmixer's API is handling object selection, especially if it's interacting with the UI. If the API isn't reliably updating the active object after a key event, getCurrentId may give wrong or outdated information.
  • Troubleshooting Tip: Try explicitly re-selecting the object or reassigning the active object ID before calling getCurrentId.

5. Key Code Values Returning as Zero:

  • If key codes are printing as zero, it could indicate an issue with how Meshmixer is capturing or interpreting key input. This might happen if a key binding is missing or malfunctioning.
  • Troubleshooting Tip: Investigate if Meshmixer is handling key events properly. Verify that the key command bindings are correctly mapped and consistently trigger the expected actions.

If you're comfortable with debugging tools, attaching a debugger to the process to inspect live state changes or stepping through your code could also help uncover the issue.

Let me know if you'd like to explore specific areas in more detail!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report