algorithmic modeling for Rhino
# importing relevant modules
import rhinoscriptsyntax as rs
import Rhino
import scriptcontext as sc
# switch to gh document
sc.doc = "FitCrv.py"
# obtain object id (Instance GUID?)
obj_id = "5978a9d6-bdbe-4074-a080-711245f43ff1"
# change to rhino object
doc_obj = rs.coercerhinoobject(obj_id)
# set object attr and geom
attributes = doc_obj.Attributes
geometry = doc_obj.Geometry
# change to Rhino doc
sc.doc = Rhino.RhinoDoc.ActiveDoc
# add geom to Rhino
rhino_obj = sc.doc.Objects.Add(geometry, attributes)
This does not work. What am I doing wrong at the moment?
Tags:
Replies are closed for this discussion.
Hey Luc,
The following works:
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
sc.doc = ghdoc
#get object id from grasshopper
obj_id = x
#convert grasshopper object into rhino object
doc_obj = rs.coercerhinoobject(obj_id)
#make attributes and geometry from rhino object
attributes = doc_obj.Attributes
geometry = doc_obj.Geometry
#go rhino document
sc.doc = Rhino.RhinoDoc.ActiveDoc
#bake object with attributes
rhino_obj = sc.doc.Objects.Add(geometry, attributes)
rs.ObjectColor(rhino_obj, y)
#back to gh
sc.doc = ghdoc
correct me if im wrong but I think assigning sc.doc to a str is not what you want..from what I understand you either target the ActiveRhinoDoc or the ghdoc.
then I dont understand why you want to feed a GUID into obj_id manually. Are you using objects that GH does not recognize? Plus you dont need to make it a str since GUID is a type..
GH deals with pure geometry objects so you wouldnt be able to get the GUID. If you reference geometry from the Rhino doc then you are able to get the GUID via the GUID component but that means you already have the geometry in the rhinoDoc..
What are you trying to do?
is the attached ok?
...ok cool
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by