Timeline's entity attribute sometimes generates error message

Timeline's entity attribute sometimes generates error message

Jorge_Jaramillo
Collaborator Collaborator
334 Views
2 Replies
Message 1 of 3

Timeline's entity attribute sometimes generates error message

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

I'm trying to run some script over the timeline of a Design, but I'm getting error messages when the code access the ENTITY property in some of the items of the timeline.

 

Here is an example: in the design I have 5 items, in order: #0 canvas, #1 sketch, #2 extrude, #3 copy body, #4 move

wtallerdemadera_0-1659733148319.png

 

For items 0 and 3 error messages are generated with the sentence:

app.activeProduct.timeline.item(0).entity

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users/monchisteria/AppData/Local/Autodesk/webdeploy/production/dc406fd0d566a1ba77afee542432c1e031a68604/Api/Python/packages\adsk\fusion.py", line 38225, in _get_entity
    return _fusion.TimelineObject__get_entity(self)
RuntimeError: 2 : InternalValidationError : res

 

app.activeProduct.timeline.item(3).entity 

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "C:\Users/monchisteria/AppData/Local/Autodesk/webdeploy/production/dc406fd0d566a1ba77afee542432c1e031a68604/Api/Python/packages\adsk\fusion.py", line 38225, in _get_entity
    return _fusion.TimelineObject__get_entity(self)
RuntimeError: 3 : feature is not supported

 

I'd tried with other designs and the problem persists for the same type of items in the timeline.

You can see in the above image the error is not reported for item #4 in the timeline (same happen on items #1 and #2).

I believe it's a bug in the API.  Shouldd someone at Autodesk take a look at it?

 

Regards,

Jorge

0 Likes
335 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor

Unfortunately, this is expected behavior. The timeline objects where the entity property is failing represent objects that the API does not currently support. There is not any canvas support, but I'm a little surprised that there is no support for "Copy Body". I thought all of the features had some support, but this one must have fallen through the cracks.

 

Ideally, the API would support these operations, and the entity property would return the appropriate object representing that operation. The next best behavior would be if the entity property would return either None or an adsk.core.Base class, which is the base class for everything and, as a result, can represent any object even though what it supports is very minimal. In either case, the entity property won't fail, and you can use the result to know that the API doesn't support that type of entity.

 

For now, you'll need to put a try-except statement around the call to the entity property and assume it's an unsupported type if it fails.

 

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

Jorge_Jaramillo
Collaborator
Collaborator

Hi @BrianEkins ,

 

I Completely agree with you.

I already did the try/expect you suggested, but without identifying properly the body copy in the timeline, I'll try to infer it from the components/occurrences.

Regarding operations that are not implemented in the API, a quick option could be to have a facade of the object, just to identify the operation, without any further functionality inside.

 

Meanwhile, I hope someone from Autodesk team could analyze it further, at least to avoid the exception in a regular operation with the API.

 

Regards,

Jorge

0 Likes