PointCloud IPointCloudAccess immediate call to free

PointCloud IPointCloudAccess immediate call to free

jonas.meer
Participant Participant
971 Views
8 Replies
Message 1 of 9

PointCloud IPointCloudAccess immediate call to free

jonas.meer
Participant
Participant

Hello,

 

I work currently on an addin for Revit 2020.2. And I observed a behavior where I am not sure what the intend of this behavior is.

So immediately after creating a pointcloud with

 

PointCloudType type = PointCloudType.Create(doc, engineType, identifier);
PointCloudInstance.Create(doc, type.Id, trf);

 

"Free()" (implemented via IPointCloudAccess) is called. And then again exactly the same pointcloud is constructed (same identifier) but this time "Free()" is not called.

But then "Free()" is never called again (not when deleting or closing revit/the document)

 

This can be observed with the official samples.

 

I also noticed that in older samples (like for 2019) the free method threw an NotImplementedException.

This was removed in the new samples See on this mirror. So I guess the developers are aware of this.

 

This leads to my question: Why is "Free()" called immediately after creation and what is the actual purpose of "Free()"?

0 Likes
Accepted solutions (1)
972 Views
8 Replies
Replies (8)
Message 2 of 9

jeremytammik
Autodesk
Autodesk

The internal implementation of the IPointCloudEngine interface is completely up to you yourself.

  

Normally, methods named `Free` or similar are used to free up resources that are no longer required.

  

As clearly stated by the documentation, the `Free` method is called by Revit when it is done using the engine:

 

https://www.revitapidocs.com/2020/8ab4ee5f-af6d-c452-a7e8-fa8f60f15779.htm

 

As said, what happens inside the method implementation is entirely up to the interface implementor.

   



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 3 of 9

jonas.meer
Participant
Participant

Thanks for your answer🙂

 

I am aware that the free method of IPointCloudEngine and IPointCloudAccess  are called by revit to signal that I can dispose my resources or do other things when Revit tells me: "I do not need this Engine or PointCloud anymore".

 

But I do not understand why it is called immediately after the point cloud is constructed and then the point cloud is constructed again.

 

I try to visualize it via the PointCloudEngine from the sdk sample (2020).

 

I press the button "Add predefined instance" and revit invokes the externalCommand as expected:

 

1.png

 

So when this line is executed revit asks the "PredefinedPointCloudEngine" to create a new PointCloudAccess:

2.png

Then a "PredefinedPointCloud" is created and "Free()" is immediately called:

 

4.png

 

When you inspect the callstack you see that this all happens within the externalCommand.

And then revit asks for a new PointCloud within the same command:

5.png

(This is the second call for the exactly same pointCloud)

 

So Revit says: "Give me the new requested Pointcloud. Okay thanks, but I do not need it anymore you can release it... So I need that pointCloud now, give it to me again" And that all within the same command.

 

I think this is also the reason the sdk samples were modified as I wrote in my first post. I guess the old unmodified sdk samples would not work anymore since revit 2020. So this behavior is new and I do not know why.

 

Imagine I need to do some time intense stuff to create my pointCloud. And I have to do it twice because revit does throw my first PointCloud away.

 

Also I never see that "Free()" is invoked. Only during instantiation as stated above.

I can delete it in revit and still "Free()" is not called. But when I undo (via revit undo) that deletion Revit requests a new pointCloud via their engine(as expected). But it never tells me to release my resources.

 

Thanks again for your help

0 Likes
Message 4 of 9

jeremytammik
Autodesk
Autodesk

Yes, indeed, that sounds weird.

 

Can you please submit a minimal reproducible case that I can pass on to the development team for analysis?

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#1b

 

Thank you!

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 5 of 9

jonas.meer
Participant
Participant

Thanks for your feedback.

 

I created a minimal example and attached it to this post.

0 Likes
Message 6 of 9

jeremytammik
Autodesk
Autodesk

Dear Jonas,

 

Thank you for your report and reproducible case.

 

Sorry to hear about this.

 

I logged the issue REVIT-170437 [Immediate call to IPointCloudEngine and IPointCloudAccess Free method] with our development team for this on your behalf as it requires further exploration and possibly a modification to our software. Please make a note of this number for future reference.

 

You are welcome to request an update on the status of this issue or to provide additional information on it at any time quoting this change request number.

 

This issue is important to me. What can I do to help?

 

This issue needs to be assessed by our engineering team and prioritised against all other outstanding change requests. Any information that you can provide to influence this assessment will help. Please provide the following where possible:

 

  • Impact on your application and/or your development.
  • The number of users affected.
  • The potential revenue impact to you.
  • The potential revenue impact to Autodesk.
  • Realistic timescale over which a fix would help you.
  • In the case of a request for a new feature or a feature enhancement, please also provide detailed Use cases for the workflows that this change would address.

 

This information is extremely important. Our engineering team have limited resources, and so must focus their efforts on the highest impact items. We do understand that this will cause you delays and affect your development planning, and we appreciate your cooperation and patience.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 7 of 9

jeremytammik
Autodesk
Autodesk

Dear Jonas,

 

Thank you again for your sample material and patience.

 

The development team analysed the issue and confirmed the behaviour you report.

 

They closed the original ticket REVIT-170437 [Immediate call to IPointCloudEngine and IPointCloudAccess Free method] as 'code fix needed' and submitted a new one for the future development work, REVIT-170691 [Free and the CreatePointCloudAccess are triggered in the call to IPointCloudAccess.CreatePointCloudAccess, which is not expected].

 

Please make a note of this number as well for future reference.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 8 of 9

jeremytammik
Autodesk
Autodesk
Accepted solution

Dear Jonas,

 

Just FYI, the development ticket REVIT-170691 [Free and the CreatePointCloudAccess are triggered in the call to IPointCloudAccess.CreatePointCloudAccess, which is not expected] has now also been completed and closed, so the we can expect to see the desired behaviour in an upcoming future major release of Revit.

 

Best regards,

 

Jeremy

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes
Message 9 of 9

jonas.meer
Participant
Participant

Dear Jeremy,

 

thank you very much for your update and also thanks to the dev team for fixing this 😉

 

 

0 Likes