Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with component rotation? #8

Open
ModischFabrications opened this issue Aug 29, 2021 · 9 comments
Open

Issues with component rotation? #8

ModischFabrications opened this issue Aug 29, 2021 · 9 comments
Labels
bug Something isn't working

Comments

@ModischFabrications
Copy link

ModischFabrications commented Aug 29, 2021

It seems like finger joints in sub-components are calculated without respecting the rotation/movement of sub-assemblies. The screenshot should show everything, feel free to ask for more details if needed.

image

@FlorianPommerening
Copy link
Owner

Hmm, interesting. I tested with rotated bodies and saw no issue, so it has to be related to sub-assemblies. Can you let me know the steps to reproduce this bug?

@ModischFabrications
Copy link
Author

I created a component, created a body based on a scetch inside of it, then rotated and moved the whole subassembly, then tried to generate the finger joints. My picture shows the difference in origins, do note the rotation.

I think I "captured" the new position of the subcomponent, but I'm not sure. I would need to recreate it in a new project if you are unable to reproduce it based on my previous paragraph.

@FlorianPommerening
Copy link
Owner

OK, so both bodies are inside the same subassembly? Did you rotate the subassembly and create the joint while it was the active component or was the root component active?

I'll try to reproduce this but it might be a while until I get around to it. I only work on this project in my spare time.

@FlorianPommerening FlorianPommerening added the bug Something isn't working label Sep 2, 2021
@FlorianPommerening
Copy link
Owner

I found one possible cause of this is if pieces are moved and their position is not captured before the command executes. The fix is simply to declare the command as "position dependent". This makes Fusion prompt the user for either capturing the position of moved pieces or reset them. There is a good explanation of why this is necessary here: https://www.youtube.com/watch?v=ZlfSFnj46gY

@ModischFabrications, could you check if this solves your issue? The updated code is not merged in the main branch yet, in case there are more cases where the rotation causes an issue. You can find it in branch "issue8": https://github.com/FlorianPommerening/FingerJoints/archive/refs/heads/issue8.zip

@ModischFabrications
Copy link
Author

ModischFabrications commented Oct 4, 2021

Sorry, I don't get to CAD very often. Looks like the issue persists:

image

I drag-and-dropped the plugin into the directory and restarted fusion, so I'm more or less positive that the fix doesn't fix the problem.

There was no prompt for saving the position, it seems like the component was already fixed in position.

@FlorianPommerening
Copy link
Owner

FlorianPommerening commented Oct 5, 2021

In that case there must be some other way of rotating parts that I'm not aware of. Can you create a minimal working example to demonstrate the bug and list the steps to recreate it? You already did this earlier and wrote

I created a component, created a body based on a sketch inside of it, then rotated and moved the whole subassembly, then tried to generate the finger joints.

If I follow these steps, after rotating and moving the part, I get the prompt for capturing the position. How did you create the second body (inside the component or outside or in its own component, before rotation or after)? How exactly did you do the rotation? Which component was active for which operation?

@ModischFabrications
Copy link
Author

  1. Create component
  2. Activate component
  3. Model two bodies in subcomponent
  4. Move/Rotate component, capturing position
  5. Apply finger joints -> wrong direction
    image

@FlorianPommerening
Copy link
Owner

Thanks, that helped me to recreate the issue. I'm not sure yet what a good solution would be but if you want a quick fix, you can try to edit the file FingerJoints.py and replace this

    def createCustomFeature(self, body0, body1, toolBody0, toolBody1):
        app = adsk.core.Application.get()
        activeComponent = app.activeProduct.activeComponent
        # We will later group all created features into a custom feature.
        # For that reason, we have to remember the first and last feature that is part of this group.
        tool0Feature = createBaseFeature(activeComponent, toolBody0, "tool0")
        createCutFeature(activeComponent, body0, tool0Feature)
        tool1Feature = createBaseFeature(activeComponent, toolBody1, "tool1")
        createCutFeature(activeComponent, body1, tool1Feature)

with this

    def createCustomFeature(self, body0, body1, toolBody0, toolBody1):
        app = adsk.core.Application.get()
        activeComponent = app.activeProduct.activeComponent
        rootComponent = app.activeProduct.rootComponent
        # We will later group all created features into a custom feature.
        # For that reason, we have to remember the first and last feature that is part of this group.
        tool0Feature = createBaseFeature(rootComponent, toolBody0, "tool0")
        createCutFeature(activeComponent, body0, tool0Feature)
        tool1Feature = createBaseFeature(rootComponent, toolBody1, "tool1")
        createCutFeature(activeComponent, body1, tool1Feature)

This will create the tool bodies used to cut the fingers in the root component instead of the active component. Not ideal for an organizational aspect but it got rid off the error for me. I want to keep this issue open and look for a better solution where the tool bodies are created in the active component.

@FlorianPommerening
Copy link
Owner

For later reference: there are two issues with creating the component inside the active component instead of the root component. I asked about them on the forums.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/transformation-when-adding-a-brepbody-in-component/td-p/10677775

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/problem-when-adding-a-brepbody-in-the-copy-of-a-component/td-p/10678752

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants