예제 #1
0
def _define_other_block():
    guids = _draw_x()
    base_point = (0, 0, 0)
    name = 'x'
    delete_input = True
    rs.AddBlock(guids, base_point, name, delete_input)
    return name
예제 #2
0
 def _new_definition(cls):
     """Requires:
         A frame definition does not already exist
         A layer named <frame_layer_name> does not already exist
     Creates a frame definition on its own layer. Returns:
         frame_name_out  str. The name of the frame definition
     """
     (   layer_name, 
         color_name
     ) = (
         s.Settings.frame_layer_name, 
         s.Settings.frame_color_name)
     rs.AddLayer(layer_name, color_name)
     rs.CurrentLayer(layer_name)
     (   line_guids, 
         base_point, 
         frame_name_in,
         delete_input
     ) = (
         cls._get_guids(), 
         s.Settings.frame_base_point,
         s.Settings.frame_name,
         True)
     frame_name_out = rs.AddBlock(
         line_guids, base_point, frame_name_in, delete_input)
     (   default_layer_name
     ) = (
         s.Settings.default_layer_name)
     rs.CurrentLayer(default_layer_name)
     return frame_name_out
예제 #3
0
def initDoorBlock():
    if not rs.IsLayer("Opening"): 
        initCaadLayer("Opening")
    oldLayer = rs.CurrentLayer("Opening"); 
    line = rs.AddLine( (0.0, 0.0, 0.0), (0.0, 1000.0, 0.0) )
    arc = rs.AddArcPtTanPt( (1000,0,0), (0,1,0), (0,1000,0))
    block = rs.AddBlock((line,arc), (500,0,0), "door", True)
    rs.CurrentLayer(oldLayer); 
예제 #4
0
def initWindowBlock():
    if not rs.IsLayer("Opening"): 
        initCaadLayer("Opening")
    oldLayer = rs.CurrentLayer("Opening"); 
    line0 = rs.AddLine( (0.0, 0.0, 0.0), (1000.0, 0.0, 0.0) )
    line1 = rs.AddLine( (0.0, 50.0, 0.0), (1000.0, 50.0, 0.0) )
    line2 = rs.AddLine( (0.0, 100.0, 0.0), (1000.0, 100.0, 0.0) )
    block = rs.AddBlock((line0,line1,line2), (500,50,0), "window", True)
    rs.CurrentLayer(oldLayer); 
예제 #5
0
 def _define_zigzag_block(self):
     """Defines a zigzag block. Returns:
         name_out        str. The name of the zigzag block
     """
     zigzag_guids = self._draw_zigzag()
     base_point = (8, 8, 0)
     name_in = 'zigzag'
     delete_input = True
     name_out = rs.AddBlock(zigzag_guids, base_point, name_in, delete_input)
     return name_out
예제 #6
0
 def try_yes_definition():
     try_name = 'yes_definition'
     g.Grammar.clear_all()
     double_arrow_name = s.Settings.double_arrow_name
     color_name = s.Settings.double_arrow_color_name
     rs.AddLayer(double_arrow_name, color_name)
     rs.CurrentLayer(double_arrow_name)
     position = (0, 0, 0)
     guids = da.DoubleArrow._get_guids(position)
     delete_input = True
     rs.AddBlock(guids, position, double_arrow_name, delete_input)
     da.DoubleArrow.new_instance(double_arrow_name, position)
예제 #7
0
def addLevelMarks(func):
    rs.EnableRedraw(False)
    leftAlign = True
    geometry = []
    currentLevels = setLevels.getFloorLevels()
    for level in currentLevels:
        if level is None:
            print "Levels have not been set."
            return
    levelNames = rs.GetDocumentData("Levels")
    size = 10
    i = 0
    stPts = []
    for level in currentLevels:
        vec1 = [size*.2,size*.1,0]
        ptA = [0, level, 0]
        ptB = [size*.5, level, 0]
        stPts.append(ptA)
        geometry.append(rs.AddLine(ptA, ptB))
        geometry.append(rs.AddText(levelNames[i] + ": +" + str(level), rs.VectorAdd(ptA, vec1), size*.1))
                
        #Triangle Marking
        triPts = [[0,0,0], [size*.05, size*.07,0], [-size*.05, size*.07,0], [0,0,0]]
        newPts = []
        triPt = rs.VectorAdd(ptA, [size*.1, 0,0])
        for j in range(0, 4):
            newPts.append(rs.VectorAdd(triPt, triPts[j]))
        tri = rs.AddPolyline(newPts)
        geometry.append(rs.CloseCurve(tri))
        i=i+1
    
    #Dimensions
    for i in range(0, len(currentLevels)-1):
        pt1 = [0,currentLevels[i], 0]
        pt2 = [0,currentLevels[i+1], 0]
        pt3 = [size*-.15,currentLevels[i+1], 0]
        geometry.append(rs.AddAlignedDimension(pt1, pt2, pt3))
    firstPt = [0,currentLevels[0], 0]
    lastPt = [0,currentLevels[-1], 0]
    dimOffset = [size*-.3,currentLevels[-1], 0]
    geometry.append(rs.AddAlignedDimension(firstPt, lastPt, dimOffset))
    rs.AddLayer("80_LAYOUT", visible = True)
    annoLayer = rs.AddLayer("ANNO", parent = "80_LAYOUT")
    for geo in geometry:
        rs.ObjectLayer(geo, annoLayer)
    rs.AddBlock(geometry, [0,0,0], "Level Marks", True)
    if (func == 0):
        block = rs.InsertBlock("Level Marks", [0,0,0])
        rs.ObjectLayer(block, "ANNO")
    
    rs.EnableRedraw(True)
    return
예제 #8
0
def MakeBlockUnique(block, newName):
    """
    Explodes a block and makes a new one with 'newName'
    """
    xform = rs.BlockInstanceXform(block)
    insertPt = rs.BlockInstanceInsertPoint(block)
    objs = rs.ExplodeBlockInstance(block, False)
    rs.TransformObjects(objs, rs.XformInverse(xform))
    pt = rs.TransformObject(insertPt, rs.XformInverse(xform))
    rs.AddBlock(objs, insertPt, newName, True)
    newBlock = rs.InsertBlock2(newName, xform)
    rs.DeleteObject(pt)
    return newBlock
예제 #9
0
def CreateDesignOption():
    objs = rs.GetObjects("Select objects to create design option with",
                         preselect=True)
    if objs is None: return None
    try:
        date = utils.GetDatePrefix()
        origName = date + '_OPTION_00'
        defaultName = origName
        for i in range(100):
            defaultName = utils.UpdateString(defaultName)
            if origName == defaultName:
                break
            if rs.IsBlock(defaultName) == False:
                break

        looping = True
        while looping:
            designOptionName = rs.StringBox("Design Option Name", defaultName,
                                            "Create Design Option")
            if designOptionName is None: return None
            if rs.IsBlock(designOptionName):
                print "Block name already exists"
            elif len(designOptionName) == 0:
                print "Must specify a name"
            else:
                looping = False
        block = rs.AddBlock(objs, (0, 0, 0), designOptionName, True)
        blockInstance = rs.InsertBlock(designOptionName, (0, 0, 0))

        #Add user text
        rs.SetUserText(blockInstance, 'Design Option History',
                       designOptionName)

        #Ensure 3_DESIGN OPTIONS already exists
        layers.AddLayerByNumber(3000, False)

        #Create new layer
        parentLayer = layers.GetLayerNameByNumber(3000)
        designOptionLayer = rs.AddLayer(parentLayer + "::" + designOptionName,
                                        color=utils.GetRandomColor())
        rs.ObjectLayer(blockInstance, designOptionLayer)
        utils.SaveFunctionData('Blocks-Create Design Option',
                               [__version__, designOptionName])
        return True
    except:
        print "Failed to create design option"
        utils.SaveFunctionData('Blocks-Create Design Option',
                               [__version__, '', 'Failed'])
        return None
예제 #10
0
def redefineBlockScale(block):
    block_name = rs.BlockInstanceName(block)
    # rs.RenameBlock (block_name, "{}-old".format(block_name))
    blockXform = rs.BlockInstanceXform(block)
    plane = rs.PlaneTransform(rs.WorldXYPlane(), blockXform)
    cob = rs.XformChangeBasis(plane, rs.WorldXYPlane())
    cob_inverse = rs.XformChangeBasis(rs.WorldXYPlane(), plane)
    refBlock = rs.TransformObjects(block, cob_inverse, True)
    exploded = rs.ExplodeBlockInstance(refBlock)
    rs.AddBlock(exploded, rs.WorldXYPlane().Origin, block_name, True)
    newBlock = rs.InsertBlock2(block_name, cob)
    copySourceLayer(newBlock, block)
    try:
        copySourceData(newBlock, block)
    except:
        pass
    rs.DeleteObjects(block)
예제 #11
0
def addResultToBlock(obj, result):
             
            name = rs.BlockInstanceName(obj)
            i_point = rs.BlockInstanceInsertPoint(obj)
            xform = rs.BlockInstanceXform(obj)
            
            block_content = rs.ExplodeBlockInstance(obj)  

            bc=[]
            for c in block_content:
                bc.append(c)
            
            bc.append(result)
            
            rs.AddBlock(bc, i_point, name, True)
            
            rs.InsertBlock2(name, xform)     
예제 #12
0
def ReplicateBlock(blockObj):
    #Copy block
    copiedBlock = rs.CopyObject(blockObj)

    #Get new block name
    origName = rs.BlockInstanceName(blockObj)
    defaultName = origName
    for i in range(100):
        defaultName = utils.UpdateString(defaultName)
        if origName == defaultName:
            break
        if rs.IsBlock(defaultName) == False:
            break

    looping = True
    while looping:
        newBlockName = rs.StringBox("Enter new block name",
                                    default_value=defaultName,
                                    title='Iterate Design Option')
        if newBlockName is None:
            rs.DeleteObject(copiedBlock)
            return
        if rs.IsBlock(newBlockName):
            print "Block name already exists"
        elif len(newBlockName) == 0:
            print "Must specify a name"
        else:
            looping = False

    if newBlockName is None:
        rs.DeleteObject(copiedBlock)
        return

    #Get previous base point
    xform = rs.BlockInstanceXform(copiedBlock)
    basePoint = rs.BlockInstanceInsertPoint(copiedBlock)

    #Explode block
    objsInside = rs.ExplodeBlockInstance(copiedBlock)

    rs.AddBlock(objsInside, basePoint, newBlockName, True)
    #Create new block
    instance = rs.InsertBlock2(newBlockName, xform)
    return instance
예제 #13
0
def organizedBlock():
    """
    create a block from selection and add it to a layer with the block's name
    nested under layer Block_Definitions
    tested in Rhino 6.14
    www.studiogijs.nl
    """

    #get objects to create block from
    objs = rs.GetObjects("select objects to creat block from")
    if not objs: return

    base_point = rs.GetPoint("block base point")
    if not base_point: return

    def checkName():
        block_name = rs.GetString("enter block name")
        if block_name == '' or block_name == None:
            print "block name can't be empty"
            return checkName()
        #check if layer Block_Definitions exist, else create it
        if not rs.IsLayer("Block_Definitions"):
            rs.AddLayer("Block_Definitions")

        #check if layer with block name exists, else create it
        if not rs.IsLayer("Block_Definitions::" + block_name):
            block_layer = rs.AddLayer(block_name, parent="Block_Definitions")

        else:
            print "block definition with this name already exists"
            return checkName()
        return block_layer, block_name

    block_layer, block_name = checkName()

    #create the block
    block = rs.AddBlock(objs, base_point, block_name, True)
    if not block:
        return
    temp_layer = rs.CurrentLayer()
    rs.CurrentLayer(block_layer)
    rs.InsertBlock(block, base_point)
    #restore to previous layer
    rs.CurrentLayer(temp_layer)
def makeBlockUnique(obj):
    oldBase = rs.BlockInstanceInsertPoint(obj)
    if oldBase is None: return
    newName = rs.GetString("New Block Name")
    if newName is None: return
    newOrigin = rs.GetPoint("Select New Block Base point", base_point=oldBase)
    if newOrigin is None: return
    blockObjs = rs.ExplodeBlockInstance(obj)
    if blockObjs is None: return
    origObjs = []

    for a in blockObjs:
        origObjs.append(a)

    rs.AddBlock(origObjs, newOrigin, newName, True)

    rs.InsertBlock(newName, newOrigin)

    return
def draw_model_paperspace():
    #go to paperspace, then go to view and enter its modelspace
    view = rs.CurrentView()  #rs.CurrentDetail()
    detail = rs.CurrentDetail(view)

    type = Rhino.RhinoDoc.ActiveDoc.Views.ActiveView.ActiveViewport.ViewportType
    if type != Rhino.Display.ViewportType.DetailViewport:
        print "Please enter detail modelspace"
        return
    print type

    #get model
    objs = rs.GetObjects("Select objects to draw", rs.filter.polysurface)
    rs.SelectObjects(objs)

    #make 2d, as current view
    rs.Command("!-_Make2D DrawingLayout=CurrentView _enter _enter")
    dwg_crvs = rs.LastCreatedObjects()

    #cut and paste into view window (paperspace)
    origin = [0, 0, 0]
    rs.AddBlock(dwg_crvs, origin, name=view, delete_input=True)

    #leave detail view and insert block
    rs.CurrentDetail(view, detail=view)
    insert_pt = [17, 11, 0]
    obj = rs.InsertBlock(view, insert_pt)

    #orient 2pt with 3d scaling enabled
    r1 = rs.GetPoint("Pick reference corner 1")
    r2 = rs.GetPoint("Pick reference corner 2")
    t1 = rs.GetPoint("Pick target corner 1")
    t2 = rs.GetPoint("Pick target corner 2")
    ref_pts = [r1, r2]
    target_pts = [t1, t2]
    rs.OrientObject(obj, ref_pts, target_pts, flags=2)

    print "Script Finished"
    return
예제 #16
0
 def _new_definition(cls):
     """Creates an arrow definition on its own layer. Returns:
         name            str. The name of the arrow, if successful. None 
                         otherwise
     """
     layer_name = s.Settings.arrow_name
     color_name = s.Settings.arrow_color_name
     rs.AddLayer(layer_name, color_name)
     rs.CurrentLayer(layer_name)
     base_point = s.Settings.arrow_base_point
     line_guids = cls._get_guids(base_point)
     arrow_name = s.Settings.arrow_name
     delete_input = True
     actual_arrow_name = rs.AddBlock(
         line_guids, base_point, arrow_name, delete_input)
     default_layer_name = s.Settings.default_layer_name
     rs.CurrentLayer(default_layer_name)
     layer_names = rs.LayerNames()
     if (layer_name in layer_names and
         actual_arrow_name == arrow_name
     ):
         return_value = actual_arrow_name
     return return_value
예제 #17
0
def RunCommand(is_interactive):
    if sc.escape_test(False):
        print "script cancelled"  #do something

    print "Making unique..."

    #******* Get blocks *****************
    #************************************

    objectIds = rs.GetObjects("Pick some blocks", 4096, preselect=True)
    if not objectIds:
        print "No objects"
        return False

    #pause viewport redraw
    rs.EnableRedraw(False)

    #******* Sort blocks by type ********
    #************************************
    blockTypes = {}
    for id in objectIds:
        blockName = rs.BlockInstanceName(id)
        if blockName not in blockTypes:
            blockTypes[blockName] = []
        blockTypes[blockName].append(id)

    #***** Define new block and add *****
    #************************************

    #Get block names
    blockNames = rs.BlockNames()

    #gather all new objects when done
    finalObjs = []

    for blockType in blockTypes:
        for id in blockTypes[blockType]:
            #Get the block transformation matrix and name
            blockXForm = rs.BlockInstanceXform(id)
            blockName = rs.BlockInstanceName(id)

            #Insert new block in 0,0,0
            newBlock = rs.InsertBlock(blockName, [0, 0, 0])

            #Explode the block
            exObjs = rs.ExplodeBlockInstance(newBlock)

            #create new block name

            # if the string ends in digits m will be a Match object, or None otherwise.
            strippedName = re.sub(r'#[0-9]+$', '', blockName)

            #test if block name exist and add to the end number if true.
            x = 0
            tryAgain = True
            while tryAgain:
                x += 1
                newerBlockName = strippedName + "#" + str(x)
                if newerBlockName not in blockNames:
                    tryAgain = False
                    break

            #insert exObjs as new block
            rs.AddBlock(exObjs, [0, 0, 0], newerBlockName, delete_input=True)
            newerBlock = rs.InsertBlock(newerBlockName, [0, 0, 0])

            #match properties from original
            rs.MatchObjectAttributes(newerBlock, id)

            #transform new block
            rs.TransformObject(newerBlock, blockXForm)

            #append for final selection
            finalObjs.append(newerBlock)

        #add name to list of used blocknames.
        blockNames.append(newerBlockName)

    #Delete original block
    rs.DeleteObjects(objectIds)

    #Select all new objects
    rs.SelectObjects(finalObjs)

    rs.EnableRedraw(True)

    print "...aaand its done."
    #End RunCommand()

    #end sane
    return 0
예제 #18
0
def TreeMassing():
    try:

        litre = rs.GetReal("Enter the root ball litres, max 2000 Litres", 400)
        soilDepth = rs.GetReal('Enter the soil depth available in m', 0.8)
        matureHeight = rs.GetReal('Enter the mature tree height in m', 5)
        dbh = rs.GetReal(
            'Enter the DBH at maturity in m, if unknown hit Enter', 0)
        userPt = rs.GetPoint('Pick a point to place rootball')

        rs.EnableRedraw(False)

        # Dictionery for litre size to pot Rootball Diameter [0] / Rootball Height [1] / Calliper [2] / Height [3] / Spread [4]
        # Figures obtained from https://winterhill.com.au/tree-sizes/
        PotDict = {
            25: [0.300, 0.250, 0.020, 1.000, 0.500],
            45: [0.420, 0.350, 0.025, 2.000, 1.000],
            75: [0.465, 0.500, 0.035, 2.500, 2.000],
            100: [0.520, 0.560, 0.050, 3.500, 2.000],
            200: [0.700, 0.625, 0.070, 4.500, 3.000],
            400: [0.980, 0.715, 0.090, 6.000, 4.000],
            600: [1.200, 0.600, 0.100, 6.000, 5.000],
            800: [1.300, 0.600, 0.120, 7.000, 5.000],
            1000: [1.500, 0.600, 0.150, 8.000, 5.000],
            2000: [2.000, 0.800, 0.200, 9.000, 5.000],
        }

        def closest(lst, K):

            return lst[min(range(len(lst)), key=lambda i: abs(lst[i]-K))]

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

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

        s = scale()

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

        # Calc for standard soil requirements as per Australian Standards

        if dbh == 0:
            dbh = ((matureHeight / 100) * 4) * 1000  # Gives a DBH in mm
        # Gives a required soil volume in M3
        reqSoil = (matureHeight * dbh) / 100
        reqSoilRadius = math.sqrt(reqSoil / ((math.pi)*soilDepth))

        # Add soil puck to doc
        reqSoilRadiusCyl = rs.AddCylinder(
            userPt, (soilDepth*s), (reqSoilRadius*s), cap=True)
        rs.ObjectColor(reqSoilRadiusCyl, (150, 75, 0))

        # Calc for size of rootball as per standard pot sizes
        litreMatch = closest(list(PotDict.keys()), litre)
        dia = (PotDict[litreMatch])[0]
        height = (PotDict[litreMatch])[1]

        # Add Rootball to doc
        rootballCyl = rs.AddCylinder(userPt, (height*s), ((dia/2)*s))
        rs.ObjectColor(rootballCyl, (0, 128, 0))
        vec = (0, 0, ((soilDepth*s) - (height*s)))
        rs.MoveObject(rootballCyl, vec)

        # Add Tree model based on Dict
        calliper = (PotDict[litreMatch])[2]
        treeHeight = (PotDict[litreMatch])[3]
        spread = (PotDict[litreMatch])[4]
        vec02 = (0, 0, (((soilDepth*s) - (height*s))) + (height*s))

        treeTrunk = rs.AddCylinder(userPt, (treeHeight*s), (calliper*s))
        rs.ObjectColor(treeTrunk, (101, 67, 33))
        rs.MoveObject(treeTrunk, vec02)
        canopy = rs.AddSphere(userPt, ((spread/2)*s))
        rs.ObjectColor(canopy, (33, 101, 67))
        vec03 = (0, 0, (((soilDepth*s) - (height*s))) +
                 (height*s) + (treeHeight*s) - ((spread/2)*s))
        rs.MoveObject(canopy, vec03)

        # Various Text Annotation
        txt1 = rs.AddText('Rootball ' + 'Height = ' + str(height*s) + ', Diameter = ' + str(dia*s), userPt,
                          height=(.1*s), font="Arial", font_style=0, justification=2)

        txt2 = rs.AddText('Soil Volume Requirement = ' + str(reqSoil) + ' m3', (userPt.X, (userPt.Y - (.2*s)), userPt.Z),
                          height=(.1*s), font="Arial", font_style=0, justification=2)

        block = rs.AddBlock((reqSoilRadiusCyl, rootballCyl, treeTrunk, canopy, txt1, txt2), userPt,
                            ("Rootball and Soil " + (str(random.random()))), delete_input=True)
        rs.BlockDescription(block, 'Rootball ' + 'Height = ' + str(height*s) + ', Diameter = ' + str(dia*s)
                            + ', Soil Volume Requirement = ' + str(reqSoil) + ' m3')

        guid = rs.InsertBlock(block, userPt)
        rs.ObjectName(guid, 'Rootball ' + 'Height = ' + str(height*s) + ', Diameter = ' + str(dia*s)
                            + ', Soil Volume Requirement = ' + str(reqSoil) + ' m3')

        rs.EnableRedraw(True)

    except:
        print("Failed to execute")
        rs.EnableRedraw(True)
        return
import rhinoscriptsyntax as rs

theObjs = rs.SelectedObjects()

rs.EnableRedraw(enable=False)

for i in range(len(theObjs)):
    obj = [theObjs[i]]
    objName = str(rs.ObjectLayer(obj[0])) + str(i)
    block = rs.AddBlock(obj, (0, 0, 0), objName, True)
    rs.InsertBlock(block, (0, 0, 0))

rs.EnableRedraw(enable=True)
예제 #20
0
def add_rivet(rivet):
    # ***********************************************
    # ******** ADDING THE RIVET TO THE SCENE *********
    # ***********************************************
    old_osnap_state = ModelAidSettings.OsnapModes  #record Osnap state to reset later

    rivets = 0
    rs.OsnapMode(32 + 134217728)
    while True:
        Rhino.UI.MouseCursor.SetToolTip("select surface or face")
        # this function ask the user to select a point on a surface to insert the bolt on
        # Surface to orient on
        gs = Rhino.Input.Custom.GetObject()
        gs.SetCommandPrompt("Surface to orient on")
        gs.GeometryFilter = Rhino.DocObjects.ObjectType.Surface
        gs.Get()
        if gs.CommandResult() != Rhino.Commands.Result.Success:
            ModelAidSettings.OsnapModes = old_osnap_state  #reset to previous Osnap state
            print str(rivets) + " " + rivet.__repr__(
            ) + " rivet(s) added to the document"
            Rhino.UI.MouseCursor.SetToolTip("")

            return

        objref = gs.Object(0)
        # get selected surface object
        obj = objref.Object()
        if not obj:
            ModelAidSettings.OsnapModes = old_osnap_state  #reset to previous Osnap state

            print str(rivets) + " " + rivet.__repr__(
            ) + " bolt(s) added to the document"
            return

        # get selected surface (face)
        global surface
        surface = objref.Surface()
        if not surface: return Rhino.Commands.Result.Failure
        # Unselect surface
        obj.Select(False)

        # Point on surface to orient to / activate center Osnap

        gp = Rhino.Input.Custom.GetPoint()
        gp.SetCommandPrompt("Point on surface to orient to")
        gp.Constrain(surface, False)
        #display the geometry to be created
        gp.DynamicDraw += drawbreps
        gp.Get()

        if gp.CommandResult() != Rhino.Commands.Result.Success:
            ModelAidSettings.OsnapModes = old_osnap_state  #reset to previous Osnap state
            print str(rivets) + " " + rivet.__repr__(
            ) + " bolt(s) added to the document"
            return

        getrc, u, v = surface.ClosestPoint(gp.Point())
        if getrc:
            getrc, target_plane = surface.FrameAt(u, v)
            if getrc:
                # Build transformation
                source_plane = Rhino.Geometry.Plane.WorldXY
                xform = Rhino.Geometry.Transform.PlaneToPlane(
                    source_plane, target_plane)

                #check if layer Block_Definitions exist, else create it
                if not rs.IsLayer("Block_Definitions"):
                    rs.AddLayer("Block_Definitions")

                #check if layer with block name exists, else create it
                if not rs.IsLayer("Block_Definitions::" + rivet.name):

                    block_layer = rs.AddLayer("Block_Definitions::" +
                                              rivet.name,
                                              color=(120, 210, 210))

                block_layer = "Block_Definitions::" + rivet.name

                layer_id = rs.LayerId(block_layer)

                layer_index = sc.doc.Layers.Find(layer_id, True)
                # Do the transformation

                rs.EnableRedraw(False)
                temp_layer = rs.CurrentLayer()

                rs.CurrentLayer(block_layer)

                objs = rivet.breps
                rhobj = []
                for brep in objs:

                    attribs = Rhino.DocObjects.ObjectAttributes()
                    attribs.WireDensity = -1
                    attribs.LayerIndex = layer_index
                    rhobj.append(sc.doc.Objects.AddBrep(brep, attribs))

                rs.AddBlock(rhobj, [0, 0, 0], rivet.name, True)

                newrivet = rs.InsertBlock2(rivet.name, xform)
                rs.CurrentLayer(temp_layer)
                rs.EnableRedraw(True)
                rivets += 1
예제 #21
0
 def _initialize_block(self, name):
     rs.CurrentLayer('infrastructure')
     x, y, z = 0, 0, 0
     frame_lines = self._draw_shape_frame(x, y, z)
     rs.AddBlock(frame_lines, [x, y, z], 'shape frame', True)
     rs.CurrentLayer('Default')
 def add_block(self):
     #cut and paste into view window (paperspace)
     origin = [0, 0, 0]
     name = self.format_block_name()
     rs.AddBlock(self.dwg_crvs, origin, name, delete_input=True)
def initialize_shape_frame_block():
    rs.CurrentLayer('infrastructure')
    x, y, z = [0, 0, 0]
    frame_lines = draw_shape_frame(x, y, z)
    rs.AddBlock(frame_lines, [x, y, z], 'shape frame', True)
    rs.CurrentLayer('Default')