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: 

how do I install python library like fonttools

3 REPLIES 3
Reply
Message 1 of 4
mark
698 Views, 3 Replies

how do I install python library like fonttools

I am trying to install and run the add-in surfacetext.py.  I downloaded the code, created a new add-in, and pasted in the code.  However I am getting the error "Import "fontTools" could not be resolved".  I opened a windows terminal and did "pip install fonttools" which succeeded.  This did not fix the error.  I suspect that the windows default python environment is not used by fusion360 add-ins.  Is this correct?

 

To make a long story shorter, how do I install a library for add-ins to use?

3 REPLIES 3
Message 2 of 4
masounmardini
in reply to: mark

Not sure if my information is still valid?

Once I found something like this, since Spider instead of VSCode, you must find Fusion 360 Python version Normally in in Webdeploy folder "%appdata%/local/Autodesk/webdeploy" find your latest python and install the library from Source, since PIP is not installed.
Normally when Fusion 360 update or change python version you will lose the installation of the library and you have to install it again!!!

this is a translate from Japanese website through google translate , expect to have problems, and it's done over MAC OS

 

For some reason (usually?) Python specific to Fusion, even if pip was installed it could not be used. If pip can be
used, it is done with pip install noise .
However, since it can not be done, I will build it manually and take it for installation.
First of all, I will grasp where Fusion puts the entity of python.
In my environment
/ Users / USERNAME / Library / Application \ Support / Autodesk / webdeploy / shared / PYTHON / 3.5.3c /
MAC64 / Python.framework / Versions / 3.5 / bin .
procedure
1. Get a set of noise source code from the URL or GitHub shown earlier.
2. I will put it on the desktop etc.
3. Start a terminal that python can run.
4. Moved inside the noise directory.
inside that
sudo / Users / USERNAME / Library / Application \ Support / Autodesk / webdeploy / shared / PYTHON / 3.5.3c /
MAC64 / Python.framework / Versions / 3.5 / bin / python setup.py build
next

sudo / Users / USERNAME / Library / Application \ Support / Autodesk / webdeploy / shared / PYTHON / 3.5.3c /
MAC64 / Python.framework / Versions / 3.5 / bin / python setup.py install
Then,

/ Users / USERNAME / Library / Application \ Support / Autodesk / webdeploy / shared / PYTHON / 3.5.3c /
MAC64 / Python.framework / Versions / 3.5 / lib / python 3.5 / site-packages / py3.5-macosx-10.6-intel.egg
↑ This kind of thing is generated.
This is okay.
Because I am addicted to various things,
/ Users / USERNAME / Library / Application \ Support / Autodesk / webdeploy / production /
2a93884b46c5eedb87c1f008a9d77b138ef905db / Api / Python / packages / . I wonder if I can manage to use pip.
Although I did it, it should end in less than 10 minutes if I know how to do it.
Let's restart Fusion as a matter of course.
Let's start Spyder from scripts and add-ins.
When adding noise to the script which changes the angle of the axis with the for statement as shown earlier

import math
import noise
import random
import adsk.core, adsk.fusion, adsk.cam, traceback
def run (context):
ui = None
.......

 

Message 3 of 4
BrianEkins
in reply to: mark

I tried using the fonttools add-in and it seems to have a lot of problems.  I've never used it before and find it strange if it did work at one point.  The main problem is that it's trying to do some things that are not supported in a parametric model.  I change my model to not capture the design history and then I had another problem where it was trying to create groups within the timeline and the timeline is only supported in a parametric design.  Regardless, the add-in needs quite a bit of work to get it functioning again.

 

Regarding your initial question of how to use external Python libraries, the fonttools add-in does do a good job of that.  It has a local copy of the Python library.  If you pull the zip file from Github you'll see there is a FontTools folder within the add-in folder. It is recommended that each script or add-in have its own local copy of whatever libraries it wants to use. Fusion uses Python in a different way than is typical.  Fusion has its own copy of Python and all scripts and add-ins share that copy of Python. A typical way to add libraries is to install them in the system path so the library is shared among all programs. You could install a library into the Fusion Python install but that is problematic because the location changes and is updated with each release. This is creates a problem where two add-ins want to use the same library but may not be using the same version of that library. By having your own local copy, you're able to have whatever version you want and have tested with.

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

I meant to say there are a lot of problems with the SurfaceText add-in, not the fonttools library.

---------------------------------------------------------------
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