def RunCommand(is_interactive): config = get_sisufile() if not config: print('Sisufile not configured') return Rhino.Commands.Result.Failure items = config['data'] out = [] failed_objects = [] result = {} for item in items: if not 'code' in item: print('failed to process item: code not found') continue # calc existing layer only layer_name = item['layer'][0] if not rs.IsLayer(layer_name): continue c = item.get('code') units = c.get('units') if not units: print('failed to process dc item: units not specified') if units == UNIT_PIECE: upd, failed = calc_piece(c) failed_objects = failed_objects + failed result.update(upd) if units == UNIT_M2: upd, failed = calc_m2(c) failed_objects = failed_objects + failed result.update(upd) if units == UNIT_M: upd, failed = calc_m(c) failed_objects = failed_objects + failed result.update(upd) if len(failed_objects) > 0: print('failed to calc') rs.SelectObjects([x.Id for x in failed_objects]) else: now = datetime.date.today() prefix = now.strftime('%Y%m%d') doc = rs.DocumentPath() filename = '%s-SISU_CALC.csv' % prefix filepath = os.path.join(doc, filename) print('saving to file... %s' % filepath) save_sisu_calc_report(result, filepath) # try: # conf = get_layer_config(code) # conf.update(item) # out.append(conf) # except Exception as e: # print('DC failed. Fill defaults', code, e) ## conf.update(default_config) return Rhino.Commands.Result.Success
def RunCommand(is_interactive): config = get_sisufile() if not config: print('Sisufile not configured') return Rhino.Commands.Result.Failure layers = get_related_layers(config, derived_only=True) for layer in layers: rs.LayerVisible(layer, visible=True) return Rhino.Commands.Result.Success
def RunCommand(is_interactive): config = get_sisufile() if not config: print('Sisufile not configured') return Rhino.Commands.Result.Failure layers = get_related_layers(config, derived_only=True) for layer in layers: rs.LayerVisible(layer, visible=False) parent = rs.ParentLayer(layer) rs.ExpandLayer(parent, False) # collapse parend layer return Rhino.Commands.Result.Success
def RunCommand(is_interactive): config = get_sisufile() if not config: print('Sisufile not configured') return Rhino.Commands.Result.Failure layers = get_related_layers(config, derived_only=True) for layer in layers: if rs.IsLayerCurrent(layer): parent = rs.ParentLayer(layer) rs.CurrentLayer(parent) rs.PurgeLayer(layer) return Rhino.Commands.Result.Success
def RunCommand(is_interactive): config = get_sisufile() if not config: print('Sisufile not configured') return Rhino.Commands.Result.Failure codes = config['data'] out = [] for code in codes: conf = {} layer_name, layer_options = code['layer'] if not rs.IsLayer(layer_name): continue try: layer_conf = get_layer_config(layer_name, layer_options) conf.update(layer_conf) except Exception as e: print('Failed to dump layer %s' % layer_name) print(e) for view in code['view']: view_layer_name = layer_name + view['layerSuffix'] render_type, render_options = view['render'] if is_solid_view(view): solid_conf = get_solid_view_config(view_layer_name, render_options) conf.update(solid_conf) else: pattern_conf = get_pattern_view_config(view_layer_name, render_options) conf.update(pattern_conf) if conf: conf['code'] = layer_name out.append(conf) # builder = ConfigBuilder() # new_data = builder.build(out) # sisu_path = get_sisufile_path() # sisufile_update_data(sisu_path, new_data) path = get_sisufile_path() airtable_push(path, out) return Rhino.Commands.Result.Success
def RunCommand(is_interactive): load_system_hatch_patterns() config = get_sisufile() if not config: print('Sisufile not configured') return Rhino.Commands.Result.Failure codes = config['data'] mode_full = 'Full' mode_existing = 'Existing' mode_current = 'Current' modes = (mode_existing, mode_current, mode_full) user_options, status = get_sync_options(modes) if status != Rhino.Commands.Result.Success: return status add_layer_enabled = user_options['mode'] == mode_full layer_scope = [] if user_options['mode'] == mode_current: layer_scope = [rs.CurrentLayer()] else: layer_scope = rs.LayerNames() options = {} rs.EnableRedraw(False) for code in codes: layer_name, layer_options = code['layer'] layer_exists = rs.IsLayer(layer_name) valid_layer = (layer_name in layer_scope) or (not layer_exists and add_layer_enabled) if not valid_layer: continue try: sync_code(code, options) except Exception as e: print('failed to sync %s: %s' % (code['code'], e)) rs.EnableRedraw(True) sc.doc.Views.Redraw() return Rhino.Commands.Result.Success
) as csvfile: hatches_reader = csv.reader(csvfile, delimiter=',') for list_of_hatch_paths in hatches_reader: for hatch_path in list_of_hatch_paths: # print(hatch_path) hatches_paths_all_mac.append(hatch_path) # import all hatches ''' for path in hatches_paths_all_mac: filename = path if filename: patterns = rs.AddHatchPatterns(filename) if patterns: for pattern in patterns: print pattern ''' # import hatches needed custom_hatches_needed = [] config = get_sisufile() for code in config['data']: custom_hatches_needed.append(code['view'][1]['render'][1]['pattern']) for hatch_needed in custom_hatches_needed: for path in hatches_paths_all_mac: filename = path if filename and hatch_needed in filename: patterns = rs.AddHatchPatterns(filename) if patterns: for pattern in patterns: print pattern