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: 

Errors after the October update

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
Maciej_Rogowski
326 Views, 3 Replies

Errors after the October update

I noticed after the October update V.2.0.9305 that angle, boundaryLines, position, and referencedEntity of a SketchText object aren't available in the Python API.

Attribute "util" in the module "importlib" also isn't available and throws the AttributeError.

3 REPLIES 3
Message 2 of 4

This appears to be the behavior of the 'importlib' library. At least it is with version I've tried it in since 3.7. If in a new shell you just run:

import importlib
importlib.util # Fails!

 You will get this 'util' unknown attribute error. It is only if you directly import the util module that this works. It can be imported with something like 'import imporlib.util' or 'from importlib import util'. So the following will work:

import importlib.util
importlib.util # Works!

Note that the examples in the importlib documentation at https://docs.python.org/3/library/importlib.html all show a direct import of importlib.util like this. (Apparently looking at the package code and bootstrap code at https://github.com/python/cpython/tree/master/Lib/importlib, the util module is not loaded by package __init__.)

 

Now as to why this may have changed in your case... Note that if importlib.util was previously directly imported, it would be available on the existing importlib package if your script later imported it. For example:

# Done from anywhere in Fusion or other addins
import importlib.util
# Done In your addin
import importlib
importlib.util # Works!

So it is possible that slight changes in addin loading order or timing, or changes in other scripts or internal code run in the same interpreter could result in this. But I believe if you directly import the util module, you won't be dependent on someone else previously having loaded it.

 

Kris



Kris Kaplan
Message 3 of 4

As for the angle, boundaryLines, position, and referencedEntity properties on SketchText... The implementation of SketchText was enhanced to support the new capabilities of sketch text in Fusion. As part of that work, these properties were either inconsistent with the new implementation, or redundant with information available on the new SketchTextDefinition (available from the SketchText.definition property). Note that these properties were not actually removed. They were marked as [obsolete] and are just no longer documented. But for backward compatibility they are still available on the objects.

 

Also note that some of these 'removed' properties may only work for legacy sketch text entities in existing documents. And some of the new properties will only work for new sketch text entities created after these changes.

 

Kris



Kris Kaplan
Message 4 of 4

Thank you for the help.

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