Exemplo n.º 1
0
import compas_rhino
import compas_rbe

from compas_rhino.utilities import XFunc

from compas_rbe.datastructures import Block
from compas_rbe.datastructures import Assembly

from compas_rbe.rhino import AssemblyArtist


# ==============================================================================
# external functions
# ==============================================================================

assembly_interfaces = XFunc('compas_rbe.interfaces.assembly_interfaces_xfunc')
assembly_interfaces.tmpdir = compas_rbe.TEMP

compute_interface_forces = XFunc('compas_rbe.equilibrium.compute_interfaceforces_xfunc')
compute_interface_forces.tmpdir = compas_rbe.TEMP

# # for rhinomac

# assembly_interfaces.paths  = [compas_rbe.SRC]
# compute_interface_forces.paths  = [compas_rbe.SRC]

# mypython = "/Users/vanmelet/anaconda3/bin/python"

# assembly_interfaces.python = mypython
# compute_interface_forces.python = mypython
Exemplo n.º 2
0

# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    import sys

    import compas

    from compas.datastructures import Mesh
    from compas_rhino.utilities import XFunc

    fd_numpy = XFunc('compas.numerical.fd.fd_numpy.fd_numpy',
                     delete_files=True)

    fd_numpy.python = "/Users/vanmelet/anaconda3/bin/python3"

    mesh = Mesh.from_obj(compas.get('faces.obj'))

    vertices = mesh.get_vertices_attributes('xyz')
    edges = list(mesh.edges())
    fixed = list(
        [key for key in mesh.vertices() if mesh.vertex_degree(key) == 2])
    q = mesh.get_edges_attribute('q', 1.0)
    loads = mesh.get_vertices_attributes(('px', 'py', 'pz'), (0.0, 0.0, 0.0))

    xyz, q, f, l, r = fd_numpy(vertices, edges, fixed, q, loads)

    print(xyz)
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import scriptcontext as sc
import traceback

import compas_assembly

from compas_rhino.utilities import XFunc

assembly_interfaces_xfunc = XFunc(
    'compas_assembly.datastructures.assembly_interfaces_xfunc')
assembly_interfaces_xfunc.tmpdir = compas_assembly.TEMP


def assembly_interfaces(assembly, nmax=10, tmax=0.05, amin=0.01, lmin=0.01):
    data = {
        'assembly': assembly.to_data(),
        'blocks':
        {str(key): assembly.blocks[key].to_data()
         for key in assembly.blocks}
    }
    result = assembly_interfaces_xfunc(data,
                                       nmax=nmax,
                                       tmax=tmax,
                                       amin=amin,
                                       lmin=lmin)
    assembly.data = result['assembly']
    for key in assembly.blocks:
        assembly.blocks[key].data = result['blocks'][str(key)]
Exemplo n.º 4
0
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import compas
import compas_rbe

from compas_rhino.utilities import XFunc

from compas_rbe.datastructures import Assembly
from compas_rbe.rhino import AssemblyArtist


# replace this by RPC server
assembly_interfaces_ = XFunc('compas_rbe.interfaces.assembly_interfaces_xfunc', tmpdir=compas_rbe.TEMP)
compute_interface_forces_ = XFunc('compas_rbe.equilibrium.compute_interface_forces_xfunc', tmpdir=compas_rbe.TEMP)

# replace this by automated search for python executables
# based on .(bash_)profile
assembly_interfaces_.python = '/Users/vanmelet/anaconda3/bin/python3'
compute_interface_forces_.python = '/Users/vanmelet/anaconda3/bin/python3'

# replace 
assembly_interfaces_.paths = ['/Users/vanmelet/Code/BlockResearchGroup/compas_rbe/src']
compute_interface_forces_.paths = ['/Users/vanmelet/Code/BlockResearchGroup/compas_rbe/src']


# wrapper
def assembly_interfaces(assembly, nmax=10, tmax=0.05, amin=0.01, lmin=0.01):
    data = {'assembly': assembly.to_data(),
            'blocks'  : {str(key): assembly.blocks[key].to_data() for key in assembly.blocks}}
Exemplo n.º 5
0
# ==============================================================================
# Main
# ==============================================================================

if __name__ == '__main__':

    import sys

    import compas

    from compas.datastructures import Mesh
    from compas_rhino.utilities import XFunc

    from compas_rhino.artists import MeshArtist

    fd_numpy = XFunc('compas.numerical.fd.fd_numpy.fd_numpy',
                     delete_files=True)

    # for rhino on mac
    # fd_numpy.python = "/Users/vanmelet/anaconda3/bin/python3"

    mesh = Mesh.from_obj(compas.get('faces.obj'))

    vertices = mesh.get_vertices_attributes('xyz')
    edges = list(mesh.edges())
    fixed = list(
        [key for key in mesh.vertices() if mesh.vertex_degree(key) == 2])
    q = mesh.get_edges_attribute('q', 1.0)
    loads = mesh.get_vertices_attributes(('px', 'py', 'pz'), (0.0, 0.0, 0.0))

    xyz, q, f, l, r = fd_numpy(vertices, edges, fixed, q, loads)
from __future__ import print_function
from __future__ import absolute_import
from __future__ import division

import scriptcontext as sc
import traceback

import compas_rbe

from compas_rhino.utilities import XFunc


compute_interface_forces_xfunc = XFunc('compas_rbe.equilibrium.compute_interface_forces_xfunc', tmpdir=compas_rbe.TEMP)


def compute_interface_forces(assembly, solver):
    data = {
        'assembly': assembly.to_data(),
        'blocks': {str(key): assembly.blocks[key].to_data() for key in assembly.blocks},
    }
    result = compute_interface_forces_xfunc(data, solver=solver)
    assembly.data = result['assembly']
    for key in assembly.blocks:
        assembly.blocks[key].data = result['blocks'][str(key)]


__commandname__ = "Assembly_compute_interface_forces"


def RunCommand(is_interactive):
    try:
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

import os

import compas

from compas_rhino.utilities import XFunc
from compas_assembly.datastructures import Assembly


# make an XFunc version of the compute interfaces function

compute_interface_forces_xfunc = XFunc('compas_rbe.equilibrium.compute_interface_forces_xfunc')

# path to CPython on RhinoMac
# change this if necessary

if compas.is_mono():
    python = os.path.join(os.environ['HOME'], 'anaconda3/bin/python')
    compute_interface_forces_xfunc.python = python

# a convenience wrapper

def compute_interface_forces(assembly, **kwargs):
    data = {
        'assembly': assembly.to_data(),
        'blocks': {str(key): assembly.blocks[key].to_data() for key in assembly.blocks},
    }