def main(): # get script location rs.AddAlias("MoveToWorldXY", "E:/rhinoscript/moveToXy.py")
import rhinoscriptsyntax as rs import Rhino import math import re import time import scriptcontext import checkAndExport as ce # SCRIPT GLOBALS EXPORT_FONT = 'timfont' MAT_THICKNESS = 18 #add to rhino as an alias if not rs.IsAlias("TNM_make3d"): rs.AddAlias("TNM_make3d", "'_-runPythonScript \"%s\"" % __file__ ) print 'addAlias' else: print 'alias could not be added' # recursive explode of blocks def iterateBlocks(objects): def explode(objs, li): for obj in objs: if rs.IsBlockInstance(obj): # DIRTY FIX FOR RHINO 5-SR14 522.8390 (5-22-2017) # temp_objs = rs.ExplodeBlockInstance(obj) rs.UnselectAllObjects()
# with a textbox that can be used to define the text in a new text dot from System.Windows.Forms import Form, DialogResult, Label, Button, TextBox, CheckBox, ComboBox, NumericUpDown from System.Drawing import Point, Size import rhinoscript.selection import rhinoscript.geometry import rhinoscriptsyntax as rs import os from subprocess import check_output #add to rhino as an alias if not rs.IsAlias("TNM_addLayer"): rs.AddAlias("TNM_addLayer", "'_-runPythonScript \"%s\"" % __file__) print 'addAlias' else: print 'alias could not be added' # Our custom form class class AnnotateForm(Form): # build all of the controls in the constructor def __init__(self, tools): label_width = 30 offset = 30 index = 0 # header self.Text = "Add layer" width = 400
def ApplyPCPAAliases(scriptFolder): try: ############################################################################ #ARCHITECTURE #STAIR str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\stair.py) ' rs.AddAlias('pcpStair', str) #RAMP str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\ramp.py) ' rs.AddAlias('pcpRamp', str) ############################################################################ #BLOCKS #ITERATE DESIGN OPTION str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\blocks.py) 0 ' rs.AddAlias('pcpIterDesignOpt', str) #MAKE BLOCK UNIQUE str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\blocks.py) 1 ' rs.AddAlias('pcpMakeUnique', str) #SUPER EXPLODE str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\blocks.py) 2 ' rs.AddAlias('pcpSuperExplode', str) #POPULATE str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\populate.py) ' rs.AddAlias('pcpPopulate', str) #RESET BLOCK SCALE str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\blocks.py) 4 ' rs.AddAlias('pcpResetBlockScale', str) #EXPORT AND LINK str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\blocks.py) 5 ' rs.AddAlias('pcpExportAndLink', str) ############################################################################ #DRAWINGS #AREA TAG str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\drawing.py) 0 ' rs.AddAlias('pcpAreaTag', str) #DIM PLINE str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\drawing.py) 1 ' rs.AddAlias('pcpDimPline', str) #ADD LAYOUT str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\layout.py) 0 ' rs.AddAlias('pcpLayout', str) #CUT MODEL str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\cut_model.py) ' rs.AddAlias('pcpCutModel', str) ############################################################################ #GEOMETRY #CONTOUR AT POINT str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\geometry.py) 0 ) ' rs.AddAlias('pcpContourPt', str) #UNFILLET str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\geometry.py) 1 ' rs.AddAlias('pcpUnfillet', str) #RECTIFY str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\rectify.py) ' rs.AddAlias('pcpRectify', str) ############################################################################ #COLOR #COLOR RANDOM RANGE str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\colors.py) 1 ' rs.AddAlias('pcpColorRandRange', str) #COLOR GRADIENT str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\colors.py) 0 ' rs.AddAlias('pcpColorGradient', str) #COLOR BY SIZE str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\colors.py) 3 ' rs.AddAlias('pcpColorBySize', str) #COLOR TO MATERIAL str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\colors.py) 2 ' rs.AddAlias('pcpColorToMaterial', str) ############################################################################ #I/O #CAPTURE DISPLAY MODES str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\file_IO.py) 3 ' rs.AddAlias('pcpCaptureDisplayModes', str) #EXPORT TO RENDER DWG str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\file_IO.py) 1 ' rs.AddAlias('pcpExportToRenderDWG', str) #EXPORT TO RENDER SKP str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\file_IO.py) 2 ' rs.AddAlias('pcpExportToRenderSKP', str) #IMPORT CAD str = r'_NoEcho -_RunPythonScript (' + scriptFolder + '\\file_IO.py) 0 ' rs.AddAlias('pcpImportCAD', str) print "\tLoaded PCPA Aliases" result = True except: print "Failed to load PCPA Aliases" result = False utils.SaveFunctionData('Standards-Load PCPA Aliases', [__version__, result]) return result
def importCaadAlias(): #wall rs.AddAlias("WW", "! wall _Enter") rs.AddAlias("DL", "! wall a _Enter") rs.AddAlias("L2W", "! line2wall w _Enter") rs.AddAlias("WJ", "! wall_join _Enter") rs.AddAlias("DJ", "! wall_join w _Enter") #opening rs.AddAlias("OP", "! opening") rs.AddAlias("WIN", "! opening t w") rs.AddAlias("DOOR", "! opening t d") #dim rs.AddAlias("DIMJ", "! dimjoin") rs.AddAlias("DIMS", "! dimsplit") rs.AddAlias("DIML", "! dimlayer") rs.AddAlias("FR", "! frame")
"""300 Days of Code Sketches 201-300 by Tim Williams """ import Rhino as rc import Rhino.Geometry as rg import rhinoscriptsyntax as rs import scriptcontext as sc import math import random import os import System.Drawing as drawing import time import datetime rs.AddAlias() #import lib.color as color
import rhinoscriptsyntax as rs import Rhino import scriptcontext as sc import math import re import time import os #add to rhino as an alias if not rs.IsAlias("TNM_renameLayers"): rs.AddAlias("TNM_renameLayers", "'_-runPythonScript \"%s\"" % __file__) print 'addAlias' else: print 'alias could not be added' layers = rs.LayerIds() for layer_id in layers: if rs.IsLayer(layer_id): old_name = rs.LayerName(layer_id, False) if (re.search('0.0.0', old_name)): new_name = old_name.replace('0.0.0', '0.0.160.0') rs.RenameLayer(old_name, new_name) else: print layer_id
# for a in dir(rs): # if "Layer" in a: # print a # SCRIPT GLOBALS EXPORT_FONT = 'timfont' DEBUG_CLAMEX = True DEBUG_FLIPCUVRVE = False # filename = __file__.replace("\\","//") print os.path #add to rhino as an alias if not rs.IsAlias("TNM_Export"): rs.AddAlias("TNM_Export", "'_-runPythonScript \"%s\"" % __file__) print 'addAlias' else: print 'alias could not be added' # print 'addalias', rs.AddAlias("checkAndExport", "'_-runPythonScript \\"%s\\"" % ) def redraw(): rs.EnableRedraw(True) rs.EnableRedraw(False) # function to reverse a curve if the normal points downwards in Z-dir # assumed is that only closed curves can have inside or outside def setCurveDir(objs):