Beispiel #1
0
    def read_objects_from_layer(self, layer_name):
        """Read the user-visible names of all objects on a specific RhinoDoc layer.
        Returns a tuple (geoms, guids, names) with lists of all geometry
        objects, RhinoDoc GUID strings, and name attributes.
        """
        layer_index = ghrhinodoc.fetch_or_create_layer_index(layer_name)

        # Fetch all objects on the layer and report out individual properties.
        all_objects = ghrhinodoc.all_doc_objects(layer_name)

        geoms = [obj.Geometry for obj in all_objects]
        guids = [str(obj.Id) for obj in all_objects]
        names = [obj.Attributes.Name for obj in all_objects]
        return geoms, guids, names
Beispiel #2
0
    def read_objects_from_layer(self, layer_name):
        """Read the user-visible names of all objects on a specific RhinoDoc layer.
        Returns a tuple (geoms, guids, names) with lists of all geometry
        objects, RhinoDoc GUID strings, and name attributes.
        """
        layer_index = ghrhinodoc.fetch_or_create_layer_index(layer_name)

        # Fetch all objects on the layer and report out individual properties.
        all_objects = ghrhinodoc.all_doc_objects(layer_name)

        geoms = [obj.Geometry for obj in all_objects]
        guids = [str(obj.Id) for obj in all_objects]
        names = [obj.Attributes.Name for obj in all_objects]
        return geoms, guids, names
Beispiel #3
0
# LayerGeometry.py - contents of the LayerGeometry ghpython script

# inputs
#   layer  - string naming the layer to address within the current Rhino document
#  update  - any input will force recomputing the output (dummy value)

# outputs
#   out    - console debugging output
#   geom   - list of geometry primitives currently present in the layer
#   guid   - list of GUID strings for the geometry primitives
#
# Note: the GUIDs are for objects located in the RhinoDoc database, *not* the
# Grasshopper document database, so they are only useful for requesting updates
# to the current Rhino document.

import Rhino
import System.Guid
import pythonlibpath
pythonlibpath.add_library_path()
import ghutil.ghrhinodoc as ghrhinodoc

# Fetch the layer index, creating the layer if not present.
layer_name = str(layer)
layer_index = ghrhinodoc.fetch_or_create_layer_index(layer_name)

# Fetch all objects on the layer and report out individual properties.
all_objects = ghrhinodoc.all_doc_objects(layer_name)

geom = [obj.Geometry for obj in all_objects]
guid = [str(obj.Id) for obj in all_objects]
Beispiel #4
0
# inputs
#   layer  - string naming the layer to address within the current Rhino document
#  update  - any input will force recomputing the output (dummy value)

# outputs
#   out     - console debugging output
#   geoms   - list of geometry primitives currently present in the layer
#   guids   - list of GUID strings for the geometry primitives
#   names   - list of user-visible object names

# Note: the GUIDs are for objects located in the RhinoDoc database, *not* the
# Grasshopper document database, so they are only useful for requesting updates
# to the current Rhino document.

import Rhino
import System.Guid
import pythonlibpath; pythonlibpath.add_library_path()
import ghutil.ghrhinodoc as ghrhinodoc

# Fetch the layer index, creating the layer if not present.
layer_name = str(layer)
layer_index = ghrhinodoc.fetch_or_create_layer_index(layer_name)

# Fetch all objects on the layer and report out individual properties.
all_objects = ghrhinodoc.all_doc_objects(layer_name)

geoms = [obj.Geometry for obj in all_objects]
guids = [str(obj.Id) for obj in all_objects]
names = [obj.Attributes.Name for obj in all_objects]
Beispiel #5
0
#   array   - list of srfs representing part boundaries
#   names - a list of strs corresponding to Rhino.DocObject Names
# notes
#   Best if Rhino parts are named with sequential integers
#   script reorders grasshopper list to correspond to Rhino part order and
#   maintains Rhio naming convention

import rhinoscriptsyntax as rs
import ghutil.ghrhinodoc as ghutil
import ghutil.trees as trees
import scriptcontext as sc
import Rhino as r

#============================================================================

#fetch all objects on specified layer
all_objects = ghutil.all_doc_objects(layer_name)

# get and order Rhino object names
name = [obj.Name for obj in all_objects]
names = sorted(name)
geom = [obj.Geometry for obj in all_objects]

# create a list of srfs based on ordered name list
dict_tuple = zip(name, geom)
parts = dict(dict_tuple)
array = []
items = sorted(parts)
for item in items:
    array.append(parts[str(item)])
Beispiel #6
0
# outputs
#   out    - console debugging output
# notes
#   script currently hard coded to take in geo from only those layers reprsented 
#   in input.


import scriptcontext as sc
import Rhino as r
import ghutil.ghrhinodoc as ghutil

#==============================================================================

# take in all geo inputs and order them by layer name list
allItems = [no_cut,score,cut_1,cut_2]
layerNum = 0
for name in layers:
    # create or fetch cut sht layers
    layer =  ghutil.fetch_or_create_layer_index(name)
    # delete any current items on these layers 
    all_objects = ghutil.all_doc_objects(name)
    for obj in all_objects:
        r.RhinoDoc.ActiveDoc.Objects.Delete(obj, True)
    # add all objects associated with layer
    layerItems = allItems[layerNum]
    layerNum +=1
    for item in layerItems:
        ghutil.add_geometry(item,layer)


Beispiel #7
0
#   array   - list of srfs representing part boundaries
#   names - a list of strs corresponding to Rhino.DocObject Names
# notes
#   Best if Rhino parts are named with sequential integers
#   script reorders grasshopper list to correspond to Rhino part order and 
#   maintains Rhio naming convention

import rhinoscriptsyntax as rs
import ghutil.ghrhinodoc as ghutil
import ghutil.trees as trees
import scriptcontext as sc
import Rhino as r

#============================================================================

#fetch all objects on specified layer
all_objects = ghutil.all_doc_objects(layer_name)

# get and order Rhino object names
name = [obj.Name for obj in all_objects]
names = sorted(name)
geom = [obj.Geometry for obj in all_objects]

# create a list of srfs based on ordered name list
dict_tuple = zip(name,geom)
parts = dict(dict_tuple)
array = []
items = sorted(parts)
for item in items:
    array.append (parts[str(item)])
    
Beispiel #8
0
#   score - geo for score layer
#   cut_1 - geo for cut_1 layer
#   cut_2 - geo for cut_2 layer
# outputs
#   out    - console debugging output
# notes
#   script currently hard coded to take in geo from only those layers reprsented
#   in input.

import scriptcontext as sc
import Rhino as r
import ghutil.ghrhinodoc as ghutil

#==============================================================================

# take in all geo inputs and order them by layer name list
allItems = [no_cut, score, cut_1, cut_2]
layerNum = 0
for name in layers:
    # create or fetch cut sht layers
    layer = ghutil.fetch_or_create_layer_index(name)
    # delete any current items on these layers
    all_objects = ghutil.all_doc_objects(name)
    for obj in all_objects:
        r.RhinoDoc.ActiveDoc.Objects.Delete(obj, True)
    # add all objects associated with layer
    layerItems = allItems[layerNum]
    layerNum += 1
    for item in layerItems:
        ghutil.add_geometry(item, layer)
Beispiel #9
0
 def _update_namesets(self, all_names):
     all_objects = ghrhinodoc.all_doc_objects(layer_name)        
     names = [obj.Attributes.Name for obj in all_objects]
     self.set_namesets(all_names, names)
     return
Beispiel #10
0
 def _update_namesets(self, all_names):
     all_objects = ghrhinodoc.all_doc_objects(layer_name)
     names = [obj.Attributes.Name for obj in all_objects]
     self.set_namesets(all_names, names)
     return