modules/rna_xml.py: BoolVectorProperty and CollectionProperty #31703

Closed
opened 2012-06-04 17:52:09 +02:00 by n floyd · 5 comments

%%%in rna_xml.xml2rna.rna2xml_node(): -- shouldn't it be xml_node2rna() ?? --

BoolVectorProperty :

   line 260ish:
         value_xml_split = value_xml.split()
         try:
               value_xml_coerce = [int(v) for v in value_xml_split]
         except ValueError:
                value_xml_coerce = [float(v) for v in value_xml_split]
  • if value_xml stores a BoolVectorProperty, float(v) will raise another ValueError

         value_xml_split = value_xml.split()
         try:
               value_xml_coerce = [int(v) for v in value_xml_split]
               except ValueError:
                    try:
                         value_xml_coerce = [float(v) for v in value_xml_split]
                    except ValueError: # bool vector property
                          value_xml_coerce = [{'TRUE': True, 'FALSE': False}[v] for v in value_xml_split]

CollectionProperty:

line 280ish:

  if hasattr(subvalue, "__len__"):
    # Collection
      if len(elems) != len(subvalue):
          print("Size Mismatch! collection:", child_xml.nodeName)
       else:
          for i in range(len(elems)):
            # ...

Should a CollectionProperty have a fixed size ?

  I've used it to store an arbitrary number of items.
  So when restoring a saved preset which contains a Collection of a different size than the one in the active preset,  it doesn't work.
  I've resorted to dynamically adjust the size of the CollectionProperty
      if len(elems) != len(subvalue):
          while len(elems) > len(subvalue):
              subvalue.add()
          while len(elems) < len(subvalue):
               subvalue.remove(0)
      for i in range(len(elems)):
            # ...

%%%

%%%in rna_xml.xml2rna.rna2xml_node(): -- shouldn't it be xml_node2rna() ?? -- BoolVectorProperty : ---------------------------- ``` line 260ish: value_xml_split = value_xml.split() try: value_xml_coerce = [int(v) for v in value_xml_split] except ValueError: value_xml_coerce = [float(v) for v in value_xml_split] ``` - > if value_xml stores a BoolVectorProperty, float(v) will raise another ValueError ``` value_xml_split = value_xml.split() try: value_xml_coerce = [int(v) for v in value_xml_split] except ValueError: try: value_xml_coerce = [float(v) for v in value_xml_split] except ValueError: # bool vector property value_xml_coerce = [{'TRUE': True, 'FALSE': False}[v] for v in value_xml_split] ``` CollectionProperty: -------------------------- line 280ish: ``` if hasattr(subvalue, "__len__"): ``` # Collection ``` if len(elems) != len(subvalue): print("Size Mismatch! collection:", child_xml.nodeName) else: for i in range(len(elems)): ``` # ... Should a CollectionProperty have a fixed size ? ``` I've used it to store an arbitrary number of items. So when restoring a saved preset which contains a Collection of a different size than the one in the active preset, it doesn't work. I've resorted to dynamically adjust the size of the CollectionProperty ``` ``` if len(elems) != len(subvalue): while len(elems) > len(subvalue): subvalue.add() while len(elems) < len(subvalue): subvalue.remove(0) for i in range(len(elems)): ``` # ... %%%
Author

Changed status to: 'Open'

Changed status to: 'Open'
Author

%%%I should have included a file to demonstrate this better.
Here's one in attachment, packaged as a addon. (import-export/ bug-report 31703)
The UI panel is in View3d/properties/bug_31703%%%

%%%I should have included a file to demonstrate this better. Here's one in attachment, packaged as a addon. (import-export/ bug-report 31703) The UI panel is in View3d/properties/bug_31703%%%

%%%Campbell, afraid this one is for you.%%%

%%%Campbell, afraid this one is for you.%%%

%%%applied fix r50873. closing.%%%

%%%applied fix r50873. closing.%%%

Changed status from 'Open' to: 'Resolved'

Changed status from 'Open' to: 'Resolved'
Sign in to join this conversation.
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#31703
No description provided.