AWESOME! Thanks @ferdinand!!!
Latest posts made by randymills
-
RE: Encountered a possible error in the example code in the docs for AssetDataBasesInterface.FindRepository
Thanks Ferdinand and that does seem very plausible given that I am very new to type hinting in my code, and I have actually caught myself swapping the colon for the equals sign already. Learning from you guys every day though! I'm off to break some more sh!t! Thanks so much for your time, will let you know when I get stuck...
-
RE: Encountered a possible error in the example code in the docs for AssetDataBasesInterface.FindRepository
Ferdinand, I stand corrected and apologize for any confusion. Thank you for taking the time to explain that so thoroughly, very helpful! Having examples, like you provided in the documentation here, has been the ONLY way I've been able to navigate my way through the API. I'm quickly finding out the difference between what's included in the Python API vs. the C++ API and learning to work my way around my shortcomings as a coder, so I greatly appreciate your help and your time. After reading your response I have a much clearer understanding of this concept. Thank you!
It does seem that I made a mistake somewhere on my end, since I tried again this morning after reconnecting my custom databases in the Asset Browser and it is working as you described above. I'm not sure what happened yesterday to cause the "issubclass() arg 1 must be a class" error, but it is not reproduceable this morning, and changing the class in maxon.Cast back to "AssetRepositoryRef" now works. I'll continue testing and let you know if I come across this issue again, but I can't seem to reproduce it today and it's working as intended. Would resetting the databases in the Asset Browser make sense to you as to why it may have solved this issue on my end? Could I have stored something other than a subclass in memory somehow?
Again, thank you for your time!
-
Encountered a possible error in the example code in the docs for AssetDataBasesInterface.FindRepository
I have been working on a bit of code that versions up an asset automatically based on the timestamp of a master asset and I was having a really hard time figuring out how to properly assign the custom database to the new version. I was using the example for AssetDataBasesInterface.FindRepository found here https://developers.maxon.net/docs/py/2024_4_0a/modules/maxon_generated/frameworks/asset/interface/maxon.AssetDataBasesInterface.html#maxon.AssetDataBasesInterface.FindRepository, but I think there may be an error in the code.
I was consistently getting an issubclass error when running the example code:
url: maxon.Url = maxon.Url(r"/Volumes/database") obj: maxon.ObjectRef = maxon.AssetDataBasesInterface.FindRepository(url) if obj.IsNullValue(): raise RuntimeError(f"Could not establish repository for: {url}.") # Cast #obj to an AssetRepositoryRef. What #obj must be cast to depends on the repository #url # is representing. But all repositories are of type AssetRepositoryInterface, so a ref for that # will give access to all common asset repository methods. repo: maxon.AssetRepositoryRef = maxon.Cast(maxon.AssetRepositoryRef, obj) if repo.IsNullValue(): raise RuntimeError(f"Could not establish repository for: {url}.")
After reading a little more about issubclass() I figured out that I needed to define the class to Cast as maxon.AssetRepositoryInterface instead of maxon.AssetRepositoryRef and that seems to work perfectly.
The updated version looks like this and works for me:
url: maxon.Url = maxon.Url(r"/Volumes/database") obj: maxon.ObjectRef = maxon.AssetDataBasesInterface.FindRepository(url) if obj.IsNullValue(): raise RuntimeError(f"Could not establish repository for: {url}.") # Cast #obj to an AssetRepositoryRef. What #obj must be cast to depends on the repository #url # is representing. But all repositories are of type AssetRepositoryInterface, so a ref for that # will give access to all common asset repository methods. repo: maxon.AssetRepositoryRef = maxon.Cast(maxon.AssetRepositoryInterface, obj) if repo.IsNullValue(): raise RuntimeError(f"Could not establish repository for: {url}.")
Thought I'd post here in case anyone else is struggling with this as hard as I've been!
-
RE: TexBox CustomGUI for Python?
Was there any further investigation into this topic? We are trying to add a drag and drop field to our python dialog for textures from image assets in the asset browser...I can make a separate post, but scouring the forum first for relevant articles.