3D Printing Toolbox - Local View bug #49895

Closed
opened 2016-10-31 17:15:14 +01:00 by Eugene · 16 comments

Error with 3D Printing Toolbox CheckAll command when called from Local View mode.

Check is not done.
Duplicate object called ~temp~ is addes to the scene.
Log shows:

Traceback (most recent call last):
  File "blender\blender-2.78a-windows32\2.78\scripts\addons\object_print3d_utils\operators.py", line 332, in execute
    cls.main_check(obj, info)
  File "blender\blender-2.78a-windows32\2.78\scripts\addons\object_print3d_utils\operators.py", line 242, in main_check
    faces_error = mesh_helpers.bmesh_check_thick_object(obj, print_3d.thickness_min)
  File "blender\blender-2.78a-windows32\2.78\scripts\addons\object_print3d_utils\mesh_helpers.py", line 185, in bmesh_check_thick_object
    ok, co, no, index = ray_cast(p_a, p_dir, p_dir.length)
RuntimeError: Error: Object '~temp~' has no mesh data to be used for ray casting

To reproduce:

  1. Select any object with mesh.
  2. Enable Local View (Numpad /)
  3. Hit Check All on 3D Printing tab.

Error appears both in Object mode and Edit mode.

Error with 3D Printing Toolbox **CheckAll** command when called from **Local View** mode. Check is not done. Duplicate object called *~temp~* is addes to the scene. Log shows: ``` Traceback (most recent call last): File "blender\blender-2.78a-windows32\2.78\scripts\addons\object_print3d_utils\operators.py", line 332, in execute cls.main_check(obj, info) File "blender\blender-2.78a-windows32\2.78\scripts\addons\object_print3d_utils\operators.py", line 242, in main_check faces_error = mesh_helpers.bmesh_check_thick_object(obj, print_3d.thickness_min) File "blender\blender-2.78a-windows32\2.78\scripts\addons\object_print3d_utils\mesh_helpers.py", line 185, in bmesh_check_thick_object ok, co, no, index = ray_cast(p_a, p_dir, p_dir.length) RuntimeError: Error: Object '~temp~' has no mesh data to be used for ray casting ``` To reproduce: 1. Select any object with mesh. 2. Enable Local View (**Numpad /**) 3. Hit **Check All** on **3D Printing** tab. Error appears both in *Object mode* and *Edit mode*.
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

Added subscriber: @EugeneDidkivskyy

Added subscriber: @EugeneDidkivskyy

Added subscriber: @VukGardasevic

Added subscriber: @VukGardasevic

I could not recreate the issue on the latest build 1ee43c5 on Win7 64 bit.

Please, could you provide additional information:

Try the latest developer build and see if the error is still present
What version of the add-on you have and what exact windows OS you're using?
If the error is still present with the latest build, attach a small blend file that demonstrates the issue.

I could not recreate the issue on the latest build 1ee43c5 on Win7 64 bit. Please, could you provide additional information: Try the latest developer build and see if the error is still present What version of the add-on you have and what exact windows OS you're using? If the error is still present with the latest build, attach a small blend file that demonstrates the issue.
Author

Thanks for you review!

Unfortunately, I can not test it on Win7 64. However, I did test it on different PCs with Win7 32 before.

I've also checked this on blender-2.78-643c5a2-win32 daily build. Same behaviour.

Moreover, I believe this issue to be not new to 2.78a because my tests on 2.77a show the same bug. In contrast, the error is absent on 2.74 and Check All works as it should both for Global and Local views.

It also does not depend on the file and behaves identically on any file including the Start-Up file.

I hope this info helps a little more.

KR,
Eugene

In #49895#401947, @VukGardasevic wrote:
I could not recreate the issue on the latest build 1ee43c5 on Win7 64 bit.

Please, could you provide additional information:

Try the latest developer build and see if the error is still present
What version of the add-on you have and what exact windows OS you're using?
If the error is still present with the latest build, attach a small blend file that demonstrates the issue.

Thanks for you review! Unfortunately, I can not test it on Win7 64. However, I did test it on different PCs with Win7 32 before. I've also checked this on blender-2.78-643c5a2-win32 daily build. Same behaviour. Moreover, I believe this issue to be not new to 2.78a because my tests on 2.77a show the same bug. In contrast, the error is absent on 2.74 and **Check All** works as it should both for Global and Local views. It also does not depend on the file and behaves identically on any file including the Start-Up file. I hope this info helps a little more. KR, Eugene > In #49895#401947, @VukGardasevic wrote: > I could not recreate the issue on the latest build 1ee43c5 on Win7 64 bit. > > Please, could you provide additional information: > > Try the latest developer build and see if the error is still present > What version of the add-on you have and what exact windows OS you're using? > If the error is still present with the latest build, attach a small blend file that demonstrates the issue.

Thanks, I can confirm the issue now.

Seems that the mesh doesn't show up in the scene making the raycast function to fail.
The workaround is to exit the local mode update the scene and go back into the local mode.
I don't know if there is a better way of fixing the issue.

I'll think about it and push a fix.

Thanks, I can confirm the issue now. Seems that the mesh doesn't show up in the scene making the raycast function to fail. The workaround is to exit the local mode update the scene and go back into the local mode. I don't know if there is a better way of fixing the issue. I'll think about it and push a fix.
Author

Thanks Vuk.

I figured that I can do Hide Unselected (Shift+H) to carry some 3D printing tests with the part of the mesh/scene. This way I can stay in Global View and avoid the error.

Still strange that this worked smoothly for earlier Blender versions.

In #49895#402858, @VukGardasevic wrote:
Thanks, I can confirm the issue now.

Seems that the mesh doesn't show up in the scene making the raycast function to fail.
The workaround is to exit the local mode update the scene and go back into the local mode.
I don't know if there is a better way of fixing the issue.

I'll think about it and push a fix.

Thanks Vuk. I figured that I can do **Hide Unselected** (Shift+H) to carry some 3D printing tests with the part of the mesh/scene. This way I can stay in **Global View** and avoid the error. Still strange that this worked smoothly for earlier Blender versions. > In #49895#402858, @VukGardasevic wrote: > Thanks, I can confirm the issue now. > > Seems that the mesh doesn't show up in the scene making the raycast function to fail. > The workaround is to exit the local mode update the scene and go back into the local mode. > I don't know if there is a better way of fixing the issue. > > I'll think about it and push a fix.

Added subscribers: @mont29, @MikhailRachinskiy

Added subscribers: @mont29, @MikhailRachinskiy

Hi Eugene, I have looked into the problem as I promised and here is what I've found.

The issue is not with the add-on, the code responsible for thickness check (that currently produces the error) hasn't been changed since 2.74:

# PRODUCES ERROR

def bmesh_check_thick_object(obj, thickness):

    ...

    scene = bpy.context.scene
    me_tmp = bpy.data.meshes.new(name="~temp~")
    bm.to_mesh(me_tmp)
    # bm.free()  # delay free
    obj_tmp = bpy.data.objects.new(name=me_tmp.name, object_data=me_tmp)
    scene.objects.link(obj_tmp)
    scene.update()
    ray_cast = obj_tmp.ray_cast

    ...

If we insert bpy.ops.view3d.localview() before and after scene.objects.link(obj_tmp) there won't be an error.

# NO ERROR

bpy.ops.view3d.localview()
scene.objects.link(obj_tmp)
bpy.ops.view3d.localview()

Which means the issue is with objects.link() and C API.

I also narrowed down the Blender version, the code worked in 2.75, but gives an error in 2.76. So something happened between these two releases.

Unfortunately I'm not a C developer and I cannot handle this issue myself, but maybe @mont29 could look into this?

Hi Eugene, I have looked into the problem as I promised and here is what I've found. The issue is not with the add-on, the code responsible for thickness check (that currently produces the error) hasn't been changed since 2.74: ``` # PRODUCES ERROR def bmesh_check_thick_object(obj, thickness): ... scene = bpy.context.scene me_tmp = bpy.data.meshes.new(name="~temp~") bm.to_mesh(me_tmp) # bm.free() # delay free obj_tmp = bpy.data.objects.new(name=me_tmp.name, object_data=me_tmp) scene.objects.link(obj_tmp) scene.update() ray_cast = obj_tmp.ray_cast ... ``` If we insert `bpy.ops.view3d.localview()` before and after `scene.objects.link(obj_tmp)` there won't be an error. ``` # NO ERROR bpy.ops.view3d.localview() scene.objects.link(obj_tmp) bpy.ops.view3d.localview() ``` Which means the issue is with `objects.link()` and C API. I also narrowed down the Blender version, the code worked in 2.75, but gives an error in 2.76. So something happened between these two releases. Unfortunately I'm not a C developer and I cannot handle this issue myself, but maybe @mont29 could look into this?

There is no real bug in Blender here, the issue is with local_view, which (among other things) requires newly linked objects to be put in the lacalview 'layer' to be considered (otherwise it’s ll be hidden, and hence 'invisible' from operators, even if selected).

See 'add object' helper code, and in particular this recent fix: https://developer.blender.org/rB216a3a3826214c665c90b8c89715507e8755b1c7

You probably want to add something like that in your code to link object correctly, even in local view:

base = scene.objects.link(obj_tmp)


v3d = None
if context.space_data and context.space_data.type == 'VIEW_3D':
v3d = context.space_data


if v3d and v3d.local_view:
base.layers_from_view(context.space_data)

There is no real bug in Blender here, the issue is with local_view, which (among other things) requires newly linked objects to be put in the lacalview 'layer' to be considered (otherwise it’s ll be hidden, and hence 'invisible' from operators, even if selected). See 'add object' helper code, and in particular this recent fix: https://developer.blender.org/rB216a3a3826214c665c90b8c89715507e8755b1c7 You probably want to add something like that in your code to link object correctly, even in local view: ```lang=python ``` base = scene.objects.link(obj_tmp) ``` ``` v3d = None if context.space_data and context.space_data.type == 'VIEW_3D': v3d = context.space_data ``` ``` if v3d and v3d.local_view: base.layers_from_view(context.space_data) ```

@MikhailRachinskiy if you're ok with this I'll push the fix with the code by Bastien,

Have some clean up fixes for Print3d too but i'll do them in a separate patch.

@MikhailRachinskiy if you're ok with this I'll push the fix with the code by Bastien, Have some clean up fixes for Print3d too but i'll do them in a separate patch.

@VukGardasevic I've prepared the fix already, but OK.

@mont29 big thanks for your help with this.

@VukGardasevic I've prepared the fix already, but OK. @mont29 big thanks for your help with this.

@MikhailRachinskiy No problem I can wait with the clean up patch after your fix.

@MikhailRachinskiy No problem I can wait with the clean up patch after your fix.

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Mikhail Rachinskiy self-assigned this 2016-11-11 16:25:40 +01:00

Fixed by 7df41339ae

Fixed by 7df41339ae
Author

Hi,

I've tested the 7df41339ae for 2.78a on Win32. I can confirm this completely solves the issue.

Thank you very much for your efforts, gentlemen!

P.S.: The only thing I regret - I didn't post the bug earlier. Thus now I have to work on my habit to avoid local view for 3D printing tests :-)

Have a great weekend!

Eugene

Hi, I've tested the **7df41339ae** for 2.78a on Win32. I can confirm this completely solves the issue. Thank you very much for your efforts, gentlemen! P.S.: The only thing I regret - I didn't post the bug earlier. Thus now I have to work on my habit to avoid local view for 3D printing tests :-) Have a great weekend! Eugene
Sign in to join this conversation.
No Milestone
No project
4 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#49895
No description provided.