-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getTextureForMaterial fails with attribute Name not found #36
Comments
Hmm catching all exceptions is never a good idea. The fix would be to check hasattr(obj, "Name") before accessing the Name of the given object. Could you add your FreeCAD Version info to the issue so I can check whats going on? |
ArchTexture commit e3af619. I should point out that this bug was being triggered by a particular data file I had which was quite complex. When I recreated the same sub-part I wanted to texture in a new project, I did not experience this issue. So whatever the pickled state of those objects is may actually be a remnant of past version of FreeCAD and may stick around essentially forever if one makes use of asset libraries. I agree that catch-all-pass is a poor idiom. Duck typing the Name attribute only may be sufficient but I'd also warn that line 240 may also have an issue to check out. One note, though, is that |
In case, a object has a Material property, and the material has no "Name" attribute, a exception is raised when texturing it. To prevent this from happening, we check if the material has a Name. If not, we simply ignore the object and do not texture it. fixes #36
@memetb Thanks for the detailed explanation.
|
@furti, thanks for the update, and thanks for thinking about the issue as I don't have a lot of spare bandwidth to review the code.
|
Hi @furti: I went back to check on what's going on when the bug manifests. It seems that the function receives a dictionary at some point. I started by running
on the culprit project and I get no hits. Here's the stack trace I get when I click the UI "create a new TextureConfig" button:
So it would seem, for some reason a dict is being passed to that function. I actually put a debug print in the code, and it's specifically an empty dict. edit: alright, I've found a minimal reproducible bug.
This will cause the above bug to occur (provided you remove that Hopefully this'll allow you to figure out why this is happening. Let me know if you have any other requests. |
Dear Furti, I've used the arch texture with limited succes, at the times that it works it's great! But, I get the attribute Name not found most of the times. I'm using FreeCAD 0.19 build: OS: Windows 10 (10.0) |
I have the problem when trying to apply textures to my house design: |
As the title says, I have a particular project that triggers this problem.
The symptom manifests during the call to
textureObjects
and results in an exception when enumerating through the objects of the scene. (This is triggered when the "Create a new TextureConfig" button is pressed, and the exception leaves the UI in an unusable state).If
getTextureForForMaterial
is made to correctly try/except and return None as it is intended here, this problem goes away.I'm open to submitting a PR or simply leave it up to you to resolve. On my local system, I've simply wrapped the whole function
getTextureForForMaterial
in a try block, with a handler as such:The text was updated successfully, but these errors were encountered: