Skip to content
Snippets Groups Projects
Commit 79d1a85d authored by Campbell Barton's avatar Campbell Barton
Browse files

fix [#34606] x3d file with comma separated coordinates doesn't import

parent 93be8553
Branches
Tags
No related merge requests found
...@@ -532,7 +532,7 @@ class vrmlNode(object): ...@@ -532,7 +532,7 @@ class vrmlNode(object):
child.searchNodeTypeID(node_spec, results) child.searchNodeTypeID(node_spec, results)
return results return results
def getFieldName(self, field, ancestry, AS_CHILD=False): def getFieldName(self, field, ancestry, AS_CHILD=False, SPLIT_COMMAS=False):
self_real = self.getRealNode() # in case we're an instance self_real = self.getRealNode() # in case we're an instance
for f in self_real.fields: for f in self_real.fields:
...@@ -739,7 +739,7 @@ class vrmlNode(object): ...@@ -739,7 +739,7 @@ class vrmlNode(object):
self_real = self.getRealNode() # in case we're an instance self_real = self.getRealNode() # in case we're an instance
child_array = self_real.getFieldName(field, ancestry, True) child_array = self_real.getFieldName(field, ancestry, True, SPLIT_COMMAS=True)
#if type(child_array)==list: # happens occasionaly #if type(child_array)==list: # happens occasionaly
# array_data = child_array # array_data = child_array
...@@ -747,23 +747,15 @@ class vrmlNode(object): ...@@ -747,23 +747,15 @@ class vrmlNode(object):
if child_array is None: if child_array is None:
# For x3d, should work ok with vrml too # For x3d, should work ok with vrml too
# for x3d arrays are fields, vrml they are nodes, annoying but not tooo bad. # for x3d arrays are fields, vrml they are nodes, annoying but not tooo bad.
data_split = self.getFieldName(field, ancestry) data_split = self.getFieldName(field, ancestry, SPLIT_COMMAS=True)
if not data_split: if not data_split:
return [] return []
array_data = ' '.join(data_split)
if array_data is None:
return []
array_data = array_data.replace(',', ' ')
data_split = array_data.split()
array_data = array_as_number(data_split) array_data = array_as_number(data_split)
elif type(child_array) == list: elif type(child_array) == list:
# x3d creates these # x3d creates these
data_split = [w.strip(",") for w in child_array] array_data = array_as_number(child_array)
array_data = array_as_number(data_split)
else: else:
# print(child_array) # print(child_array)
# Normal vrml # Normal vrml
...@@ -1344,7 +1336,7 @@ class x3dNode(vrmlNode): ...@@ -1344,7 +1336,7 @@ class x3dNode(vrmlNode):
# Other funcs operate from vrml, but this means we can wrap XML fields, still use nice utility funcs # Other funcs operate from vrml, but this means we can wrap XML fields, still use nice utility funcs
# getFieldAsArray getFieldAsBool etc # getFieldAsArray getFieldAsBool etc
def getFieldName(self, field, ancestry, AS_CHILD=False): def getFieldName(self, field, ancestry, AS_CHILD=False, SPLIT_COMMAS=False):
# ancestry and AS_CHILD are ignored, only used for VRML now # ancestry and AS_CHILD are ignored, only used for VRML now
self_real = self.getRealNode() # in case we're an instance self_real = self.getRealNode() # in case we're an instance
...@@ -1354,6 +1346,8 @@ class x3dNode(vrmlNode): ...@@ -1354,6 +1346,8 @@ class x3dNode(vrmlNode):
# We may want to edit. for x3d specific stuff # We may want to edit. for x3d specific stuff
# Sucks a bit to return the field name in the list but vrml excepts this :/ # Sucks a bit to return the field name in the list but vrml excepts this :/
if SPLIT_COMMAS:
value = value.replace(",", " ")
return value.split() return value.split()
else: else:
return None return None
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment