def _setupBitShape(self, obj, path=None): PathLog.track(obj.Label) activeDoc = FreeCAD.ActiveDocument (doc, docOpened) = self._loadBitBody(obj, path) obj.Label = doc.RootObjects[0].Label self._deleteBitSetup(obj) bitBody = obj.Document.copyObject(doc.RootObjects[0], True) docName = doc.Name if docOpened: FreeCAD.setActiveDocument(activeDoc.Name) FreeCAD.closeDocument(doc.Name) if bitBody.ViewObject: bitBody.ViewObject.Visibility = False PathLog.debug("bitBody.{} ({}): {}".format(bitBody.Label, bitBody.Name, type(bitBody))) propNames = [] for attributes in [ o for o in bitBody.Group if PathPropertyBag.IsPropertyBag(o) ]: PathLog.debug("Process properties from {}".format( attributes.Label)) for prop in attributes.Proxy.getCustomProperties(): self._setupProperty(obj, prop, attributes) propNames.append(prop) if not propNames: PathLog.error( translate( 'PathToolBit', 'Did not find a PropertyBag in {} - not a ToolBit shape?'). format(docName)) # has to happen last because it could trigger op.execute evaluations obj.BitPropertyNames = propNames obj.BitBody = bitBody self._copyBitShape(obj)
GroupMap[g[0]] = g[1] if args.set: s = args.set.split('=') if len(s) != 2: print("ERROR: {} not a valid group mapping".format(args.move)) sys.exit(1) set_var = s[0] set_val = s[1] for i, fname in enumerate(args.path): #print(fname) doc = FreeCAD.openDocument(fname, False) print("{}:".format(doc.Name)) for o in doc.Objects: if PathPropertyBag.IsPropertyBag(o): if args.print_groups: print(" {}: {}".format(o.Label, sorted(o.CustomPropertyGroups))) else: print(" {}:".format(o.Label)) for p in o.Proxy.getCustomProperties(): grp = o.getGroupOfProperty(p) typ = o.getTypeIdOfProperty(p) ttp = PathPropertyBag.getPropertyTypeName(typ) val = PathUtil.getProperty(o, p) dsc = o.getDocumentationOfProperty(p) enm = '' enum = [] if ttp == 'Enumeration': enum = o.getEnumerationsOfProperty(p) enm = "{}".format(','.join(enum))