Example #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
Example #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
Example #3
0
#   guid   - GUID string identifying a single object within the RhinoDoc

# outputs
#   out    - console debugging output
#
# 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

if guid is not None:
    # Fetch the layer index, creating the layer if not present.
    layer_name = str(layer)
    layer_index = ghrhinodoc.fetch_or_create_layer_index(layer_name)
    
    # Look up the object to delete.
    print "GUID to modify is", guid, type(guid)
    
    # convert from a string to a Guid object
    guid = System.Guid(guid)
    
    existing = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid)
    print "Found RhinoDoc object", existing
    
    # Delete the geometry from the RhinoDoc with the given layer and name.
    Rhino.RhinoDoc.ActiveDoc.Objects.Delete(guid, True)
Example #4
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)


Example #5
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)