Resolve "[CG Pipeline] баг при работе с файлом FreeCAD asm4 tower.FCStd" #186

Merged
brothermechanic merged 1 commit from 50-deselect-nonsolids into master 2023-03-12 22:31:48 +03:00
3 changed files with 41 additions and 1 deletions

6
.gitignore vendored
View file

@ -103,4 +103,8 @@ ENV/
# blender backup files # blender backup files
*.blend1 *.blend1
install_plugin_cad.sh install_plugin_cad.sh
.vscode .vscode
# emacs backup files
~*
*#

View file

@ -23,6 +23,7 @@ import bpy
from bpy_extras.node_shader_utils import PrincipledBSDFWrapper from bpy_extras.node_shader_utils import PrincipledBSDFWrapper
from import_fcstd.handler import FreeCAD_xml_handler from import_fcstd.handler import FreeCAD_xml_handler
from import_fcstd.materials import set_fem_mat from import_fcstd.materials import set_fem_mat
from import_fcstd.is_object_solid import is_object_solid
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.INFO) logging.basicConfig(level=logging.INFO)
@ -123,6 +124,10 @@ def importer(filename,
# TODO add parent visibility check # TODO add parent visibility check
continue continue
if not is_object_solid(obj):
logger.debug('%s is not solid', obj.Label)
continue
verts = [] verts = []
edges = [] edges = []
faces = [] faces = []

View 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