Errors after the October update

Errors after the October update

Maciej_Rogowski
Enthusiast Enthusiast
768 Views
3 Replies
Message 1 of 4

Errors after the October update

Maciej_Rogowski
Enthusiast
Enthusiast

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.

0 Likes
Accepted solutions (1)
769 Views
3 Replies
Replies (3)
Message 2 of 4

KrisKaplan
Autodesk
Autodesk

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
0 Likes
Message 3 of 4

KrisKaplan
Autodesk
Autodesk
Accepted solution

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
0 Likes
Message 4 of 4

Maciej_Rogowski
Enthusiast
Enthusiast

Thank you for the help.

0 Likes