Using .ghcomp.RhinoInside in Python to pass elements to Revit

Hello,

@Japhy

I’m trying to use GH components via Python to send geometry to Revit.

When I pass a list of GUIDs through the .AddDirectShapeGeometry() I’m only getting the last item on the list in Revit. How can get the full list of objects through this method?

Also, I can’t seem to get in any objects of Structural Columns.

Please see .3dm attached.

Thanks,

Dan

tester.3dm (3.4 MB)

import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino.DocObjects as rd
import Rhino.Geometry as rg
import System.Drawing as sd
import Rhino
import ghpythonlib.components as ghcomp


x = rs.GetObjects()

for i in x:
    name = rs.ObjectName(i)
    catString = rs.GetUserText(i,"RV-Category")
    print catString
    if catString is None:
        print "This object needs a RV-Category assignment"
    catValue = ghcomp.RhinoInside.QueryCategories("Model",catString)
    print catValue.Name
    if catValue is not None:
        DS = ghcomp.RhinoInside.AddDirectShapeGeometry(name,catValue,i)
        print DS

Is your input set to List access?

What Rhino & Revit version are you using? Where are you setting the scriptContext? Please post the GH file as well. Thanks

@Japhy

Thanks for the reply. I was wanting to make a .py script right in Rhino and not use GH. So in using rs.GetObjects() I’m returning a list of GUIDs.

I’m not sure how to set scriptContext.

I don’t know if I’m going nuts, but this was working yesterday, and is not working today.

I’m getting the error that ghcomp doesn’t have the RhinoInside module anymore. The only instance of Rhino I have running is within Revit (2023).

Is this a workflow that should be possible using the Rhino Python Editor in V7?

Thanks,

Dan

My bad, the script context is only required when running in grasshopper.

You are running inside Revit, correct? The active document context is still required.

I’ll look around for a similar example.

1 Like