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: 

Importing Image as Canvas Using API?

6 REPLIES 6
Reply
Message 1 of 7
kmknights
359 Views, 6 Replies

Importing Image as Canvas Using API?

Hello all. Is there any way to import a .jpg or .png image to a plane using the API? Trying to insert a reference image to go alongside our 3D model. So far we have found out how to insert an .svg onto a construction plane, however the image quality is extremely poor after the conversion (from .jpg to .svg) thus it no longer has landmarks that serve our purpose. If there is any way to get a .jpg with a canvas onto a plane using the API that would be exactly what we are looking for! 

 

Thank you for your help!

Tags (3)
Labels (1)
  • API
6 REPLIES 6
Message 2 of 7
BrianEkins
in reply to: kmknights

Unfortunately, that capability is not supported by the API. Hopefully, at some point in the future, but I don't know.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 7
kmknights
in reply to: BrianEkins

Ah, too bad to hear. Thank you for the response! My team and I hope to see this feature implemented sometime in the future.

Message 4 of 7
mitgandhi
in reply to: BrianEkins

import adsk.core, adsk.fusion, traceback

def run(context😞

try:

app = adsk.core.Application.get()

ui = app.userInterface

# Get the active design.

product = app.activeProduct

design = adsk.fusion.Design.cast(product)

root = design.rootComponent

# Get the path to the image file.

file_path = r"C:\path\to\image.png"

# Import the image into Fusion 360.

import_manager = design.importManager

import_options = import_manager.createImportOptions(file_path)

imported = import_manager.importToRootComponent(import_options)

ui.messageBox("Image imported successfully!", "Success")

except:

ui.messageBox("Failed to import image:\n{}".format(traceback.format_exc()), "Error")

Message 5 of 7
mitgandhi
in reply to: mitgandhi

The emoji has me posted by mistake.

Message 6 of 7
mitgandhi
in reply to: kmknights

import adsk.core, adsk.fusion, traceback

def run(context)

try:

app = adsk.core.Application.get()

ui = app.userInterface

# Get the active design.

product = app.activeProduct

design = adsk.fusion.Design.cast(product)

root = design.rootComponent

# Get the path to the image file.

file_path = r"C:\path\to\image.png"

# Import the image into Fusion 360.

import_manager = design.importManager

import_options = import_manager.createImportOptions(file_path)

imported = import_manager.importToRootComponent(import_options)

ui.messageBox("Image imported successfully!""Success")

except:

ui.messageBox("Failed to import image:\n{}".format(traceback.format_exc()), "Error")

Message 7 of 7
BrianEkins
in reply to: mitgandhi

What is this sample supposed to be? It doesn't work and is calling a function that doesn't exist.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report