2019-07-02 14:44:42 +02:00
|
|
|
bl_info = {
|
|
|
|
"name": "gdsii OBJ format",
|
|
|
|
"author": "Julian Daube",
|
|
|
|
"version": (0, 9, 0),
|
|
|
|
"blender": (2, 78, 0),
|
|
|
|
"location": "File > Import-Export",
|
|
|
|
"description": "Import GdsII files",
|
|
|
|
"warning": "",
|
|
|
|
"category": "Import-Export"}
|
|
|
|
|
|
|
|
if "bpy" in locals():
|
|
|
|
import importlib
|
|
|
|
if "import_gds" in locals():
|
|
|
|
importlib.reload(import_gds)
|
2019-07-04 21:22:20 +02:00
|
|
|
if "gds" in locals():
|
|
|
|
importlib.reload(gds)
|
|
|
|
|
2019-07-02 14:44:42 +02:00
|
|
|
import bpy
|
|
|
|
|
|
|
|
from bpy.props import (
|
|
|
|
BoolProperty,
|
|
|
|
FloatProperty,
|
|
|
|
StringProperty,
|
|
|
|
EnumProperty,
|
|
|
|
)
|
2019-07-04 21:22:20 +02:00
|
|
|
|
2019-07-02 14:44:42 +02:00
|
|
|
from bpy_extras.io_utils import (
|
|
|
|
ImportHelper,
|
|
|
|
ExportHelper,
|
|
|
|
orientation_helper_factory,
|
|
|
|
path_reference_mode,
|
|
|
|
axis_conversion,
|
|
|
|
)
|
|
|
|
|
|
|
|
IOOBJOrientationHelper = orientation_helper_factory("IOOBJOrientationHelper", axis_forward='-Z', axis_up='Y')
|
|
|
|
|
|
|
|
class ImportGDS(bpy.types.Operator, ImportHelper, IOOBJOrientationHelper):
|
|
|
|
"""Load a GDSII File"""
|
|
|
|
bl_idname = "import_scene.gds"
|
|
|
|
bl_label = "Import GDSII"
|
|
|
|
bl_options = {'PRESET', 'UNDO'}
|
|
|
|
|
|
|
|
filename_ext = ".obj"
|
|
|
|
filter_glob = StringProperty(
|
|
|
|
default="*.gds",
|
|
|
|
options={'HIDDEN'},
|
|
|
|
)
|
|
|
|
|
2019-07-03 13:53:25 +02:00
|
|
|
# use_edges = BoolProperty(
|
|
|
|
# name="Lines",
|
|
|
|
# description="Import lines and faces with 2 verts as edge",
|
|
|
|
# default=True,
|
|
|
|
# )
|
|
|
|
# use_smooth_groups = BoolProperty(
|
|
|
|
# name="Smooth Groups",
|
|
|
|
# description="Surround smooth groups by sharp edges",
|
|
|
|
# default=True,
|
|
|
|
# )
|
|
|
|
|
|
|
|
# use_split_objects = BoolProperty(
|
|
|
|
# name="Object",
|
|
|
|
# description="Import OBJ Objects into Blender Objects",
|
|
|
|
# default=True,
|
|
|
|
# )
|
|
|
|
# use_split_groups = BoolProperty(
|
|
|
|
# name="Group",
|
|
|
|
# description="Import OBJ Groups into Blender Objects",
|
|
|
|
# default=True,
|
|
|
|
# )
|
|
|
|
|
|
|
|
# use_groups_as_vgroups = BoolProperty(
|
|
|
|
# name="Poly Groups",
|
|
|
|
# description="Import OBJ groups as vertex groups",
|
|
|
|
# default=False,
|
|
|
|
# )
|
|
|
|
|
|
|
|
# use_image_search = BoolProperty(
|
|
|
|
# name="Image Search",
|
|
|
|
# description="Search subdirs for any associated images "
|
|
|
|
# "(Warning, may be slow)",
|
|
|
|
# default=True,
|
|
|
|
# )
|
|
|
|
|
|
|
|
# split_mode = EnumProperty(
|
|
|
|
# name="Split",
|
|
|
|
# items=(('ON', "Split", "Split geometry, omits unused verts"),
|
|
|
|
# ('OFF', "Keep Vert Order", "Keep vertex order from file"),
|
|
|
|
# ),
|
|
|
|
# )
|
|
|
|
|
|
|
|
# global_clamp_size = FloatProperty(
|
|
|
|
# name="Clamp Size",
|
|
|
|
# description="Clamp bounds under this value (zero to disable)",
|
|
|
|
# min=0.0, max=1000.0,
|
|
|
|
# soft_min=0.0, soft_max=1000.0,
|
|
|
|
# default=0.0,
|
|
|
|
# )
|
|
|
|
|
|
|
|
top_cell_name = StringProperty(
|
|
|
|
name="Top Cell Name",
|
|
|
|
#descriptionn="When set, only import the structure with that name",
|
|
|
|
default="",
|
|
|
|
)
|
2019-07-02 14:44:42 +02:00
|
|
|
|
|
|
|
def execute(self, context):
|
|
|
|
# print("Selected: " + context.active_object.name)
|
|
|
|
from . import import_gds
|
2019-07-04 21:22:20 +02:00
|
|
|
from . import gds
|
2019-07-02 14:44:42 +02:00
|
|
|
|
2019-07-03 13:53:25 +02:00
|
|
|
# ignore axis helper arguments
|
2019-07-02 14:44:42 +02:00
|
|
|
keywords = self.as_keywords(ignore=("axis_forward",
|
|
|
|
"axis_up",
|
|
|
|
"filter_glob",
|
|
|
|
"split_mode",
|
|
|
|
))
|
|
|
|
|
|
|
|
if bpy.data.is_saved and context.user_preferences.filepaths.use_relative_paths:
|
|
|
|
import os
|
|
|
|
keywords["relpath"] = os.path.dirname(bpy.data.filepath)
|
2019-07-04 21:22:20 +02:00
|
|
|
|
|
|
|
# do the file import
|
|
|
|
progressCounter = import_gds.Progressor(context.window_manager)
|
|
|
|
|
|
|
|
try:
|
|
|
|
with open(keywords["filepath"], "rb") as file:
|
|
|
|
lib = gds.parse_file(file, progressCounter)
|
|
|
|
except gds.ParserError as e:
|
|
|
|
self.report({"ERROR_INVALID_INPUT"}, "cannot parse given gds file: {}".format(e))
|
|
|
|
|
|
|
|
progressCounter.end()
|
|
|
|
sceneInserter = import_gds.SceneInserter(context, lib, top_cell=keywords["top_cell_name"])
|
|
|
|
|
|
|
|
if not sceneInserter(progressCounter):
|
2019-07-03 13:53:25 +02:00
|
|
|
self.report({"ERROR_INVALID_INPUT"}, "Could not find structure with name {}".format(keywords["top_cell_name"]))
|
2019-07-04 21:22:20 +02:00
|
|
|
return {"CANCELLED"}
|
|
|
|
|
|
|
|
return {"FINISHED"}
|
2019-07-03 13:53:25 +02:00
|
|
|
|
2019-07-02 14:44:42 +02:00
|
|
|
def draw(self, context):
|
|
|
|
layout = self.layout
|
|
|
|
|
2019-07-03 13:53:25 +02:00
|
|
|
row = layout.row()
|
|
|
|
row.prop(self, "top_cell_name")
|
|
|
|
|
2019-07-04 21:22:20 +02:00
|
|
|
|
2019-07-03 13:53:25 +02:00
|
|
|
# row = layout.row(align=True)
|
|
|
|
# row.prop(self, "use_smooth_groups")
|
|
|
|
# row.prop(self, "use_edges")
|
2019-07-02 14:44:42 +02:00
|
|
|
|
2019-07-03 13:53:25 +02:00
|
|
|
# box = layout.box()
|
|
|
|
# row = box.row()
|
|
|
|
# row.prop(self, "split_mode", expand=True)
|
2019-07-02 14:44:42 +02:00
|
|
|
|
2019-07-03 13:53:25 +02:00
|
|
|
# row = box.row()
|
|
|
|
# if self.split_mode == 'ON':
|
|
|
|
# row.label(text="Split by:")
|
|
|
|
# row.prop(self, "use_split_objects")
|
|
|
|
# row.prop(self, "use_split_groups")
|
|
|
|
# else:
|
|
|
|
# row.prop(self, "use_groups_as_vgroups")
|
2019-07-02 14:44:42 +02:00
|
|
|
|
2019-07-03 13:53:25 +02:00
|
|
|
# row = layout.split(percentage=0.67)
|
|
|
|
# row.prop(self, "global_clamp_size")
|
|
|
|
# layout.prop(self, "axis_forward")
|
|
|
|
# layout.prop(self, "axis_up")
|
2019-07-02 14:44:42 +02:00
|
|
|
|
2019-07-03 13:53:25 +02:00
|
|
|
# layout.prop(self, "use_image_search")
|
2019-07-02 14:44:42 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def menu_func_import(self, context):
|
|
|
|
self.layout.operator(ImportGDS.bl_idname, text="GDSII Stream (.gds)")
|
|
|
|
|
|
|
|
classes = (
|
|
|
|
ImportGDS,
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
def register():
|
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.register_class(cls)
|
|
|
|
|
|
|
|
bpy.types.INFO_MT_file_import.append(menu_func_import)
|
|
|
|
|
|
|
|
|
|
|
|
def unregister():
|
|
|
|
bpy.types.INFO_MT_file_import.remove(menu_func_import)
|
|
|
|
|
|
|
|
for cls in classes:
|
|
|
|
bpy.utils.unregister_class(cls)
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
register()
|