コード例 #1
0
# inputs
#   layer  - string naming the layer to address within the current Rhino document
#   gobj   - geometry object to add, either a raw Geometry type or a ghdoc GUID
#   name   - object name string
#  update  - dummy input to force adding again

# outputs
#   out    - console debugging output
#   guid   - GUID strings for the new geometry primitive
#
# 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)

# If needed, find the geometry corresponding with the given input, possibly looking it up by GUID.
item = ghrhinodoc.find_ghdoc_geometry(ghdoc, gobj)
print "Input item is ", item, type(item)

# Add the geometry to the RhinoDoc with the given layer and name.
guid = str(ghrhinodoc.add_geometry(item, layer_index, name))
コード例 #2
0
import ghutil.ghrhinodoc as ghrhinodoc

if update and guids 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)
    newids = list()

    for guid, gobj in zip(guids, gobjs):
        # Look up the object to delete.  Convert from a string to a Guid object, then search the active document.
        guid = System.Guid(guid)
        existing = Rhino.RhinoDoc.ActiveDoc.Objects.Find(guid)
        print "Found RhinoDoc object", existing

        if existing is not None:
            name = existing.Attributes.Name
            print "Existing object has name", name
            # Delete the geometry from the RhinoDoc with the given layer and name.
            Rhino.RhinoDoc.ActiveDoc.Objects.Delete(guid, True)

            # If needed, find the geometry corresponding with the given input, possibly looking it up by GUID.
            item = ghrhinodoc.find_ghdoc_geometry(ghdoc, gobj)
            print "Input item is ", item, type(item)

            # Add the geometry to the RhinoDoc with the given layer and name.
            newids.append(str(ghrhinodoc.add_geometry(item, layer_index,
                                                      name)))

        else:
            # if something goes wrong, make sure the output indicates a null for this object
            newids.append(None)
コード例 #3
0
ファイル: AddGeometry.py プロジェクト: cmuphyscomp/hmv-s16
#   names  - list of object name strings
# enabled  - Boolean to indicate the action is enabled
#
# Note: gobjs and names must be set to 'List Access'
#
# outputs
#   out    - console debugging output
#   guids  - list of GUID strings for the new geometry primitive
#
# 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.
if enabled:
    layer_name = str(layer)
    layer_index = ghrhinodoc.fetch_or_create_layer_index(layer_name)
    guids = list()
    
    for gobj, name in zip(gobjs, names):
        # If needed, find the geometry corresponding with the given input, possibly looking it up by GUID.
        item = ghrhinodoc.find_ghdoc_geometry(ghdoc, gobj)

        # Add the geometry to the RhinoDoc with the given layer and name, returning the new RhinoDoc GUID as a string.
        guids.append(str(ghrhinodoc.add_geometry(item, layer_index, name)))
コード例 #4
0
ファイル: CreateCutSht.py プロジェクト: cmuphyscomp/hmv-s16
# 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)


コード例 #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)