def RunCommand(is_interactive): gp = Rhino.Input.Custom.GetPoint() gp.SetCommandPrompt( "get a point as a locaiton and setting frame size, scale 1:" + str(config.DRAWINGSCALE)) sizeValues = "A5", "A4", "A3", "A2", "A1", "A0" sizeValue = config.FRAMESIZE sizeIndex = sizeValues.index(sizeValue) opList = gp.AddOptionList("FrameSize", sizeValues, sizeIndex) gp.DynamicDraw += GetPointDynamicDrawFunc while True: get_rc = gp.Get() if gp.CommandResult() != Rhino.Commands.Result.Success: return gp.CommandResult() if get_rc == Rhino.Input.GetResult.Point: point = gp.Point() if not rs.IsLayer("Dim"): util.initCaadLayer("Dim") oldLayer = rs.CurrentLayer("Dim") Dim.DrawFrameBySize(sizeValue, point, config.FRAMERIGHTMARGIN, config.FRAMELEFTMARGIN) rs.CurrentLayer(oldLayer) elif get_rc == Rhino.Input.GetResult.Option: if gp.OptionIndex() == opList: sizeIndex = gp.Option().CurrentListOptionIndex sizeValue = sizeValues[sizeIndex] config.FRAMESIZE = sizeValue continue break return Rhino.Commands.Result.Success
def RunCommand(is_interactive): if not rs.IsLayer("Dim"): util.initCaadLayer("Dim") oldLayer = rs.CurrentLayer("Dim") rs.Command("_DimAligned") rs.CurrentLayer(oldLayer)
def drawOpening(distance, length, block=0): if block == 1 and rs.IsBlock("window") == False: util.initWindowBlock() if block == 2 and rs.IsBlock("door") == False: util.initDoorBlock() if not rs.IsLayer("Axis"): util.initCaadLayer("Axis") twoLines = findTwoParallelLines() if not twoLines: return 0 pi, linei, linej = twoLines if not linej: return 0 pj = linej.CurveGeometry.Line.ClosestPoint(pi, False) oldLockMode = rs.LayerLocked("Axis", True) # side=0 start from startPoint , side=1 start from endPoint if rs.Distance(linei.CurveGeometry.Line.From, pi) <= rs.Distance( pi, linei.CurveGeometry.Line.To): side = 0 else: side = 1 # direct: # 0 | 1 # ------- # 2 | 3 vji = rs.VectorCreate(pj, pi) vi = linei.CurveGeometry.Line.Direction angle = rs.Angle((0, 0, 0), rs.VectorRotate(vji, -rs.Angle((0, 0, 0), vi)[0], (0, 0, 1))) if abs(angle[0] - 90) < sc.doc.ModelAbsoluteTolerance: line0 = linei line1 = linej if side == 0: direct = 2 else: direct = 3 elif abs(angle[0] + 90) < sc.doc.ModelAbsoluteTolerance: line0 = linej line1 = linei if side == 0: direct = 0 else: direct = 1 dl = DoubleLine(line0.CurveGeometry.Line, line1.CurveGeometry.Line) newLayer = rs.ObjectLayer(line0.Id) oldLayer = rs.CurrentLayer(newLayer) dl.drawOpening(distance, length, side, block, direct) rs.DeleteObject(line0.Id) rs.DeleteObject(line1.Id) rs.CurrentLayer(oldLayer) rs.LayerLocked("Axis", oldLockMode)
def line2wall(layer): go = Rhino.Input.Custom.GetOption() go.AcceptNothing(True) go.SetCommandPrompt("set wall width") # set up the options widthOption = Rhino.Input.Custom.OptionDouble( config.DOUBLELINEWIDTH, config.DOUBLELINEWIDTHLIMIT[0], config.DOUBLELINEWIDTHLIMIT[1]) go.AddOptionDouble("Width", widthOption) while True: get_rc = go.Get() if go.CommandResult() != Rhino.Commands.Result.Success: print go.CommandResult() break if get_rc == Rhino.Input.GetResult.Option: continue break if go.CommandResult() != Rhino.Commands.Result.Cancel: config.DOUBLELINEWIDTH = widthOption.CurrentValue if not rs.IsLayer("Axis"): util.initCaadLayer("Axis") if not rs.IsLayer(layer): util.initCaadLayer(layer) go = Rhino.Input.Custom.GetObject() go.SetCommandPrompt("Select lines") go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve go.GetMultiple(1, 0) if go.CommandResult() != Rhino.Commands.Result.Success: return go.CommandResult() oldLayer = rs.CurrentLayer(layer) for lineCurveId in go.Objects(): if rs.IsLine(lineCurveId): # make axis rs.ObjectLayer(lineCurveId, "Axis") # make wall point0 = rs.CurveStartPoint(lineCurveId) point1 = rs.CurveEndPoint(lineCurveId) doubleLine = DoubleLine.MakeDoubleLine(config.DOUBLELINEWIDTH, point0, point1) doubleLine.draw() rs.CurrentLayer(oldLayer)
def RunCommand(is_interactive): go = Rhino.Input.Custom.GetObject() go.SetCommandPrompt("Select a LinearDimension") go.GeometryFilter = Rhino.DocObjects.ObjectType.Annotation go.Get() if go.CommandResult() != Rhino.Commands.Result.Success: return go.CommandResult() object_id = go.Objects()[0].ObjectId if not rs.IsLayer("Dim"): util.initCaadLayer("Dim") oldLayer = rs.CurrentLayer("Dim") Dim.DimSplit(object_id) rs.CurrentLayer(oldLayer) sc.doc.Views.Redraw()
def wallJoin(layer): if not rs.IsLayer("Wall"): util.initCaadLayer("Wall") if not rs.IsLayer("Axis"): util.initCaadLayer("Axis") haveLayer = True items = (layer, "Off", "On") result = rs.GetBoolean("current layer option", items, True) if result: haveLayer = result[0] oldLockMode = rs.LayerLocked("Axis", True) while True: go = Rhino.Input.Custom.GetObject() go.SetCommandPrompt("Select 4 lines, each two parallel to anthor") go.GeometryFilter = Rhino.DocObjects.ObjectType.Curve go.GetMultiple(4, 4) if go.CommandResult() != Rhino.Commands.Result.Success: rs.LayerLocked("Axis", oldLockMode) return go.CommandResult() if go.ObjectCount != 4: return Rhino.Commands.Result.Failure crv = [] for obj in go.Objects(): crv.append(obj.Geometry().Line) rc, doubleLines = DoubleLine.GetIntersectedDoubleline(crv) if rc: doubleLine0 = doubleLines[0] doubleLine1 = doubleLines[1] if haveLayer: oldLayer = rs.CurrentLayer(layer) doubleLine0.drawIntersectionWithDoubleLine(doubleLine1) if haveLayer: rs.CurrentLayer(oldLayer) rs.DeleteObjects(go.Objects()) else: print "Error: no two doubleLines"
def RunCommand(is_interactive): go = Rhino.Input.Custom.GetOption() go.AcceptNothing(True) go.SetCommandPrompt("set options") # set up the options widthOption = Rhino.Input.Custom.OptionDouble( config.DOUBLELINEWIDTH, config.DOUBLELINEWIDTHLIMIT[0], config.DOUBLELINEWIDTHLIMIT[1]) wallOption = Rhino.Input.Custom.OptionToggle(True, "Off", "On") # offset side options sideValues = "middle", "right", "left" sideIndex = config.DOUBLELINEOFFSETSIDETYPE go.AddOptionList("Type", sideValues, sideIndex) go.AddOptionDouble("Width", widthOption) go.AddOptionToggle("Wall", wallOption) while True: get_rc = go.Get() if go.CommandResult() != Rhino.Commands.Result.Success: print go.CommandResult() break if get_rc == Rhino.Input.GetResult.Option: sideIndex = go.Option().CurrentListOptionIndex config.DOUBLELINEOFFSETSIDETYPE = sideIndex continue break if go.CommandResult() != Rhino.Commands.Result.Cancel: config.DOUBLELINEWIDTH = widthOption.CurrentValue isWall = wallOption.CurrentValue if not rs.IsLayer("Wall"): util.initCaadLayer("Wall") if isWall: DoubleLine.DrawDoubleLines("wall", sideIndex) else: DoubleLine.DrawDoubleLines(rs.CurrentLayer(), sideIndex) sc.doc.Views.Redraw()
def RunCommand(is_interactive): if not rs.IsLayer("Wall"): util.initCaadLayer("Wall") line2wall("wall") sc.doc.Views.Redraw()