solid test and disable importing nonsolid objects
This commit is contained in:
parent
1ea7e50ecd
commit
37bdfcd5e9
3 changed files with 41 additions and 1 deletions
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -103,4 +103,8 @@ ENV/
|
|||
# blender backup files
|
||||
*.blend1
|
||||
install_plugin_cad.sh
|
||||
.vscode
|
||||
.vscode
|
||||
|
||||
# emacs backup files
|
||||
~*
|
||||
*#
|
||||
|
|
|
@ -23,6 +23,7 @@ import bpy
|
|||
from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
|
||||
from import_fcstd.handler import FreeCAD_xml_handler
|
||||
from import_fcstd.materials import set_fem_mat
|
||||
from import_fcstd.is_object_solid import is_object_solid
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
|
@ -123,6 +124,10 @@ def importer(filename,
|
|||
# TODO add parent visibility check
|
||||
continue
|
||||
|
||||
if not is_object_solid(obj):
|
||||
logger.debug('%s is not solid', obj.Label)
|
||||
continue
|
||||
|
||||
verts = []
|
||||
edges = []
|
||||
faces = []
|
||||
|
|
31
cg/blender/import_fcstd/is_object_solid.py
Normal file
31
cg/blender/import_fcstd/is_object_solid.py
Normal file
|
@ -0,0 +1,31 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
# Original code by (C) 2019 yorikvanhavre <yorik@uncreated.net>
|
||||
# Copyright (C) 2023 Ilia Kurochkin <brothermechanic@gmail.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
import FreeCAD
|
||||
|
||||
|
||||
def is_object_solid(obj):
|
||||
"""If obj is solid return True"""
|
||||
if not isinstance(obj, FreeCAD.DocumentObject):
|
||||
return False
|
||||
|
||||
if not hasattr(obj, 'Shape'):
|
||||
return False
|
||||
|
||||
if not hasattr(obj.Shape, 'Solids'):
|
||||
return False
|
||||
|
||||
if len(obj.Shape.Solids) == 0:
|
||||
return False
|
||||
|
||||
return True
|
Loading…
Add table
Add a link
Reference in a new issue