NikolaiVChr/Blender-AC3D

[Known Issues] Exporting in Edit mode does not work

Entamut opened this issue · 4 comments

If exporting when in Edit mode, it will not export the last edits done in Edit mode. Best is to export when in Object mode.

This is a known issue I'm planning to solve.
The idea is:

  • Other export plugins seem to work when Edit mode is selected. So looking at one of those plugins provided by Blender itself looks reasonable
  • One of those is STL format import/export (io_mesh_stl)
  • In "io_scene_ac3d/_ _ init _ _ .py", inside the execute function at line 135, the script switches to object mode using the API call bpy.ops.object.mode_set(mode='OBJECT')
  • That call is documented at https://docs.blender.org/api/current/bpy.ops.object.html and allows to switch between modes

Therefore, applying such mechanism to "io_scene_ac3d/_ _ init _ _.py" should provide the expected functionally without errors.

I will include this changes only in 2.80 branch because I am not going to test it in previous versions. Blender 2.83 is the latest LTS version.

I am not sure I like forcing Object mode onto the user, it might mess up his Undo history, since there is a Undo history for both Object mode and for inside Edit mode, he might not notice the change and when doing Undo in object mode he might undo lots edits in edit mode.

Not sure

Hi @NikolaiVChr,

Well, I think it is just a question of how you would like your plugin to behave:

  1. As the official plugins distributed in every single version of Blender. Let's call this the "Standard way"
  2. Any other way. At this moment showing errors, but you could define something like a pop-up dialog (e.g. "Would you like to mess your undo history? Yes/No", it's just an example). Let's call this the "Non standard way"

If you'd ask me, I will always go with the first option. Maybe someday the guys at Blender decide to distribute the ac3d plugin in the official release ;D What better way of helping that doing things the Blender way?

Up to you.

Cheers!

Hi again,

So I checked again. And the official plugin only switches mode when importing, not when exporting.
My plan somehow remains, it is just doing what official plugins do. Therefore:

  • Switching to object mode when importing
  • Not switching to object mode when exporting

I need to check why official plugin is not switching mode and still works, and then figure out how to fix ac3d plugin (I will come back later with a plan).

Cheers!

Hi @NikolaiVChr!

Being trying for a few minutes now, and I don't understand what's not working.
Could you elaborate more on this topic? (steps to reproduce, operating system, Blender version...)

Long version

Test setup:

  • Remove following lines in _ _ init _ _ .py file (from 351 to 358):
        if context.active_object:
            if context.active_object.mode == 'EDIT':
                print("AC3D was not exported due to being in edit mode.")
                bpy.ops.error.message(
                    'INVOKE_DEFAULT',
                    type="Error",
                    message='Cannot export AC3D in edit mode.')
                return {'FINISHED'}
  • Reinstall plugin in Blender
  • MacOS Catalina 10.15.5
  • Blender 2.83.0

What I'm testing:

  • Loading a model done with AC3D software. I am trying with two different models: "/Applications/ac3dmac/models/TBD Normandy/Normandy.ac" and "/Applications/FlightGear.app/Contents/Resources/data/Aircraft/c172p/Models/c172p.ac". These are what I call "original" models.
  • First model is a complex one and it is distributed with AC3D software as demonstration
  • Second model is distributed with FlightGear and it is the default plane. It is not so complex but it is supposed to be "well done"
  • After loading the model I switch to edit mode
  • I export the model (no errors yet). These creates what I call "exported" models.
  • I open both the original model and the exported models in AC3D.
  • I get the models info in AC3D (Tools -> Model Info..., copy and paste as text file)
  • I compare models (original vs exported) visually
  • I compare models info

What I found:

  • All exported models seem to be ok. This is just my opinion. I checked textures and general look
  • When comparing model info I get a few differences (see below)

Normandy.ac:

  • Original: Total objects: 89 surfaces: 161613 vertices: 217266
  • Exported: Total objects: 89 surfaces: 161253 vertices: 217266

Number of surfaces is different, but objects and vertices number remain. My guess is there are surfaces (faces) that the plugin is not selecting for a (good) given reason

c172p.ac:

  • Original: Total objects: 254 surfaces: 43790 vertices: 47429
  • Total objects: 254 surfaces: 43789 vertices: 47429

Number of surfaces is different. Just by one in object "rudder_1". Visually, I can't tell the difference:

  • Original

00_original

  • Exported

01_exported

My guess is I'm missing something important. I'd tell is not working in Windows, but I can't (I don't want to) test it on Windows. Anyone?