Revit 2020 temp path changes every session

Revit 2020 temp path changes every session

n.vroegindeweij
Observer Observer
1,865 Views
6 Replies
Message 1 of 7

Revit 2020 temp path changes every session

n.vroegindeweij
Observer
Observer

Hello all,

 

In our add-in for Revit we are using the temp path, which can be requested using Path.GetTempPath() in C#.

When this is requested in pre 2020 version, this returned the %TMP% environment variable path.

 

Since Revit 2020 the requested temp path contains an additional guid at the end of the path, which changes after every restart of Revit(ie. C:\Users\USERNAME\AppData\Local\Temp\84ae8c0d-197b-4b44-b8d3-8823fabbba4f). It seems like Revit changes the temp path for the scope of the application.

 

Of course we can remove the guid from the path in our add-in, but I'm wondering if this has been done by purpose or could be a bug?

 

Best regards,

 

Niels

 

Revit version: 20.0.0.377 20190327_2315(x64)

0 Likes
1,866 Views
6 Replies
Replies (6)
Message 2 of 7

jeremytammik
Autodesk
Autodesk

Dear Niels,

 

Well, it is definitely not a bug, because no intended behaviour has ever been explicitly declared for this, afaik.

 

Of course, it may still cause a problem for you, depending on your specific needs and how you make use of it.

 

I would suggest that you use the operating system TMP variable instead of the current Revit.exe temporary path, if that suits your needs better.

 

I can gladly ask the development team (a) what caused this change, (b) why and (c) whether this is intentional.

 

They may not be able or willing to provide an answer, though.

 

I'll let you know what they say as soon as I hear back from them.

 

Best regards,

 

Jeremy

 



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

0 Likes
Message 3 of 7

Anonymous
Not applicable

Hello all.

I also have the same problem, and want to know, what is the reason of it? Thanks.

0 Likes
Message 4 of 7

jeremytammik
Autodesk
Autodesk

As a poet once said referring to more unfortunate circumstances:

 

Ours is not to wonder why,

Ours is but to do or die.

 

In this case, I don't know why, and I don't think it will help you or anyone else to know either.

 

The real question is how to handle the modified behaviour, isn't it?

 



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

0 Likes
Message 5 of 7

n.vroegindeweij
Observer
Observer

To get the original user temp path, below method can be used. And to have similar behavior as Path.GetTempPath(), it might be good to use TEMP, USERPROFILE, WinDir as fallback variables.

 

Environment.GetEnvironmentVariable("TMP", EnvironmentVariableTarget.User);

Probably from technical point of view there is nothing wrong with the change of temp path on application level. However, I think it can cause unexpected behavior for a lot add-ins(ie caching in temp, suddenly doesn't work).

0 Likes
Message 6 of 7

Chuong.Ho
Advocate
Advocate

Have any explain why Autodesk do that ?

Chuong Ho

EESignature

0 Likes
Message 7 of 7

jeremy_tammik
Alumni
Alumni

I'm sorry I have no explanation. I can only refer to my answer above to nikita_bokhan...

  

Jeremy Tammik Developer Advocacy and Support + The Building Coder + Autodesk Developer Network + ADN Open
0 Likes