Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Image 2 Surface Script for Fusion 360

79 REPLIES 79
SOLVED
Reply
Message 1 of 80
hanskellner
21512 Views, 79 Replies

Image 2 Surface Script for Fusion 360

I've created a script for Fusion 360 that can be used to import an image and convert it to a mesh, sketch points, or sketch lines.

 

The following heightmap image of a portion of the moon was used to generate the following mesh and then t-spline:

 

Moon.jpg => MoonMesh.png => MoonTSpline.png

 

The t-spline version is the most flexible for changes and it can also be used in the CAM environment for milling.

 

The code and information is posted on Github:

 

https://github.com/hanskellner/Fusion360Image2Surface 

 

Note, because of limitations in Fusion on the size of meshes, I highly recommend using only very small images. For example, the moon image above is only 50x50 pixels. If you have an image that's large then create a smaller version of it then import that.

 

Cheers,

 

Hans



Hans Kellner
Senior Manager, Principal Engineer
79 REPLIES 79
Message 41 of 80
hanskellner
in reply to: stevempotter

Hi Steve - 

 

It sounds like a default add-in was created and that is what you might be running.  Also, I see that the add-ins path you list is different than the path indicated in the install steps.  See install info here:

https://knowledge.autodesk.com/support/fusion-360/troubleshooting/caas/sfdcarticles/sfdcarticles/How...

 

Please verify that the files are installed in a folder named "Image2Surface" under the AddIns folder.  Then try adding that to your addins list.  When installed correctly, it should be displayed as "Image2Surface" in your add-ins list.

 

Let me know how it goes.

 

Thanks,

 

Hans

 

 



Hans Kellner
Senior Manager, Principal Engineer
Message 42 of 80
stevempotter
in reply to: hanskellner

Still not sure what I am doing wrong...

Here is the path they specify in the instructions you linked:

___quote___


@hanskellnerwrote:

https://knowledge.autodesk.com/support/fusion-360/troubleshooting/caas/sfdcarticles/sfdcarticles/How...


Windows (web install):

  • Script: %appdata%\Autodesk\Autodesk Fusion 360\API\Scripts
  • Add-In: %appdata%\Autodesk\Autodesk Fusion 360\API\AddIns

___unquote___

 

C:\Users\USER\AppData\Local\Autodesk\Autodesk Fusion 360\API\Addins is where I had put it.

I guess it should it be in 

C:\Users\USER\AppData\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns ?

(forgive me, I don't know what "Roaming" and "Local" mean. I am new to Windows.)

It is an Addin, right? Not a Script?

I did put it all in a folder named Image2Surface.

I tried putting it in the folder with other Addins, 

C:\Users\USER\AppData\Local\Autodesk\webdeploy\production\8556a3e1d81f6c5f0bca3f1440fbfa311d80a809\Api\InternalAddins\Image2Surface

and I get the same behavior.

It shows up, as before, and when I run it, it only pops up a small box that says "Hello addin", which I see is running the Image2Surface.cpp file in your Github package. So it is finding your C++ code, but nothing further happens. 

_quote_

#include <Core/CoreAll.h>
#include <Fusion/FusionAll.h>
#include <CAM/CAMAll.h>


using namespace adsk::core;
using namespace adsk::fusion;
using namespace adsk::cam;

Ptr<Application> app;
Ptr<UserInterface> ui;

extern "C" XI_EXPORT bool run(const char* context)
{
app = Application::get();
if (!app)
return false;

ui = app->userInterface();
if (!ui)
return false;

ui->messageBox("Hello addin");

return true;
}

[...]

_unquote_

 

Message 43 of 80
hanskellner
in reply to: stevempotter

Ah, I realized now that the path you are using is correct.  The %appdata% portion is a macro that expands to the correct prefix.  Therefore that's not the problem.

 

But the issue that you are seeing C++ code rather than Python (.py extension) is a problem.  Please check that the folder you placed the files is empty.

 

To verify:

 

  1. Grab the add-in files from this Github repo:
  2. Extract the files and place them in an empty folder named "Image2Surface"
  3. In the Scripts and AddIns dialog, select AddIn then the "+" button then select the Image2Surface folder

There should be not be any reference to C++ files for this AddIn.



Hans Kellner
Senior Manager, Principal Engineer
Message 44 of 80
stevempotter
in reply to: hanskellner

Thanks, Hans. I got it working now - Yay!

I guess the problem was that I clicked the Create button after adding the Addin. I think it overwrote yours with a generic one.

Message 45 of 80
hanskellner
in reply to: stevempotter

Glad you were able to get it installed and running.  Hopefully it serves your needs.

 

Hans



Hans Kellner
Senior Manager, Principal Engineer
Message 46 of 80
Anonymous
in reply to: hanskellner

How do I go about downloading this script on github? I’m new to github and have no idea what I’m doing. Thanks
Message 47 of 80
hanskellner
in reply to: Anonymous

The add-in needs to be downloaded from Github.  Go to the Github location for the add-in:
https://github.com/hanskellner/Fusion360Image2Surface

Then locate and click the "Clone or download" button.  With the popup, click the "Download ZIP" button.  This should download a ZIP archive file to your computer where you may then unarchive the files.


Screen Shot 2018-05-03 at 5.07.16 PM.png

A folder should have been created with a name that matches the archive filename.  Typically it's "Fusion360Image2Surface-master".  Rename this folder to "Image2Surface".  At this point, follow the instructions from the online help:
https://knowledge.autodesk.com/support/fusion-360/troubleshooting/caas/sfdcarticles/sfdcarticles/How...

 

Also, there's a utility to automate all this that's on the App store.  I haven't used it but others have recommended using it for installing from Github:
https://apps.autodesk.com/FUSION/en/Detail/Index?id=789800822168335025&appLang=en



Hans Kellner
Senior Manager, Principal Engineer
Message 48 of 80
hanskellner
in reply to: hanskellner

ALL - The add-in has been updated.  Changes include:

  • Added a button for loading an image file using a file browser.  This is an option to using drag & drop.
  • Cleaned up UI, cleaner wording.
  • Various small defect fixes.

Please grab the code from Github, extract and overlay over your existing installation.

 

https://github.com/hanskellner/Fusion360Image2Surface 

 

The files that have changed are:

  • Image2Surface.html
  • js/image2surface.js
  • css/style.css

Cheers!



Hans Kellner
Senior Manager, Principal Engineer
Message 49 of 80
Anonymous
in reply to: Anonymous

Hi, I have exactly the same error.

 

How did you fix it. I mush be a bit slow. I didn't get the Base Feature Thing???

 

Could you please put it as basic as you can so us slow people can understand how to fix.

 

Thanks Colin 🙂

Message 50 of 80
Anonymous
in reply to: Anonymous

Hi. Can you explain a bit more, I have the same error???

Message 51 of 80
Anonymous
in reply to: hanskellner

i cant find add in folder and fusion 360 is under local apps not programs

Message 52 of 80
hanskellner
in reply to: Anonymous

 

On Windows, the add-in folder should be located here:

  • Add-In: %appdata%\Autodesk\Autodesk Fusion 360\API\AddIns

Please see this article for help installing an add-in:

 

https://knowledge.autodesk.com/support/fusion-360/troubleshooting/caas/sfdcarticles/sfdcarticles/How...

 



Hans Kellner
Senior Manager, Principal Engineer
Message 53 of 80
RandyKopf
in reply to: hanskellner

@hanskellner and everyone else...

As simple as the install was... sort of joking... I actually was NOT evoking the actual script. 

Call me newbie or n00b or whatever...

 

What I was missing after installing the script was so simple I needed to launch or evoke the script...

 

Here is what I found I was missing...

 

1) I had to select DESIGN MODULE select the TOOLS tab...

2) Select ADD-IN's

 

 Image2SurfaceEvoke.png

3) You should see "Show Image to Surface" appear... That is IF you installed the script correctly... 

Select "Show Image to Surface" and its custom interface should launch after that selection...

That launches this interface... The rest is obvious history...

Image2SurfaceInterface.png

I hope this helps...

Thank you @hanskellner for an amazing tool that I hope one day is built into Fusion 360 as a standard function!!!

Randy 🙂

Randy Kopf 

http://desktopartisan.blogspot.com/


If my post is helpful, press the LIKE Button If it resolves your issue, press Accept as Solution! Have a great day!
Message 54 of 80
hanskellner
in reply to: RandyKopf

Really glad you got it working!  And appreciate your contribution of how to get it running.  I'm sure you aren't the only one that has run into that confusion.

 

Hans



Hans Kellner
Senior Manager, Principal Engineer
Message 55 of 80
RandyKopf
in reply to: hanskellner

Hanskellner you made us an excellent tool!!! thank you for doing this and
what you've done to make an awesome addition to Fusion 360!!!

Randy Kopf 

http://desktopartisan.blogspot.com/


If my post is helpful, press the LIKE Button If it resolves your issue, press Accept as Solution! Have a great day!
Message 56 of 80
JeromeBriot
in reply to: hanskellner

@hanskellner, you can modify the code to display the message below when the user runs the add-in for the first time:fusion-360-add-in-install-information.png

 

Here is the modified run function:

 

def run(context):
    try:
        global _ui, _app
        _app = adsk.core.Application.get()
        _ui  = _app.userInterface

        # Add a command that displays the panel.
        showPaletteCmdDef = _ui.commandDefinitions.itemById('showImage2SurfacePalette')
        if not showPaletteCmdDef:
            #strTooltip = '<div style=\'font-family:"Calibri";color:#e0e0e0; padding-top:-10px; padding-bottom:10px;\'><span style=\'font-size:20px;\'><b>Image 2 Surface</b></span></div>Use this add-in to convert an image into a surface (mesh).'
            showPaletteCmdDef = _ui.commandDefinitions.addButtonDefinition('showImage2SurfacePalette', 'Show Image 2 Surface', '', './/Resources//image2surface')
            showPaletteCmdDef.toolClipFilename = './/Resources//image2surface//image2surface-tooltip.png'

            # Connect to Command Created event.
            onCommandCreated = ShowPaletteCommandCreatedHandler()
            showPaletteCmdDef.commandCreated.add(onCommandCreated)
            handlers.append(onCommandCreated)

        # Add the command to the toolbar.
        panel = _ui.allToolbarPanels.itemById('SolidScriptsAddinsPanel')
        cntrl = panel.controls.itemById('showImage2SurfacePalette')
        if not cntrl:
            panel.controls.addCommand(showPaletteCmdDef)

        if context['IsApplicationStartup'] is False:
            _ui.messageBox('The "Image2Surface" command has been added\nto the ADD-INS panel of the MODEL workspace.')

    except:
        if _ui:
            _ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Message 57 of 80
hanskellner
in reply to: JeromeBriot

Hi Jerome - 

 

Good suggestion!  I've integrated the change into the code and published the update to Github:

 

https://github.com/hanskellner/Fusion360Image2Surface 

 

Thanks for your help.

 

Hans



Hans Kellner
Senior Manager, Principal Engineer
Message 58 of 80
zimri2000
in reply to: hanskellner

I am trying to use this add-in and it is all installed. When I try to run it I get an error saying it is not WebGL compatible. If I run the .html file in chrome and firefox (outside of fusion360) it seems to run fine. Do you know if there is a way to change what browser Fusion360 is using? My default browser for Windows 10 is Chrome, so F360 is not using that. I think it is an issue with Microsoft Edge.

 

Thanks

Brendan

Message 59 of 80
hanskellner
in reply to: zimri2000

Hi @zimri2000 -

 

I've not come across that issue yet.  Will check into that and post back.

 

Thanks,

 

Hans



Hans Kellner
Senior Manager, Principal Engineer
Message 60 of 80
hanskellner
in reply to: zimri2000

Hi Brendan - 

 

I've not found a solution yet nor able to reproduce.  But I did find information about a similar issue:

https://knowledge.autodesk.com/support/fusion-360/troubleshooting/caas/sfdcarticles/sfdcarticles/Err...

 

The suggested solution is to update your graphics driver.  Please see if that solves your problem.

 

Thanks



Hans Kellner
Senior Manager, Principal Engineer

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

Post to forums  

Technology Administrators


Autodesk Design & Make Report