Пример #1
0
def RunCommand(is_interactive):

    config = {
        "name": "Cloud",
        "message": "start cloud in ?",
        "options": [
            {
                "name": "background",
                "message": "background",
                "action": None
            },
            {
                "name": "console",
                "message": "console",
                "action": None
            }
        ]
    }

    menu = CommandMenu(config)
    action = menu.select_action()

    if action['name'] == 'background':
        background = True
    if action['name'] == 'console':
        background = False

    p = get_proxy()
    p.background = background
    p.restart()
Пример #2
0
def RunCommand(is_interactive):
    RV2 = get_rv2()
    if not RV2:
        return

    session = RV2["session"]
    settings = RV2["settings"]
    scene = RV2["scene"]

    menu = CommandMenu(config)
    action = menu.select_action()

    if not action:
        return

    form = action['action'](session["cwd"])

    if not form:
        return

    rhinoform = RhinoFormDiagram(form)
    rhinoform.draw(settings)

    rhinothrust = RhinoThrustDiagram(form)

    scene["form"] = rhinoform
    scene["force"] = None
    scene["thrust"] = rhinothrust
Пример #3
0
def RunCommand(is_interactive):
    scene = get_scene()
    if not scene:
        return

    # get untrimmed surface(s) -------------------------------------------------
    guid = compas_rhino.select_surface(
        message='select an untrimmed surface or a polysurface')

    if not guid:
        return

    compas_rhino.rs.HideObjects(guid)

    # make subd object ---------------------------------------------------------
    subdobject = SubdObject.from_guid(guid)

    if not subdobject:
        return

    compas_rhino.rs.HideObjects(guid)
    subdobject.draw_coarse()
    subdobject.get_draw_default_subd()
    subdobject.draw_subd()

    # interactively  modify subdivision ----------------------------------------
    while True:
        menu = CommandMenu(config)
        action = menu.select_action()

        if not action or action is None:
            subdobject.clear()
            print("Pattern from surface(s) aborted!")
            compas_rhino.rs.ShowObjects(guid)
            return

        if action['name'] == 'Finish':
            break

        action['action'](subdobject)

    # make pattern -------------------------------------------------------------
    mesh = subdobject.subd
    xyz = mesh.vertices_attributes('xyz')
    faces = [mesh.face_vertices(fkey) for fkey in mesh.faces()]
    pattern = Pattern.from_vertices_and_faces(xyz, faces)

    # clear skeleton
    layer = subdobject.settings['layer']
    subdobject.clear()
    compas_rhino.delete_layers([layer])

    scene.clear()
    scene.add(pattern, name='pattern')
    scene.update()

    print(
        "Pattern object successfully created. Input surface(s) have been hidden."
    )
Пример #4
0
def RunCommand(is_interactive):
    scene = get_scene()
    if not scene:
        return

    rhinoform = scene.get("form")[0]
    if not rhinoform:
        return

    menu = CommandMenu(config)
    action = menu.select_action()

    if not action:
        return

    action["action"](rhinoform)
Пример #5
0
def RunCommand(is_interactive):
    if 'FOFIN' not in sc.sticky:
        print("Initialise the plugin first!")
        return

    FOFIN = sc.sticky['FOFIN']
    if not FOFIN['cablenet']:
        return

    cablenet = FOFIN['cablenet']
    settings = FOFIN['settings']

    menu = CommandMenu(config)
    action = menu.select_action()
    if action:
        action['action'](cablenet, settings)
Пример #6
0
def RunCommand(is_interactive):
    if "FOFIN" not in sc.sticky:
        print("Initialise the plugin first!")
        return

    FOFIN = sc.sticky["FOFIN"]
    settings = FOFIN["settings"]
    cablenet = FOFIN["cablenet"]

    menu = CommandMenu(config)
    action = menu.select_action()
    if action:
        del FOFIN["cablenet"]
        cablenet = action["action"](settings)
        cablenet.draw(layer=settings["layer"],
                      clear_layer=True,
                      settings=settings)
        FOFIN["cablenet"] = cablenet
Пример #7
0
def RunCommand(is_interactive):
    if "FOFIN" not in sc.sticky:
        print("Initialise the plugin first!")
        return

    rs.UnselectAllObjects()

    FOFIN = sc.sticky["FOFIN"]

    if not FOFIN["cablenet"]:
        print("There is no cablenet.")
        return

    cablenet = FOFIN["cablenet"]

    menu = CommandMenu(config)
    action = menu.select_action()
    if action:
        action["action"](cablenet)
Пример #8
0
def RunCommand(is_interactive):

    config = {
        "name":
        "Cloud",
        "message":
        "compad_cloud settings",
        "options": [{
            "name": "done",
            "message": "done",
            "action": None
        }, {
            "name": "shutdown",
            "message": "shutdown",
            "action": shutdown
        }, {
            "name": "restart",
            "message": "restart",
            "action": restart
        }, {
            "name": "check",
            "message": "check",
            "action": check
        }]
    }

    while True:
        menu = CommandMenu(config)
        action = menu.select_action()
        if not action:
            return

        if action['name'] == 'done':
            return

        action['action']()
Пример #9
0
def RunCommand(is_interactive):

    if '3GS' not in sc.sticky:
        compas_rhino.display_message('3GS has not been initialised yet.')
        return

    scene = sc.sticky['3GS']['scene']

    # get ForceVolMeshObject from scene
    objects = scene.find_by_name('form')
    if not objects:
        compas_rhino.display_message("There is no FormDiagram in the scene.")
        return
    form = objects[0]

    # --------------------------------------------------------------------------

    # draw skeleton from form ...

    menu = CommandMenu(config)
    action = menu.select_action()

    lines = [
        form.network.edge_coordinates(u, v) for u, v in form.network.edges()
    ]

    if action['name'] == 'Exoskeleton':
        branch_radius = compas_rhino.rs.GetReal('branch radius:')
        node_radius_fac = compas_rhino.rs.GetReal('node size factor:',
                                                  number=1,
                                                  minimum=1)
        # segments = compas_rhino.rs.GetInteger('profile segments?', number=4, minimum=3)
        kwargs = {
            'lines': lines,
            'branch_radius': branch_radius,
            'node_radius_fac': node_radius_fac,
            # 'segments': segments
        }

        sk3, guid = action['action'](**kwargs)

    else:
        raise NotImplementedError
        # joint_width = compas_rhino.rs.GetReal('joint node widths:')
        # leaf_width = compas_rhino.rs.GetReal('leaf node widths:')
        # kwargs = {
        #     'lines': lines,
        #     'joint_width': joint_width,
        #     'leaf_width': leaf_width
        # }
        # action['action'](**kwargs)

    while True:
        menu = CommandMenu(config_modify)
        action = menu.select_action()
        if not action:
            return

        if action['name'] == 'Finish':
            break

        sk3, guid = action['action'](sk3, guid)

    scene.update()
    scene.save()
def RunCommand(is_interactive):
    scene = get_scene()
    if not scene:
        return

    # skeleton from single point or a set of lines
    guids_temp = compas_rhino.rs.GetObjects(
        message="Select a single point or a group of lines",
        filter=compas_rhino.rs.filter.point | compas_rhino.rs.filter.curve)

    if not guids_temp:
        return

    # detect input object type
    guids_points = []
    guids_lines = []
    for guid in guids_temp:
        if is_curve_line(guid):
            guids_lines.append(guid)

        if compas_rhino.rs.IsPoint(guid):
            guids_points.append(guid)

    if len(guids_points) == 1 and len(guids_lines) == 0:
        guids = guids_points
        point = compas_rhino.get_point_coordinates(guids)[0]
        skeleton = Skeleton.from_center_point(point)

    elif len(guids_points) == 0 and len(guids_lines) > 0:
        guids = guids_lines
        lines = compas_rhino.get_line_coordinates(guids)
        skeleton = Skeleton.from_skeleton_lines(lines)

    if not skeleton:
        return

    compas_rhino.rs.HideObjects(guids)
    skeletonobject = SkeletonObject(skeleton)
    skeletonobject.draw()
    skeletonobject.dynamic_draw_widths()

    # modify skeleton
    while True:
        menu = CommandMenu(config)
        action = menu.select_action()
        if not action:
            return

        if action['name'] == 'Finish':
            break

        action['action'](skeletonobject)
        skeletonobject.draw()

    # make pattern
    mesh = skeletonobject.skeleton.to_mesh()
    xyz = mesh.vertices_attributes('xyz')
    faces = [mesh.face_vertices(fkey) for fkey in mesh.faces()]
    pattern = Pattern.from_vertices_and_faces(xyz, faces)

    # clear skeleton
    layer = skeletonobject.settings['layer']
    skeletonobject.clear()
    compas_rhino.delete_layers([layer])

    scene.clear()
    scene.add(pattern, name='pattern')
    scene.update()

    print("Pattern object successfully created. Input lines have been hidden.")