FEM: fem utils, add def to return type for all objects (Python and C++)

This commit is contained in:
Bernd Hahnebach
2018-01-09 07:30:10 +01:00
parent ff1601be5f
commit a4c2d276db

View File

@@ -1,6 +1,7 @@
# ***************************************************************************
# * *
# * Copyright (c) 2017 - Markus Hovorka <m.hovorka@live.de> *
# * Copyright (c) 2018 - Bernd Hahnebach <bernd@bimstatik.org> *
# * *
# * This program is free software; you can redistribute it and/or modify *
# * it under the terms of the GNU Lesser General Public License (LGPL) *
@@ -22,7 +23,7 @@
__title__ = "FEM Utilities"
__author__ = "Markus Hovorka"
__author__ = "Markus Hovorka, Bernd Hahnebach"
__url__ = "http://www.freecadweb.org"
@@ -73,6 +74,21 @@ def getSingleMember(analysis, t):
return objs[0] if objs else None
def typeOfObj(obj):
'''returns objects TypeId (C++ objects) or Proxy.Type (Python objects)'''
if hasattr(obj, "Proxy") and hasattr(obj.Proxy, "Type"):
return obj.Proxy.Type
return obj.TypeId
def isOfTypeNew(obj, ty):
'''returns if an object is of a given TypeId (C++ objects) or Proxy.Type (Python objects)'''
if typeOfObj(obj) == ty:
return True
else:
return False
def isOfType(obj, t):
if hasattr(obj, "Proxy") and hasattr(obj.Proxy, "Type"):
return obj.Proxy.Type == t