示例#1
0
def ShowRL():
    try:

        def scale():
            system = rs.UnitSystem()
            if system == 2 or system == 3 or system == 4:
                scaleFactorDict = {2: 0.001, 3: 0.01, 4: 1}
                scaleFactor = scaleFactorDict[system]
                return scaleFactor

            if system != 2 or system != 3 or system != 4:
                return None

        if scale() == None:
            rs.MessageBox(
                "This tool is can only be used in mm, cm or m model units")
            return None

        point = rs.GetPoint('Select point')

        if point:
            pointZ = point.Z
        pointZ = pointZ * scale()
        rs.AddTextDot('+RL ' + str(round(pointZ, 3)), point)

        # Copy RL to Clipboard
        RL = str(round(pointZ, 3))
        rs.ClipboardText(RL)

    except:
        print("Failed to execute")
        rs.EnableRedraw(True)
        return
示例#2
0
def Height():
    try:

        pt01 = rs.GetPoint('Select first point to measure from')
        pt02 = rs.GetPoint('Select second point to measure to')

        if pt02:

            pt01Z = pt01.Z
            pt02Z = pt02.Z

            height = abs(pt01Z - pt02Z)
            height = round(height, 3)

            rs.ClipboardText(height)

            rs.MessageBox(
                height,
                buttons=0,
                title="Height difference - Value copied to clipboard")

    except:
        print("Failed to execute")
        rs.EnableRedraw(True)
        return
示例#3
0
 def copyToClipboard(self, sender, e):
     try:
         string = self.DataStoreToHTML()
         rs.ClipboardText(string)
         print "Copied to clipboard"
     except:
         print "copyToClipboard() Failed"
示例#4
0
def calcArea(srfs):
    areas = []
    for srf in srfs:
        areas.append(rs.SurfaceArea(srf)[0])
    totalArea = sum(areas)
    totalAreaPy = totalArea / 3.3058
    print area, areapy
    txt = rs.ClipboardText(area)
示例#5
0
 def copySelectionToClipboard(self, sender, e):
     try:
         items = list(self.grid.SelectedItems)
         string = self.DataStoreToHTML(items)
         rs.ClipboardText(string)
         print "Copied Selection to clipboard"
     except:
         print "copySelectionToClipboard() Failed"
示例#6
0
def GetCoordinate():
    try:

        # Get point from user and round to nearest 3 decimal points
        point = rs.GetPoint("Pick point to find Coordinate information")
        pointX = round(point.X, 3)
        pointY = round(point.Y, 3)
        pointZ = round(point.Z, 3)

        # store string in variable
        coord = ("E " + str(pointX) + " N " +
                 str(pointY) + " Z " + str(pointZ))

        # Create textdot
        rs.AddTextDot("E " + str(pointX) + " N " +
                      str(pointY) + " Z " + str(pointZ), point)

        # copy to clipboard
        rs.ClipboardText(coord)

    except:
        print("Failed to execute")
        rs.EnableRedraw(True)
        return
示例#7
0
for face in faces:
    if rs.IsSurface(face):
        domainU = rs.SurfaceDomain(face, 0)
        domainV = rs.SurfaceDomain(face, 1)
        u = domainU[1] / 2.0
        v = domainV[1] / 2.0
        point = rs.EvaluateSurface(face, u, v)
        param = rs.SurfaceClosestPoint(face, point)
        normal = rs.SurfaceNormal(face, param)
        # print normal
        if normal.Z == -1:
            bndry.append(face)

for bnd in bndry:
    area = rs.SurfaceArea(bnd)[0]
    areapy = area / 3.3058
    print area, areapy
    txt = rs.ClipboardText(area)

if faces: rs.DeleteObjects(faces)


def calcArea(srfs):
    areas = []
    for srf in srfs:
        areas.append(rs.SurfaceArea(srf)[0])
    totalArea = sum(areas)
    totalAreaPy = totalArea / 3.3058
    print area, areapy
    txt = rs.ClipboardText(area)
def RunCommand( is_interactive ):
    print(__commandname__ + " v0.5.1")

    # ZERO_TOLERANCE = 1.0e-2
    ZERO_TOLERANCE = rs.UnitAbsoluteTolerance()
    myDebug = True
    unlockLayersDefault = False
    global plane
    plane = []
    selectedObjects = []
    selectedCounter = 0

    go = rc.Input.Custom.GetObject()
    go.SetCommandPrompt("Select Two Parallel Planar Surfaces")
    go.AlreadySelectedObjectSelect = False
    go.DeselectAllBeforePostSelect = False
    go.EnableClearObjectsOnEntry(False)
    # go.EnableUnselectObjectsOnExit(False)
    go.OneByOnePostSelect = True
    go.SubObjectSelect = True
    go.EnablePreSelect(False, True)
    # go.EnableClearObjectsOnEntry(False)

    # Filter object type
    geometryType = rc.DocObjects.ObjectType.Surface
    go.GeometryFilter = geometryType

    # Set up command option persistance memory
    if sc.sticky.has_key("distance_parallel_unlock"):
        unlockLayersDefault = sc.sticky["distance_parallel_unlock"]
    else:
        sc.sticky["distance_parallel_unlock"] = False
        unlockLayersDefault = sc.sticky["distance_parallel_unlock"]

    if sc.sticky.has_key("distance_parallel_msg_box"):
        messageBoxDefault = sc.sticky["distance_parallel_msg_box"]
    else:
        sc.sticky["distance_parallel_msg_box"] = False
        messageBoxDefault = sc.sticky["distance_parallel_msg_box"]

    # set up command options
    unlockLayers = rc.Input.Custom.OptionToggle(unlockLayersDefault, "Off", "On")
    go.AddOptionToggle("UnlockLayersAndObjects", unlockLayers)

    messageBox = rc.Input.Custom.OptionToggle(messageBoxDefault, "Off", "On")
    go.AddOptionToggle("ResultsInMessageBox", messageBox)

    unlockLayersPrevState = unlockLayers.CurrentValue
    messageBoxPrevState = messageBox.CurrentValue

    if unlockLayers.CurrentValue == 1:
        ul.unlockLayersAndObjects()


    while True:

        getResult = go.GetMultiple(selectedCounter+1,selectedCounter+1)
        # go.EnableClearObjectsOnEntry(False)
        # go.DeselectAllBeforePostSelect = False
        if getResult == rc.Input.GetResult.Cancel:
            clean_up_cancel()
            return rc.Commands.Result.Cancel
        #     clean_up_success()
        #     return go.CommandResult()
        if getResult == rc.Input.GetResult.Object:
            # Get the view that the point was picked in.
            view = go.View()
            selectedObjects = go.Objects()
            selectedCounter = len(selectedObjects)
            # get objects from selections
            objref = go.Object(selectedCounter-1)
            # get selected surface object
            obj = objref.Object()
            if not obj:
                # Why do?
                if myDebug :
                    msgOut("Object not selected.")
                clean_up_fail()
                return rc.Commands.Result.Failure
            try:
                surface = objref.Surface()
            except:
                msgOut("Surfaces within blocks are not always selectable. Polysurfaces can be selected, Extrusion cannot. Explode block for more selectability.")
                # try to continue and reselect
                clean_up_fail()
                return rc.Commands.Result.Failure
            if not surface:
                # why is this needed?
                if myDebug :
                    msgOut("No surface selected.")
                clean_up_fail()
                return rc.Commands.Result.Failure

            test, getPlane = surface.TryGetPlane(ZERO_TOLERANCE)
            if not test:
                msgOut("Surface is not planar.")
                # maybe continue or allow select of first surface again
                clean_up_fail()
                return rc.Commands.Result.Failure
            plane.append(getPlane)
            if selectedCounter == 2:
                # view.Redraw()
                break
            # loop until second surface selected or cancel
            continue
        # Command Options
        elif getResult == rc.Input.GetResult.Option:
            if unlockLayers.CurrentValue != unlockLayersPrevState:
                if unlockLayers.CurrentValue == 1:
                    sc.sticky["distance_parallel_unlock"] = True
                    unlockLayersPrevState = True
                    ul.unlockLayersAndObjects()
                else:
                    sc.sticky["distance_parallel_unlock"] = False
                    unlockLayersPrevState = False
                    ul.relockLayersAndObjects()
            elif messageBox.CurrentValue != messageBoxPrevState:
                if messageBox.CurrentValue == 1:
                    sc.sticky["distance_parallel_msg_box"] = True
                    messageBoxPrevState = True
                else:
                    sc.sticky["distance_parallel_msg_box"] = False
                    messageBoxPrevState = False
    	    go.EnablePreSelect(False, True)
            continue
        elif getResult == rc.Input.GetResult.Nothing:
            # needed?
            msgOut("Got nothing.")
            clean_up_fail()
            return rc.Commands.Result.Failure
            # break
        # end While

    clean_up_success()
    # Are planes parallel
    if ArePlanesParallel(plane[0], plane[1], ZERO_TOLERANCE) == False:
        msgOut("Surfaces are not parallel to each other.")
        clean_up_fail()
        return rc.Commands.Result.Failure
    # measure distance between planes
    # acually distance between plane[0] and point on plan[1]
    ParallelDistance = abs(rs.DistanceToPlane(plane[0], plane[1][0]))
    # output results
    unitsName = doc.GetUnitSystemName(True, True, True, False)
    ## fromating output decimal places not working for me
    # decimalPlaces = doc.DistanceDisplayPrecision
    # textOut = "Parallel Distance = {:." + str(decimalPlaces) +"f} " + unitsName
    rs.ClipboardText(ParallelDistance)
    textOut = "Parallel Distance = {:.4f} " + unitsName
    # msgOut(textOut.format(ParallelDistance))
    print(textOut.format(ParallelDistance))
    if sc.sticky["distance_parallel_msg_box"]:
        # view.Redraw()
        rs.MessageBox("the value is saved to your clipboard", 64, textOut.format(ParallelDistance))
    else:
        pass
        #delay enough to see last selected highlighting before commend ends
        #Doesn't always work. look for better way to do this
        # rs.Sleep(400)
    return rc.Commands.Result.Success