def LoadPCPAMaterials(filepath): try: rs.EnableRedraw(False) rs.Command("-_Import " + '"' + filepath + '" Enter', echo=False) rs.EnableRedraw(True) result = True utils.SaveToAnalytics('standards-Load Materials') except: print "Failed to load PCPA Materials" result = False utils.SaveFunctionData('Standards-Load Materials', [result])
def main(): path = rs.GetObject("Select Ramp Path", rs.filter.curve, True) if path is None: return if 'ramp-widthDefault' in sc.sticky: widthDefault = sc.sticky['ramp-widthDefault'] else: widthDefault = 36 if 'ramp-slopeDefault' in sc.sticky: slopeDefault = sc.sticky['ramp-slopeDefault'] else: slopeDefault = 8.333 width = rs.GetReal("Ramp Clear Width", widthDefault, minimum=36) if width is None: return slope = rs.GetReal("Ramp slope (e.g. 8.33%(1:12) is 8.33)", slopeDefault) if slope is None: return sc.sticky['ramp-widthDefault'] = width sc.sticky['ramp-slopeDefault'] = slope rs.EnableRedraw(False) rampGeoList = Ramp_HeightSlope(path, width, slope / 100) try: layers.AddLayerByNumber(402, False) layerName = layers.GetLayerNameByNumber(402) rs.ObjectLayer(rampGeoList[0], layerName) try: if rampGeoList[2] is not None: layers.AddLayerByNumber(106, False) layerName = layers.GetLayerNameByNumber(106) rs.ObjectLayer(rampGeoList[2], layerName) except: pass result = True except: result = False utils.SaveFunctionData('Architecture-ramp', [ width, slope, str([(pt.X, pt.Y, pt.Z) for pt in rs.CurveEditPoints(path)]), result ]) rs.EnableRedraw(True) print rampGeoList[1] utils.SaveToAnalytics('architecture-ramp')
def CutModel_Button(): objs = rs.GetObjects("Select objects to cut", preselect=True) if objs is None: return srf = rs.GetObject("Select cutting surface", rs.filter.surface) if srf is None: return if rs.IsSurfacePlanar(srf) == False: print "Cutting surface must be planar" return None rs.EnableRedraw(False) result = CutModel(objs, srf) if result: utils.SaveToAnalytics('Drawing-cut Model') utils.SaveFunctionData('Drawing-Cut Model', [__version__, len(objs), result]) rs.EnableRedraw(True)
def Rectify_AngleFirst_Button(): objs = rs.GetObjects("Select polylines to rectify", rs.filter.curve, preselect = True) if objs is None: return if 'geometry-angleMultiple' in sc.sticky: angleDefault = sc.sticky['geometry-angleMultiple'] else: angleDefault = 45 if 'geometry-lengthMultiple' in sc.sticky: lengthDefault = sc.sticky['geometry-lengthMultiple'] else: lengthDefault = 1 angleMultiple = rs.GetReal("Round angle to multiples of", angleDefault) if angleMultiple is None: return sc.sticky['geometry-angleMultiple'] = angleMultiple lengthMultiple = rs.GetReal("Round length to multiples of", lengthDefault) if lengthMultiple is None: return sc.sticky['geometry-lengthMultiple'] = lengthMultiple for obj in objs: try: rs.SimplifyCurve(obj) newLine = Rectify_AngleFirst(obj, angleMultiple, lengthMultiple) rs.MatchObjectAttributes(newLine, obj) utils.SaveToAnalytics('Geometry-Rectify') result = True except: result = False print "Rectify failed" utils.SaveFunctionData('Geometry-Rectify', [angleMultiple, lengthMultiple, str([(pt.X, pt.Y, pt.Z) for pt in rs.CurveEditPoints(obj)]), result]) if result: rs.DeleteObject(obj)
[__version__, designOptionName]) return True except: print "Failed to create design option" utils.SaveFunctionData('Blocks-Create Design Option', [__version__, '', 'Failed']) return None if __name__ == "__main__" and utils.IsAuthorized(): func = rs.GetInteger("", 0, 0, 100) if func == 0: result = Iterate() if result: utils.SaveToAnalytics('blocks-iterate') elif func == 1: result = MakeBlockUniqueButton() if result: utils.SaveToAnalytics('blocks-Make Unique') elif func == 2: result = SuperExplodeBlock() if result is not None: utils.SaveToAnalytics('blocks-Super Explode') elif func == 3: result = RenameBlockButton() if result is not None: utils.SaveToAnalytics('blocks-Rename Block') elif func == 4: result = ResetBlockScale() if result:
def GetAllLayerNames(): allLayerNames = [] layerNums = [] setupVariables() global csvPath layerData = GetLayerData(csvPath) for i in range(0, 10000, 1000): layerNumsSet = GetChildNumbers(i, layerData) layerNumsSet.sort() layerNums = layerNums + layerNumsSet for each in layerNums: allLayerNames.append(GetLayerNameByNumber(each)) return allLayerNames if __name__ == "__main__" and utils.IsAuthorized(): setupVariables() layerNumRequested = rs.GetInteger( "Enter layer number to add to the document", number=10000, minimum=0, maximum=10000) AddLayerByNumber(layerNumRequested) utils.SaveToAnalytics('layers-' + str(layerNumRequested)) #print GetLayerNameByNumber(layerNumRequested)
if __name__ == "__main__" and utils.IsAuthorized(): PreloadCheck() standardsRequested = rs.GetInteger("Standards to import", number=0, minimum=0, maximum=10000) fileLocations = config.GetDict() if standardsRequested == 0: LoadPCPAMaterials(fileLocations['Material File']) elif standardsRequested == 1: SetTemplateFolder(fileLocations['Template Folder']) SetTemplateFile(fileLocations['Template File']) utils.SaveToAnalytics('standards-Set Template') elif standardsRequested == 2: LoadPCPAComponents(fileLocations['PCPA GH Components']) LoadGHDependencies(fileLocations) utils.SaveToAnalytics('standards-Load GH Components') elif standardsRequested == 3: LoadAcadSchemes(fileLocations['ACAD Scheme Folder']) utils.SaveToAnalytics('standards-Load ACADSchemes') elif standardsRequested == 4: LoadStyles(fileLocations['Template File']) utils.SaveToAnalytics('standards-Load Styles') elif standardsRequested == 5: LoadDisplayModes(fileLocations['Display Mode Folder']) utils.SaveToAnalytics('standards-Load Display Modes') elif standardsRequested == 6: LoadPSSwatch(fileLocations['PS Swatch File'],
#return to original view rs.RestoreNamedView("temp") rs.DeleteNamedView("temp") result = True except: result = False utils.SaveFunctionData('IO-BatchCapture', [__version__] + chosenViews) return result if __name__ == "__main__" and utils.IsAuthorized(): func = rs.GetInteger("Function to run", number = 0) if func == 0: result = importCAD_Button() if result: utils.SaveToAnalytics('IO-Import CAD') elif func == 1: result = exportToRenderDWG() if result: utils.SaveToAnalytics('IO-Export To Render DWG') elif func == 2: result = exportToRenderSKP() if result: utils.SaveToAnalytics('IO-Export To Render SKP') elif func == 3: result = CaptureDisplayModesToFile() if result: utils.SaveToAnalytics('IO-Capture Display Modes') elif func == 4: result = SafeCaptureButton() if result: utils.SaveToAnalytics('IO-Safe Capture') elif func == 5: result = BatchCapture() if result: utils.SaveToAnalytics('IO-Batch Capture')
import rhinoscriptsyntax as rs import utils import subprocess import config __author__ = 'Tim Williams' __version__ = "2.1.0" def launchHelp(): try: fileLocations = config.GetDict() path = fileLocations['Help File'] subprocess.Popen([path],shell=True) return True except: return False if __name__ == "__main__" and utils.IsAuthorized(): if launchHelp(): utils.SaveToAnalytics('Help')
except: pass rs.EnableRedraw(False) for obj in objects: if rs.IsCurve(obj): try: group, rc = dimensionPline(obj, offsetDist) utils.SaveFunctionData('Drawing-Dim Pline', [rs.DocumentPath(), rs.DocumentName(), rs.ObjectLayer(obj), rs.CurrentDimStyle(), offsetDist, rc]) except: print "Unknown Error" else: print "Not a polyline" rs.EnableRedraw(True) if __name__=="__main__" and utils.IsAuthorized(): func = rs.GetInteger("Func num") if func == 0: AddAreaTag() utils.SaveToAnalytics('Drawing-Add Area Tag') elif func == 1: dimensionPline_Button() utils.SaveToAnalytics('Drawing-Dim Pline') elif func == 2: AddCoordinateTag_Button() utils.SaveToAnalytics('Drawing-Add Coordinate Tag') elif func == 3: UpdateAreaTag() utils.SaveToAnalytics('Drawing-Update Area Tag')
True, True) if objs is None: return successList = [] for obj in objs: unfilletResult = unfilletObj(obj) if unfilletResult is None: successList.append(False) else: successList.append(True) result = True except: result = False utils.SaveFunctionData( 'Geometry-Unfillet', [__version__, len(objs), str(successList), result]) return result if __name__ == "__main__" and utils.IsAuthorized(): func = rs.GetInteger("func num") if func == 0: result = IntersectGeoAtPt() if result: utils.SaveToAnalytics('Geometry-Contour At Pt') if func == 1: result = Unfillet_Button() if result: utils.SaveToAnalytics('Geometry-Unfillet')
def RandomUnselect(): try: ids = rs.GetObjects("Select objects to unselect", preselect=True) if not ids: return if len(ids) == 1: return rs.SelectObjects(ids) if sc.sticky.has_key("RandomUnselect_percent"): percent_default = sc.sticky["RandomUnselect_percent"] else: percent_default = 50 percent = rs.GetInteger("Percent to deselect", percent_default, 1, 99) if not percent: return objs = random.sample(ids, int(percent * len(ids) / 100)) rs.UnselectObjects(objs) sc.sticky["RandomUnselect_percent"] = percent return True except: return False if __name__ == "__main__": result = RandomUnselect() if result: utils.SaveToAnalytics('legacy_random unselect')
def main(): if (rs.UnitSystem() == 2): widthDefault = 1800 widthMin = 900 widthMax = 100000 heightDefault = 5000 heightMin = 300 elif (rs.UnitSystem() == 4): widthDefault = 1.8 widthMin = .9 widthMax = 100.0 heightDefault = 5.0 heightMin = .30 elif (rs.UnitSystem() == 8): widthDefault = 42 widthMin = 36 widthMax = 1000.0 heightDefault = 120 heightMin = 12 else: print "Change your units to inches" return route = rs.GetObject("Select Stair Guide Curve", rs.filter.curve, True) if route is None: return if 'stair-widthDefault' in sc.sticky: widthDefault = sc.sticky['stair-widthDefault'] if 'stair-heightDefault' in sc.sticky: heightDefault = sc.sticky['stair-heightDefault'] width = rs.GetReal("Stair Width", number=widthDefault, minimum=widthMin, maximum=widthMax) if width is None: return height = rs.GetReal("Stair Height", number=heightDefault, minimum=heightMin) if height is None: return sc.sticky['stair-widthDefault'] = width sc.sticky['stair-heightDefault'] = height try: stairGeo = stairHeight(route, width, height) result = True except: result = False try: layers.AddLayerByNumber(401, False) layerName = layers.GetLayerNameByNumber(401) rs.ObjectLayer(stairGeo, layerName) except: pass utils.SaveFunctionData('Architecture-Stair', [ width, height, str([(pt.X, pt.Y, pt.Z) for pt in rs.CurveEditPoints(route)]), result ]) utils.SaveToAnalytics('Architecture-Stair')
layerName = '2_ENTOURAGE' rs.ObjectLayer(eachBlock, layerName) xyScale = random.uniform(1 - scaleVariation, 1 + scaleVariation) zScale = random.uniform(1 - scaleVariation, 1 + scaleVariation) rs.ScaleObject(eachBlock, pt, (xyScale, xyScale, zScale)) except: pass rs.EnableRedraw(True) # result = True #except: # result = False #utils.SaveFunctionData('Blocks-Populate', [__version__, numObjects, type, result]) if __name__ == "__main__" and utils.IsAuthorized(): func = rs.GetInteger("func num") if func == 0: fileLocations = config.GetDict() result = Populate_Surfaces() if result: utils.SaveToAnalytics('Blocks-Populate') elif func == 1: fileLocations = config.GetDict() result = PopulatePath() if result: utils.SaveToAnalytics('Blocks-Populate Path')
index = sc.doc.Materials.Add() mat = sc.doc.Materials[index] mat.DiffuseColor = color mat.Name = str(color) mat.CommitChanges() rs.ObjectMaterialIndex(obj, index) rs.ObjectMaterialSource(obj, 1) return True except: return False if __name__ == "__main__" and utils.IsAuthorized(): func = rs.GetInteger("Input func number") if func == 0: result = ColorObjsWithGradient2Pt() if result: utils.SaveToAnalytics('colors-Gradient') elif func == 1: result = ColorObjsRandomRange() if result: utils.SaveToAnalytics('colors-Random Range') elif func == 2: result = ObjectColorToMaterial() if result: utils.SaveToAnalytics('colors-Color To Material') elif func == 3: result = ColorBySize() if result: utils.SaveToAnalytics('colors-By Size')