Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlijenstina <lijenstina@gmail.com>2017-11-27 08:16:16 +0300
committerBastien Montagne <montagne29@wanadoo.fr>2018-01-06 18:42:16 +0300
commitdd9965f37c3b68050fc9e50d0e9ef80adae86e80 (patch)
treebe5f6beb084cad38ac93c100f03caf637021bcdd
parentea5d7b0e343e7d5f58e89d100d11d4c1ffb4b148 (diff)
HiRISE DTM Importer: Fix operator call through Python, minor cleanup
Bump version to 0.2.2 Merge Differential revision: D2926 The importer should be called with: bpy.ops.import_mesh.pds_dtm Replace deprecated imp calls with importlib Move bl_info on top of the file Imports as tuples Update wiki link ReloadTerrain operator: - add a poll to prevent crashes when called through search with no object
-rw-r--r--io_convert_image_to_mesh_img/__init__.py23
-rw-r--r--io_convert_image_to_mesh_img/ui/importer.py19
-rw-r--r--io_convert_image_to_mesh_img/ui/terrainpanel.py25
3 files changed, 42 insertions, 25 deletions
diff --git a/io_convert_image_to_mesh_img/__init__.py b/io_convert_image_to_mesh_img/__init__.py
index 4594b751..1e5bdddf 100644
--- a/io_convert_image_to_mesh_img/__init__.py
+++ b/io_convert_image_to_mesh_img/__init__.py
@@ -19,28 +19,29 @@
"""A HiRISE DTM Importer for Blender"""
-import bpy
-
-from .ui import importer
-from .ui import terrainpanel
-
bl_info = {
"name": "HiRISE DTM Importer",
"author": "Nicholas Wolf (nicwolf@pirl.lpl.arizona.edu)",
- "version": (0, 2, 1),
+ "version": (0, 2, 2),
"blender": (2, 78, 0),
"location": "File > Import > HiRISE DTM (.img)",
- "description": "Import a HiRISE DTM as a mesh.",
+ "description": "Import a HiRISE DTM as a mesh",
"warning": "May consume a lot of memory",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/Import-Export/HiRISE_DTM_from_PDS_IMG",
"category": "Import-Export",
}
if "bpy" in locals():
- import imp
- imp.reload(importer)
- imp.reload(terrainpanel)
+ import importlib
+ importlib.reload(importer)
+ importlib.reload(terrainpanel)
+
+else:
+ from .ui import importer
+ from .ui import terrainpanel
+
+import bpy
def menu_import(self, context):
diff --git a/io_convert_image_to_mesh_img/ui/importer.py b/io_convert_image_to_mesh_img/ui/importer.py
index 35e82f62..2b6a911e 100644
--- a/io_convert_image_to_mesh_img/ui/importer.py
+++ b/io_convert_image_to_mesh_img/ui/importer.py
@@ -20,7 +20,11 @@
"""Blender menu importer for loading a DTM"""
import bpy
-import bpy.props
+from bpy.props import (
+ BoolProperty,
+ FloatProperty,
+ StringProperty,
+ )
from bpy_extras.io_utils import ImportHelper
from ..mesh.terrain import BTerrain
@@ -29,11 +33,12 @@ from ..mesh.dtm import DTM
class ImportHiRISETerrain(bpy.types.Operator, ImportHelper):
"""DTM Import Helper"""
- bl_idname = "import.pds_dtm"
+ bl_idname = "import_mesh.pds_dtm"
bl_label = "Import HiRISE Terrain Model"
bl_options = {'UNDO'}
+
filename_ext = ".img"
- filter_glob = bpy.props.StringProperty(
+ filter_glob = StringProperty(
options={'HIDDEN'},
default="*.img"
)
@@ -55,7 +60,7 @@ class ImportHiRISETerrain(bpy.types.Operator, ImportHelper):
# functions to the property itself because they result in a recursion
# error. Instead, we use another, hidden, property to store the scaled
# resolution.
- dtm_resolution = bpy.props.FloatProperty(
+ dtm_resolution = FloatProperty(
subtype="PERCENTAGE",
description=(
"Percentage scale for terrain model resolution. 100\% loads the "
@@ -73,7 +78,7 @@ class ImportHiRISETerrain(bpy.types.Operator, ImportHelper):
name="Terrain Model Resolution",
min=1.0, max=100.0, default=10.0
)
- scaled_dtm_resolution = bpy.props.FloatProperty(
+ scaled_dtm_resolution = FloatProperty(
options={'HIDDEN'},
name="Scaled Terrain Model Resolution",
get=(lambda self: self.dtm_resolution / 100)
@@ -91,7 +96,7 @@ class ImportHiRISETerrain(bpy.types.Operator, ImportHelper):
# Blender to change the clipping distance to something appropriate for
# the DTM, and scales the grid floor to have gridlines 1km apart,
# instead of 1m apart.
- should_setup_viewport = bpy.props.BoolProperty(
+ should_setup_viewport = BoolProperty(
description=(
"Set up the Blender screen to try and avoid clipping the DTM "
"and to make the grid floor larger. *WARNING* This will change "
@@ -102,7 +107,7 @@ class ImportHiRISETerrain(bpy.types.Operator, ImportHelper):
)
# 2. Blender's default units are dimensionless. This option instructs
# Blender to change its unit's dimension to meters.
- should_setup_units = bpy.props.BoolProperty(
+ should_setup_units = BoolProperty(
description=(
"Set the Blender scene to use meters as its unit"
),
diff --git a/io_convert_image_to_mesh_img/ui/terrainpanel.py b/io_convert_image_to_mesh_img/ui/terrainpanel.py
index 5e61c421..e41f8821 100644
--- a/io_convert_image_to_mesh_img/ui/terrainpanel.py
+++ b/io_convert_image_to_mesh_img/ui/terrainpanel.py
@@ -20,13 +20,18 @@
"""Blender panel for managing a DTM *after* it's been imported"""
import bpy
+from bpy.types import (
+ Operator,
+ Panel,
+ )
+from bpy.props import FloatProperty
from ..mesh.terrain import BTerrain
from ..mesh.dtm import DTM
-class TerrainPanel(bpy.types.Panel):
- """Creates a Panel in the Object properites window for terrain objects"""
+class TerrainPanel(Panel):
+ """Creates a Panel in the Object properties window for terrain objects"""
bl_label = "Terrain Model"
bl_idname = "OBJECT_PT_terrain"
bl_space_type = "PROPERTIES"
@@ -50,7 +55,7 @@ class TerrainPanel(bpy.types.Panel):
# functions to the property itself because they result in a recursion
# error. Instead, we use another, hidden, property to store the scaled
# resolution.
- bpy.types.Object.dtm_resolution = bpy.props.FloatProperty(
+ bpy.types.Object.dtm_resolution = FloatProperty(
subtype="PERCENTAGE",
name="New Resolution",
description=(
@@ -65,7 +70,7 @@ class TerrainPanel(bpy.types.Panel):
),
min=1.0, max=100.0, default=10.0
)
- bpy.types.Object.scaled_dtm_resolution = bpy.props.FloatProperty(
+ bpy.types.Object.scaled_dtm_resolution = FloatProperty(
options={'HIDDEN'},
name="Scaled Terrain Model Resolution",
get=(lambda self: self.dtm_resolution / 100.0)
@@ -73,7 +78,8 @@ class TerrainPanel(bpy.types.Panel):
@classmethod
def poll(cls, context):
- return context.object.get("IS_TERRAIN", False)
+ obj = context.active_object
+ return obj and obj.get("IS_TERRAIN", False)
def draw(self, context):
obj = context.active_object
@@ -114,14 +120,19 @@ class TerrainPanel(bpy.types.Panel):
return {'FINISHED'}
-class ReloadTerrain(bpy.types.Operator):
+class ReloadTerrain(Operator):
"""Button for reloading the terrain mesh at a new resolution"""
bl_idname = "terrain.reload"
bl_label = "Reload Terrain"
+ @classmethod
+ def poll(cls, context):
+ obj = context.active_object
+ return obj and obj.get("IS_TERRAIN", False)
+
def execute(self, context):
# Reload the terrain
- obj = context.object
+ obj = context.active_object
path = obj['PATH']
scaled_dtm_resolution = obj.scaled_dtm_resolution