windows add-on to macOS conversion

windows add-on to macOS conversion

vampiro2004
Enthusiast Enthusiast
761 Views
6 Replies
Message 1 of 7

windows add-on to macOS conversion

vampiro2004
Enthusiast
Enthusiast

Hello,

 

I have got an add-on that works fine under windows but does not in MacOS, it shows up in the add-ins but will not run.

 

Is there an easy way to convert it from windows to Macos? if so how.

 

many thanks

0 Likes
Accepted solutions (1)
762 Views
6 Replies
Replies (6)
Message 2 of 7

BrianEkins
Mentor
Mentor

If it's written using Python, it should work on both Windows and Mac, unless it's using some functionality specific to the Windows OS. If that's true, then that part of it must be changed to do the same thing for Mac OS.

 

If it's written in C++, the source code will need to be recompiled to be compatible for Mac. There's also the same question of whether it does anything that is Windows-specific or not.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 7

vampiro2004
Enthusiast
Enthusiast

@BrianEkinsthank you for replying.

 

am i able to send you the bundle to have a look at and advise what needs to be changed?

0 Likes
Message 4 of 7

BrianEkins
Mentor
Mentor

Without you sending me the bundle, you can do a couple of quick things. Using File Explorer, go to the .bundle folder, open the "Contents" folder. There will be a file <addinName.manifest> and there will also be another file using the <addinName.something>. What is the "something" in your case.  If it's "dll" then the add-in is written in C++ and there's nothing you can do to make it compatible with Mac without the source code.

 

If the "something" is "py," then it's written using Python, and it's likely there is something in the code that is Windows-specific, making it difficult to easily move to Mac.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 7

vampiro2004
Enthusiast
Enthusiast

@BrianEkins

 

there is a py file with the manifest file, this is what is in the py file

import os
import shutil
import glob
import filecmp
import adsk.core, adsk.fusion, adsk.cam

# Global variable to hold Fusion 360 application and user interface
app = adsk.core.Application.get()
ui = app.userInterface

def find_all_fusion_thread_directories():
    # Locate the Autodesk Fusion 360 web deployment directory
    user_app_data = os.getenv('LOCALAPPDATA')
    fusion_base_dir = os.path.join(user_app_data, 'Autodesk', 'webdeploy', 'production')
    
    # Search for all ThreadData folders
    thread_data_paths = glob.glob(fusion_base_dir + '/**/ThreadData', recursive=True)
    
    # Return a list of all found ThreadData paths
    return thread_data_paths

def add_custom_thread_profiles():
    try:
        # Find all Fusion 360 ThreadData directories
        fusion_thread_dirs = find_all_fusion_thread_directories()
        if not fusion_thread_dirs:
            ui.messageBox("No Fusion 360 ThreadData directories found.")
            return

        # Get the path to the 'data' folder within the add-in's directory
        script_dir = os.path.dirname(os.path.realpath(__file__))
        data_dir = os.path.join(script_dir, 'data')

        # Collect all XML files in the 'data' folder
        if not os.path.exists(data_dir):
            ui.messageBox("The 'data' folder was not found in the script's directory.")
            return
        
        xml_files = [f for f in os.listdir(data_dir) if f.endswith('.xml')]
        if not xml_files:
            ui.messageBox("No XML thread files found in the 'data' folder.")
            return

        # Track if any files were copied
        files_copied = False
        copied_files_list = []

        # Copy each XML file to all ThreadData directories only if different or missing
        for fusion_thread_dir in fusion_thread_dirs:
            for file_name in xml_files:
                source_file = os.path.join(data_dir, file_name)
                destination_file = os.path.join(fusion_thread_dir, file_name)
                
                # Check if the file already exists and is identical
                if not os.path.exists(destination_file) or not filecmp.cmp(source_file, destination_file, shallow=False):
                    shutil.copyfile(source_file, destination_file)
                    files_copied = True
                    copied_files_list.append(destination_file)
                    print(f"Copied {file_name} to {fusion_thread_dir}")

        # Show a message only if files were copied
        if files_copied:
            ui.messageBox(f"ISO Metric Thread Profiles for 3D Printing have been updated. (Arroway.ltd)")

    except Exception as e:
        if ui:
            ui.messageBox(f"Error: {e}")

# Required Fusion 360 functions for add-in management
def run(context):
    add_custom_thread_profiles()
    # Automatically stop the add-in after running
    stop(context)

def stop(context):
    pass  # No message box; add-in will stop silently after completion

 

0 Likes
Message 6 of 7

JeromeBriot
Mentor
Mentor
Accepted solution

The following line won't work on Mac:

user_app_data = os.getenv('LOCALAPPDATA')

 

Try this instead:

import platform
import os

if platform.system() == 'Windows':
    fusion_base_dir = os.path.join(os.getenv('LOCALAPPDATA'), 'Autodesk', 'webdeploy', 'production')
else:
    fusion_base_dir = os.path.join(os.path.expanduser('~'), 'Library', 'Application Support', 'Autodesk', 'webdeploy', 'production', 'Autodesk Fusion 360.app', 'Contents')

 

 

Message 7 of 7

vampiro2004
Enthusiast
Enthusiast

@JeromeBriot 

 

Many thanks that worked and it pops up the box to says installed, now just got figure out why the thread profiles wont show in the thread tool😅

0 Likes