我们从Python开源项目中,提取了以下12个代码示例,用于说明如何使用System.Object()。
def unflatten_to_data_tree(all_data, pattern): """Create DataTree from a flattrn list based on the pattern. Args: all_data: A flattened list of all data pattern: A dictonary of patterns Pattern = namedtuple('Pattern', 'path index count') Returns: data_tree: A Grasshopper DataTree. """ data_tree = DataTree[Object]() for branch in xrange(len(pattern)): path, index, count = pattern[branch] data_tree.AddRange(all_data[index - count:index], path) return data_tree
def getEnergyPlusObjectsFromString(epFileString): """ Parse idf file string and return a list of EnergyPlus objects as separate strings TODO: Create a class for each EnergyPlus object and return Python objects instead of strings Args: epFileString: EnergyPlus data as a single string. The string can be multiline Returns: A list of strings. Each string represents a differnt Rdiance Object """ rawEPObjects = re.findall(r'(.[^;]*;.[^\n]*)', epFileString + "\n",re.MULTILINE) return rawEPObjects
def getEnergyPlusObjectsFromFile(self, epFilePath): """ Parse EnergyPlus file and return a list of radiance objects as separate strings TODO: Create a class for each EnergyPlus object and return Python objects instead of strings Args: epFilePath: Path to EnergyPlus file Returns: A list of strings. Each string represents a differnt Rdiance Object Usage: getEnergyPlusObjectsFromFile(r"C:\ladybug\21MAR900\imageBasedSimulation\21MAR900.rad") """ if not os.path.isfile(epFilePath): raise ValueError("Can't find %s."%epFilePath) with open(epFilePath, "r") as epFile: return self.getEnergyPlusObjectsFromString("".join(epFile.readlines()))
def getRadianceObjectsFromFile(self, radFilePath): """ Parse Radinace file and return a list of radiance objects as separate strings TODO: Create a class for each Radiance object and return Python objects instead of strings Args: radFilePath: Path to Radiance file Returns: A list of strings. Each string represents a differnt Rdiance Object Usage: getRadianceObjectsFromFile(r"C:\ladybug\21MAR900\imageBasedSimulation\21MAR900.rad") """ if not os.path.isfile(radFilePath): raise ValueError("Can't find %s."%radFilePath) with open(radFilePath, "r") as radFile: return self.getRadianceObjectsFromString("".join(radFile.readlines()))
def __init__(self, itemlist): height = len(itemlist)*17 self.Text = "Select the categories to export" self.Size = Size(300, height + 80) self.check = CheckedListBox() self.check.Parent = self self.check.Location = Point(5, 5) self.check.Size = Size(270, height) # load the list of relevant categories found in the project list_items = List[Object](itemlist) self.check.Items.AddRange(list_items.ToArray()) self.check.CheckOnClick = True # set checked by default for i in range(len(itemlist)): self.check.SetItemChecked(i , True) okay = Button() okay.Parent = self okay.Text = 'OK' okay.Location = Point(50, height+10) okay.Width = 140 okay.Click += self.onValidate cancel = Button() cancel.Parent = self cancel.Text = 'Cancel' cancel.Location = Point(okay.Right, height+10) cancel.Click += self.onCancel self.CenterToScreen()
def __init__(self, param): super(PanelParameter, self ).__init__() self.Height = Fconfig.unitline self.paramtype = param[1] tooltips = ToolTip() self.value = '' self.textlabel = Label() self.textlabel.Parent = self self.textlabel.Text = '{0} ({1}) :'.format(param[0],param[1]) self.textlabel.Location = Point(0, 0) self.textlabel.Size = Size(Fconfig.lblwidth, Fconfig.unitline) self.textlabel.TextAlign = ContentAlignment.MiddleLeft #ComboBox if list if len(param) >= 3 : self.textbox = ComboBox() list_items = List[Object](param[2]) self.textbox.Items.AddRange(list_items.ToArray()) #dropdownstyle with 4th param if False: if len(param)>3 and not param[3]: self.textbox.DropDownStyle = ComboBoxStyle.DropDownList self.textbox.SelectionChangeCommitted += self.onInput #else simple textbox else: self.textbox = TextBox() self.textbox.Parent = self self.textbox.Location = Point(self.textlabel.Right+Fconfig.margin, 10) self.textbox.Width = Fconfig.smwidth-self.textlabel.Width- 2*Fconfig.margin self.textbox.TextChanged += self.onInput tooltips.SetToolTip(self.textbox, Types.types(param[1], 'tooltip')) ModeDBG.say('panel {0}, top {1}, height :{2}'.format( param[1], self.Top, self.Height))
def __getattr__(self,name): if name[0:2] != "EO" and name[0:2] != "VM": raise AttributeError, "%s instance has no attribute '%s'" %(type(self).__name__, name) else: obj = None wrapped = System.Collections.Generic.IDictionary[System.String, System.Object](self) ret = wrapped.TryGetValue(name, obj) if ret[0]: return ret[1] else: raise AttributeError, "%s instance's ExpandoObject has no attribute '%s'" % (type(self).__name__, name)
def __setattr__(self,name,value): if name[0:2] != "EO" and name[0:2] != "VM": super(DotNetExpandoObject,self).__setattr__(name,value) else: wrapped = System.Collections.Generic.IDictionary[System.String, System.Object](self) if wrapped.ContainsKey(name): wrapped.set_Item(name, value) else: wrapped.Add(name, value)
def __delattr__(self, name): if name[0:2] != "EO" and name[0:2] != "VM": del self.__dict__[name] else: wrapped = System.Collections.Generic.IDictionary[System.String, System.Object](self) if wrapped.Remove(name): return else: raise AttributeError, "%s instance's ExpandoObject has no attribute '%s'" % (type(self).__name__, name)
def __getattr__(self,name): obj = None wrapped = System.Collections.Generic.IDictionary[System.String, System.Object](self) ret = wrapped.TryGetValue(name, obj) if ret[0]: return ret[1] else: raise AttributeError, "%s has no attribute '%s'" % ("DotNetExpandoObject", name)
def __setattr__(self,name,obj): # DataContext's attribute wrapped = System.Collections.Generic.IDictionary[System.String, System.Object](self) if wrapped.ContainsKey(name): wrapped.set_Item(name, obj) else: wrapped.Add(name, obj)
def getRadianceObjectsFromString(radFileString): """ Parse rad file string and return a list of radiance objects as separate strings Args: radFileString: Radiance data as a single string. The string can be multiline Returns: A list of strings. Each string represents a differnt Rdiance Object """ rawRadObjects = re.findall(r'(\n|^)(\w*(\h*\w.*\n){1,})', radFileString + "\n",re.MULTILINE) return [("").join(radObject[:-1]) for radObject in rawRadObjects]