Added an option to the import menu which automatically creates a Blender file for each linked block in the Rhino file. This way the addon can read from these newly created reference files to populate the instance definitions by linking (File > Link). The 'Overwrite' toggle can be enabled to save over existing reference files.
Detailed Explanation
Added a third argument to read_3dm(). 'block_toggle' allows for recursive calling of the function with different parameters. This is needed to import each block into its own separate Blender file.
Added 'instance_properties' list to handle_instance_definitions() in 'instances.py'. The list contains dictionaries of name, URL and update type for each block. This is used to determine which blocks need to have reference files created and how to match these reference files to their respective block names when linking.
Added nuke_everything() in 'read3dm.py'. This is used to clear all objects, materials and textures before importing and saving a reference block file.
Added link_all() in 'read3dm.py'. This is used to populate all instance definitions that were previously empty, using the newly created reference block files. This only applies to blocks with their block definition type set to 'Linked' in Rhino.
Since the new option creates and saves new files, it discards everything that hasn't been previously saved. Warning text is included to convey that. If the current project hasn't been saved at all, the import process will abort and ask the user to save first.
Resolves
Addresses issue "Add support for loading linked blocks from external files" #87
This only implements the mirroring of the Rhino file structure and not the reading from external Rhino files.
Additional Notes
It might be feasible to use command line instances of blender to save block files. This would remove the necessity to save the project beforehand. I have yet to explore this option.
The 'nuke_everything()' function is clunky but gets the job done. I haven't been able to find a better alternative.
This is my first time coding anything substantial in python so apologies for potential unorthodox code.
Added feature 'Auto-Create Linked Block Files':
Added an option to the import menu which automatically creates a Blender file for each linked block in the Rhino file. This way the addon can read from these newly created reference files to populate the instance definitions by linking (File > Link). The 'Overwrite' toggle can be enabled to save over existing reference files.
Detailed Explanation
Resolves
Addresses issue "Add support for loading linked blocks from external files" #87 This only implements the mirroring of the Rhino file structure and not the reading from external Rhino files.
Additional Notes