@@ -1725,14 +1725,23 @@ def get_extended_skin_bones(obj, skin_bones: list=None, ignore_pivot=False):
17251725 objects .extend (child_objects )
17261726 skin_bones = []
17271727 for obj in objects :
1728- SC = obj .GetSkeletonComponent ()
1729- skin_bones = SC .GetSkinBones ()
1730- for bone in skin_bones :
1731- if bone not in skin_bones :
1732- skin_bones .append (bone )
1728+ SC = safe_get_skeleton_component (obj )
1729+ if SC :
1730+ skin_bones = SC .GetSkinBones ()
1731+ for bone in skin_bones :
1732+ if bone not in skin_bones :
1733+ skin_bones .append (bone )
17331734 return skin_bones
17341735
17351736
1737+ def safe_get_skeleton_component (obj : RIObject ) -> RISkeletonComponent :
1738+ try :
1739+ if hasattr (obj , "GetSkeletonComponent" ):
1740+ return obj .GetSkeletonComponent ()
1741+ return None
1742+ except :
1743+ return None
1744+
17361745def get_extended_skin_bones_tree (avatar_or_prop : RIObject ):
17371746
17381747 child_objects : list = RScene .FindChildObjects (avatar_or_prop , EObjectType_Prop | EObjectType_Accessory )
@@ -1742,33 +1751,34 @@ def get_extended_skin_bones_tree(avatar_or_prop: RIObject):
17421751 bone_defs = {}
17431752 defs = []
17441753 for obj in objects :
1745- SC = obj .GetSkeletonComponent ()
1746- root = SC .GetRootBone ()
1747- skin_bones = SC .GetSkinBones ()
1748- if skin_bones :
1749- num_bones = 0
1750- for bone in skin_bones :
1751- if bone .GetName ():
1752- num_bones += 1
1753- bone : RINode
1754- if num_bones > 0 :
1755- link_id = get_link_id (obj , add_if_missing = True )
1756- for bone in skin_bones :
1757- if bone .GetID () not in bone_defs :
1758- bone_name = bone .GetName ()
1759- if bone_name :
1760- bone_def = {
1761- "bone" : bone ,
1762- "id" : bone .GetID (),
1763- "object" : obj ,
1764- "root" : bone .GetID () == root .GetID (),
1765- "name" : bone_name ,
1766- "children" : [],
1767- "parent" : bone .GetParent (),
1768- "SC" : SC ,
1769- }
1770- bone_defs [bone .GetID ()] = bone_def
1771- defs .append (bone_def )
1754+ SC = safe_get_skeleton_component (obj )
1755+ if SC :
1756+ root = SC .GetRootBone ()
1757+ skin_bones = SC .GetSkinBones ()
1758+ if skin_bones :
1759+ num_bones = 0
1760+ for bone in skin_bones :
1761+ if bone .GetName ():
1762+ num_bones += 1
1763+ bone : RINode
1764+ if num_bones > 0 :
1765+ link_id = get_link_id (obj , add_if_missing = True )
1766+ for bone in skin_bones :
1767+ if bone .GetID () not in bone_defs :
1768+ bone_name = bone .GetName ()
1769+ if bone_name :
1770+ bone_def = {
1771+ "bone" : bone ,
1772+ "id" : bone .GetID (),
1773+ "object" : obj ,
1774+ "root" : bone .GetID () == root .GetID (),
1775+ "name" : bone_name ,
1776+ "children" : [],
1777+ "parent" : bone .GetParent (),
1778+ "SC" : SC ,
1779+ }
1780+ bone_defs [bone .GetID ()] = bone_def
1781+ defs .append (bone_def )
17721782
17731783 orphaned = []
17741784 for bone_def in defs :
@@ -1886,37 +1896,38 @@ def get_extended_skin_bones_tree_debug(prop: RIObject):
18861896 utils .log_always (f"loc: { [t .x , t .y , t .z ]} " )
18871897 utils .log_always (f"rot: { [r .x , r .y , r .z , r .w ]} " )
18881898 utils .log_always (f"sca: { [s .x , s .y , s .z ]} " )
1889- SC = obj .GetSkeletonComponent ()
1890- root = SC .GetRootBone ()
1891- skin_bones = SC .GetSkinBones ()
1892- if skin_bones :
1893- num_bones = 0
1894- for bone in skin_bones :
1895- if bone .GetName ():
1896- num_bones += 1
1897- bone : RINode
1898- if num_bones > 0 :
1899- link_id = get_link_id (obj , add_if_missing = True )
1900- for bone in skin_bones :
1901- if bone .GetID () not in bone_defs :
1902- bone_name = bone .GetName ()
1903- T : RTransform = bone .WorldTransform ()
1904- t : RVector3 = T .T ()
1905- r : RQuaternion = T .R ()
1906- s : RVector3 = T .S ()
1907- if bone_name :
1908- bone_def = {
1909- "bone" : bone ,
1910- "object" : obj .GetName (),
1911- "root" : bone .GetID () == root .GetID (),
1912- "name" : bone_name ,
1913- "loc" : [t .x , t .y , t .z ],
1914- "rot" : [r .x , r .y , r .z , r .w ],
1915- "sca" : [s .x , s .y , s .z ],
1916- "children" : [],
1917- }
1918- bone_defs [bone .GetID ()] = bone_def
1919- defs .append (bone_def )
1899+ SC = safe_get_skeleton_component (obj )
1900+ if SC :
1901+ root = SC .GetRootBone ()
1902+ skin_bones = SC .GetSkinBones ()
1903+ if skin_bones :
1904+ num_bones = 0
1905+ for bone in skin_bones :
1906+ if bone .GetName ():
1907+ num_bones += 1
1908+ bone : RINode
1909+ if num_bones > 0 :
1910+ link_id = get_link_id (obj , add_if_missing = True )
1911+ for bone in skin_bones :
1912+ if bone .GetID () not in bone_defs :
1913+ bone_name = bone .GetName ()
1914+ T : RTransform = bone .WorldTransform ()
1915+ t : RVector3 = T .T ()
1916+ r : RQuaternion = T .R ()
1917+ s : RVector3 = T .S ()
1918+ if bone_name :
1919+ bone_def = {
1920+ "bone" : bone ,
1921+ "object" : obj .GetName (),
1922+ "root" : bone .GetID () == root .GetID (),
1923+ "name" : bone_name ,
1924+ "loc" : [t .x , t .y , t .z ],
1925+ "rot" : [r .x , r .y , r .z , r .w ],
1926+ "sca" : [s .x , s .y , s .z ],
1927+ "children" : [],
1928+ }
1929+ bone_defs [bone .GetID ()] = bone_def
1930+ defs .append (bone_def )
19201931 for bone_def in defs :
19211932 bone = bone_def ["bone" ]
19221933 bone_name = bone_def ["name" ]
0 commit comments