Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Copyright (C) 2013, Niklas Rosenstein
- # All rights reserved.
- #
- # This program is free software: you can redistribute it and/or modify
- # it under the terms of the GNU Lesser 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 Lesser General Public License for more details.
- #
- # You should have received a copy of the Lesser GNU General Public License
- # along with this program. If not, see <http://www.gnu.org/licenses/>.
- import os
- import c4d
- delimiter_1 = ':'
- delimiter_2 = ';'
- precision = 3
- Omograph_cloner = 1018544
- def filter_objects(doc, type_id, children=False):
- def callback(op):
- if op.CheckType(type_id):
- yield op
- if not children: return
- for child in op.GetChildren():
- for obj in callback(child):
- yield obj
- for obj in doc.GetObjects():
- for o in callback(obj):
- yield o
- def main():
- flname = c4d.storage.SaveDialog(force_suffix='txt')
- if not flname:
- return
- if os.path.exists(flname) and not os.path.isfile(flname):
- c4d.gui.MessageDialog('Invalid file-name.')
- return
- try:
- fl = open(flname, 'w')
- except IOError, OSError:
- c4d.gui.MessageDialog('Could not open file.')
- return
- for cloner in filter_objects(doc, Omograph_cloner):
- name = cloner.GetName().replace(delimiter_1, '\\%s' % delimiter_1)
- fl.write(name + delimiter_1)
- cache = cloner.GetCache()
- if cache:
- values = []
- for clones in cache.GetChildren():
- pos = clones.GetMg().off
- values.extend([pos.x, pos.y, pos.z])
- format = '%%.%df' % precision
- line = delimiter_2.join(format % v for v in values)
- fl.write(line)
- fl.write('\n')
- fl.close()
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement