def test_face(chara, face): import Manager.ADV from System import Enum from Manager.ADV import FacialExpressionPattern as Face if not isinstance(face, Face): face = Enum.Parse(Face, face, True) Manager.ADV.Instance.SetFacialExpression(chara, face)
def callable(*args): from Microsoft.Scripting import SourceSpan, TokenCategory, TokenInfo, TokenTriggers TokenTriggersNone = getattr(TokenTriggers, "None") TokenCategoryNone = getattr(TokenCategory, "None") from System import Enum triggers = args[2] if len(args)>2 else TokenTriggersNone return TokenInfo(SourceSpan(args[0], args[1]), Enum.Parse(TokenCategoryNone.GetType(), name), triggers)
def intercepted_key(self, e): log.info('intercepted key event') # FIXME: Split key intercept handling out of this program # FIXME: abstract key processing to a helper module; replace key # processing here and in preview key down # should always be a modifier modifier, keyname = e.Key.split('-', 1) # http://www.codeproject.com/Articles/6768/Tips-about-NET-Enums key = Enum.Parse(Keys, keyname) if key in keys: key = keys[key] key = str(key) if key in set(string.uppercase): key = key.lower() key = '-'.join((modifier, key)) log.info('intercepted key: ' + key) zmq.send_command(key)
viewTemplates.append(v) fs = v.GetFilters() #filters = IN[0] #view = IN[1] #filters = view.GetFilters() bips = Enum.GetValues(clr.GetClrType(BuiltInParameter)) #bips = Enum.GetNames( clr.GetClrType( BuiltInParameter ) ) bipIDs = [] for bip in bips: bipIDs.append(int(bip)) bipIDs.append(Enum.Parse(clr.GetClrType(BuiltInParameter), str(bip))) rules = [] filterRules = [] filterSheetHeadings = [("View Template ID"), ("View Template Name"), ("Filter ID"), ("Filter Name"), ("Categories"), ("Visibility"), ("Halftone"), ("Line Weight"), ("Line Colour"), ("Fill Colour"), ("Fill Pattern"), ("Transparency"), ("Filter Rules")] filterRules.append(filterSheetHeadings) filterHeadingRow = [] filterHeadingRow.append(filterSheetHeadings) filterDetails = []
# -*- coding: utf-8 -*- """ Created on Mon Sep 11 12:54:57 2017 @author: Steven """ # Python .NET interface from dotnet.seamless import add_assemblies, load_assembly#, build_assembly # load PLEXOS assemblies plexos_path = 'C:/Program Files (x86)/Energy Exemplar/PLEXOS 7.5/' add_assemblies(plexos_path) load_assembly('EEUTILITY') # .NET related imports from EEUTILITY.Enums import * from System import Enum fout = open('EEUTILITY_Enums.txt', 'w') for t in type(ClassEnum).Assembly.GetTypes(): if t.IsEnum: fout.write('{}\n'.format(t.Name)) for en in t.GetEnumNames(): fout.write('\t{} = {}\n'.format(en, int(Enum.Parse(t, en)))) fout.write('\n') fout.close()
def pull_data(sol_cxn, time_res, args, arg_opt, default_csv): from EEUTILITY.Enums import SimulationPhaseEnum, CollectionEnum, PeriodEnum, ClassEnum # is this time_res active? If not quit if not is_switch(args, arg_opt): return # date_from and date_to date_from = switch_data_to_date(args, '-f') date_to = switch_data_to_date(args, '-t') start_time = time.time() # start timer # get the csv_file name csv_file = switch_data(args, arg_opt) if csv_file is None: csv_file = re.sub('\.zip$', '', args[1]) + default_csv # remove the csv_file if it already exists if os.path.exists(csv_file): os.remove(csv_file) # loop through all relevant collections and phases config_json = switch_data(args, '-c') if not config_json is None and os.path.exists(config_json): cfg_json_obj = json.load(open(config_json)) for query in cfg_json_obj['queries']: try: phase = Enum.Parse(SimulationPhaseEnum, query['phase']) coll = sol_cxn.CollectionName2Id(query['parentclass'], query['childclass'], query['collection']) except: print("Phase:", query['phase'], "Collection:", query['collection'], "Parent Class:", query['parentclass'], "Child Class:", query['childclass']) print(" --> This combination doesn't identify queryable information") continue # If the phase or collection are missing or incorrect just skip if 'properties' in query: # the data in properties field may be a list of property names; we'll pull each individually if type(query['properties']) is list: for prop in query['properties']: try: prop_id = str(sol_cxn.PropertyName2EnumId(query['parentclass'], query['childclass'], query['collection'], prop)) query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v'), property_list=prop_id) except: pass # the data in properties field may be a single property name; we'll just pull it elif type(query['properties']) is str: try: prop_id = str(sol_cxn.PropertyName2EnumId(query['parentclass'], query['childclass'], query['collection'], query['properties'])) query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v'), property_list=prop_id) except: pass # the data in properties field may be poorly formatted else: print(query['properties'],'is not valid property information') # properties field may be missing; just pull all properties else: query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v')) else: for phase in Enum.GetValues(clr.GetClrType(SimulationPhaseEnum)): for coll in Enum.GetValues(clr.GetClrType(CollectionEnum)): query_data_to_csv(sol_cxn, csv_file, phase, coll, time_res, date_from, date_to, is_verbose=is_switch(args, '-v')) print('Completed',clr.GetClrType(PeriodEnum).GetEnumName(time_res),'in',time.time() - start_time,'sec')
class ConsoleColorMgr(object): def __init__(self, foreground=None, background=None): self.foreground = foreground self.background = background def __enter__(self): self._tempFG = _Console.ForegroundColor self._tempBG = _Console.BackgroundColor if self.foreground: _Console.ForegroundColor = self.foreground if self.background: _Console.BackgroundColor = self.background def __exit__(self, t, v, tr): _Console.ForegroundColor = self._tempFG _Console.BackgroundColor = self._tempBG import sys _curmodule = sys.modules[__name__] from System import ConsoleColor, Enum for n in Enum.GetNames(ConsoleColor): setattr(_curmodule, n, ConsoleColorMgr(Enum.Parse(ConsoleColor, n))) del ConsoleColor del Enum del sys del _curmodule del n
roi.Name = ofRoi.Name if ofRoi.DerivedRoiExpression is not None: roi.IsDerived = True roi.DependentRois = r.GetDependentRois() else: roi.IsDerived = False roi.DependentRois = List[str]() roi.HasGeometry = r.HasContours() roi.CanDeleteGeometry = False roi.CanUnderive = False roi.CanUpdate = False roi.CanDeleteGeometry = False roi.CaseName = case.CaseName roi.ExaminationName = examinations.SelectedExamination roi.RoiType = Enum.Parse(clr.GetClrType(RoiType), ofRoi.Type) roi.Color = Media.Color.FromRgb(ofRoi.Color.R, ofRoi.Color.G, ofRoi.Color.B) rois.Add(roi) from RoiManager.ViewModels import RoiSelectionViewModel roiSelectionViewModel = RoiSelectionViewModel(rois, roiNameMappingTable) from RoiManager.Views import MainWindow mainWindow = MainWindow(roiSelectionViewModel) mainWindow.ShowDialog() print "RoiSelection CanExecute: ", roiSelectionViewModel.CanExecute if not roiSelectionViewModel.CanExecute:
def MF_GetFilterRules(f): types = [] pfRuleList = [] categories = '' for c in f.GetCategories(): categories += Category.GetCategory(doc, c).Name + " , " for rule in f.GetRules(): try: comparator = "" ruleValue = "" ruleInfo = "" if rule.GetType() == FilterDoubleRule: ruleValue = "filterdoublerule" fdr = rule if (fdr.GetEvaluator().GetType() == FilterNumericLess): comparator = "<" elif (fdr.GetEvaluator().GetType() == FilterNumericGreater): comparator = ">" ruleValue = fdr.RuleValue.ToString() ruleName = ruleValue if rule.GetType() == FilterStringRule: ruleValue = "filterstringrule" fsr = rule if (fsr.GetEvaluator().GetType() == FilterStringBeginsWith): comparator = "starts with" elif (fsr.GetEvaluator().GetType() == FilterStringEndsWith): comparator = "ends with" elif (fsr.GetEvaluator().GetType() == FilterStringEquals): comparator = "equals" elif (fsr.GetEvaluator().GetType() == FilterStringContains): comparator = "contains" ruleValue = fsr.RuleString ruleName = ruleValue if rule.GetType() == FilterInverseRule: # handle 'string does not contain ' fInvr = rule.GetInnerRule() if (fsr.GetEvaluator().GetType() == FilterStringBeginsWith): comparator = "does not start with" elif (fsr.GetEvaluator().GetType() == FilterStringEndsWith): comparator = "does not end with" elif (fsr.GetEvaluator().GetType() == FilterStringEquals): comparator = "does not equal" elif (fsr.GetEvaluator().GetType() == FilterStringContains): comparator = "does not contain" ruleValue = fInvr.RuleString ruleName = ruleValue if rule.GetType() == FilterIntegerRule: #comparator = "equals" ruleValue = "filterintegerrule" fir = rule if (fir.GetEvaluator().GetType() == FilterNumericEquals): comparator = "=" elif (fir.GetEvaluator().GetType() == FilterNumericGreater): comparator = ">" elif (fir.GetEvaluator().GetType() == FilterNumericLess): comparator = "<" ruleValue = fir.RuleValue if rule.GetType() == FilterElementIdRule: comparator = "equals" feidr = rule ruleValue = doc.GetElement(feidr.RuleValue) ruleName = ruleValue.Abbreviation t = ruleValue.GetType() #ruleName = doc.GetElement(ruleValue.Id).Name types.append(t) paramName = "" bipName = " - " if (ParameterFilterElement.GetRuleParameter(rule).IntegerValue < 0): bpid = f.GetRuleParameter(rule).IntegerValue #bp = System.Enum.Parse(clr.GetClrType(ParameterType), str(bpid) ) #paramName = LabelUtils.GetLabelFor.Overloads[BuiltInParameter](bpid) #paramName = doc.get_Parameter(ElementId(bpid)).ToString() paramName = Enum.Parse(clr.GetClrType(BuiltInParameter), str(bpid)) param = Enum.Parse(clr.GetClrType(BuiltInParameter), str(bpid)) bipName = param.ToString() #YESSS paramName = LabelUtils.GetLabelFor.Overloads[BuiltInParameter]( param) else: paramName = doc.GetElement( ParameterFilterElement.GetRuleParameter(rule)).Name #paramName = doc.GetElement(ParameterFilterElement.GetRuleParameter(rule)).Name #ruleData += "'" + paramName + "' " + comparator + " " + "'" + ruleValue.ToString() + "'" + Environment.NewLine; #ruleInfo += "'" + str(paramName) + "' " + comparator + " " + "'" + ruleValue.ToString() + "---" try: ruleInfo += "" + str( paramName ) + " - " + bipName + " - " + comparator + " - " + ruleValue.ToString( ) + " - " + ruleName + " - " + rule.GetType().ToString( ) + " --- " pfRuleList += [(str(paramName)), (bipName), (comparator), (ruleValue.ToString()), (ruleName), (rule.GetType().ToString()), (" --- ")] except: ruleInfo += "" + str( paramName ) + " - " + bipName + " - " + comparator + " - " + ruleValue.ToString( ) + " - " + ruleName.ToString() + " - " + rule.GetType( ).ToString() + " --- " pfRuleList += [(str(paramName)), (bipName), (comparator), (ruleValue.ToString()), (ruleName.ToString()), (rule.GetType().ToString()), (" --- ")] #ruleList.append([str(paramName), comparator, ruleName]) #ruleInfo = ( (str(paramName) , comparator , ruleValue.ToString() ) ) #filterRuleList.append(pfRuleList) #ruleValues.append(ruleValue) except Exception as e: print str(e) #sublist.extend(pfRuleList) return [categories, pfRuleList]