Rhino.Geometry.Brep does not want to convert to readable Brep

Hi everyone!

I was just trying to write a script in CPython to create a miter edge between two beams (2 closed Breps).

Everything works (I think) but somehow the script refuses to see the ‘closed brep’ as a ‘brep’? The only working script I got gives me this as output: Rhino.Geometry.Brep but once I try to wrap it so another component is able to recognise it in grasshopper it breaks.

I have x and y as inputs (the breps) on item acces and type hint on Brep.

This is the script that works:
import Rhino.Geometry as rg

# 1. BoundingBox ophalen

box_a = x.GetBoundingBox(True)

box_b = y.GetBoundingBox(True)

# 2. Overlap berekenen

min_x = max(box_a.Min.X, box_b.Min.X)

max_x = min(box_a.Max.X, box_b.Max.X)

min_y = max(box_a.Min.Y, box_b.Min.Y)

max_y = min(box_a.Max.Y, box_b.Max.Y)

z_min = min(box_a.Min.Z, box_b.Min.Z)

# 3. Miter Punten

p1 = rg.Point3d(min_x, max_y, z_min)

p2 = rg.Point3d(max_x, min_y, z_min)

# — BALK A —

pts_a = [

rg.Point3d(box_a.Min.X, box_a.Min.Y, z_min),

p2, p1,

rg.Point3d(box_a.Min.X, box_a.Max.Y, z_min),

rg.Point3d(box_a.Min.X, box_a.Min.Y, z_min)

]

curve_a = rg.PolylineCurve(pts_a)

# We maken een Brep direct via Extrusion

brep_a = rg.Extrusion.Create(curve_a, box_a.Max.Z - box_a.Min.Z, True).ToBrep()

brep_a.Translate(rg.Vector3d(0, 0, box_a.Min.Z - z_min))

# — BALK B —

pts_b = [

p2,

rg.Point3d(box_b.Max.X, box_b.Max.Y, z_min),

rg.Point3d(box_b.Min.X, box_b.Max.Y, z_min),

p1, p2

]

curve_b = rg.PolylineCurve(pts_b)

brep_b = rg.Extrusion.Create(curve_b, box_b.Max.Z - box_b.Min.Z, True).ToBrep()

brep_b.Translate(rg.Vector3d(0, 0, box_b.Min.Z - z_min))

# — DE OUTPUT —

a = [brep_a]

b = [brep_b]

This one doesn’t:
import Rhino.Geometry as rg

import Rhino

import Grasshopper

# Importeer de Brep wrapper (net als GH_Material)

from Grasshopper.Kernel.Types import GH_Brep

# 1. BoundingBox ophalen

box_a = x.GetBoundingBox(True)

box_b = y.GetBoundingBox(True)

# 2. Overlap berekenen

min_x = max(box_a.Min.X, box_b.Min.X)

max_x = min(box_a.Max.X, box_b.Max.X)

min_y = max(box_a.Min.Y, box_b.Min.Y)

max_y = min(box_a.Max.Y, box_b.Max.Y)

z_min = min(box_a.Min.Z, box_b.Min.Z)

# 3. Miter Punten

p1 = rg.Point3d(min_x, max_y, z_min)

p2 = rg.Point3d(max_x, min_y, z_min)

# — BALK A —

pts_a = [

rg.Point3d(box_a.Min.X, box_a.Min.Y, z_min),

p2, p1,

rg.Point3d(box_a.Min.X, box_a.Max.Y, z_min),

rg.Point3d(box_a.Min.X, box_a.Min.Y, z_min)

]

curve_a = rg.PolylineCurve(pts_a)

# We maken een Brep direct via Extrusion

brep_a = rg.Extrusion.Create(curve_a, box_a.Max.Z - box_a.Min.Z, True).ToBrep()

brep_a.Translate(rg.Vector3d(0, 0, box_a.Min.Z - z_min))

# — BALK B —

pts_b = [

p2,

rg.Point3d(box_b.Max.X, box_b.Max.Y, z_min),

rg.Point3d(box_b.Min.X, box_b.Max.Y, z_min),

p1, p2

]

curve_b = rg.PolylineCurve(pts_b)

brep_b = rg.Extrusion.Create(curve_b, box_b.Max.Z - box_b.Min.Z, True).ToBrep()

brep_b.Translate(rg.Vector3d(0, 0, box_b.Min.Z - z_min))

# — DE OUTPUT —

if isinstance(brep_a, Rhino.Geometry.Brep):

a = GH_Brep(brep_a)

if isinstance(brep_b, Rhino.Geometry.Brep):

b = GH_Brep(brep_b)

It gives me this error: TypeError: Rhino.Geometry.Brep value cannot be converted to Rhino.Geometry.Brep in method Void .ctor(Rhino.Geometry.Brep)

I have a similar code for rhino matrials that does still work:

if isinstance(item, Rhino.Display.DisplayMaterial):

item = GH_Material(item)

What am I doing wrong here?

Can you post a simple gh file with these scripts and internalized geometry to show what’s not working?

Yes of course! Thank you for your help!

And a little thing I forgot to mention, I am working with Rhino.inside.revit. Which seems to be the thing messing something up because when I opened it in Rhino itself to single out the piece of the gh script it ‘worked’. I didn’t get the miter corner I wanted but at least it gave me the brep output, so its possible it’s something to do with Revit.

This is the ‘wokring’ script in Rhino.inside.Revit

This in Rhino itself:

Here’s the gh script itself:

test.gh (12.3 KB)

Am I in the right place for this or is there maybe another place to look for since it is about Rhino.inside.revit? Or does anyone know what might be causing this?

Thanks. I’m not familiar with Rhino.inside.revit, so I’m not sure why this isn’t working. I wonder if you can get the script to output the curve and height and use grasshopper components to extrude the brep?

Hi Elisa, not seeing the issue here. What is your Rhino.Inside.Revit about info?

Hi Jahpy! Here is my about info:

Hi Measure!

I tried something similar to what you suggested, but it seems like there is just something off with my rhino.inside.revit as it seems to have trouble recognizing types of geometry. I got this error while trying:

*Rhino.Geometry.Point3d value cannot be converted to Rhino.Geometry.Point3d in method Void .ctor(Rhino.Geometry.Point3d, Rhino.Geometry.Point3d)
*
Again it worked fine in Rhino/ Grasshopper itself.

And if you’re interested, I managed to clean up/change the script in rhino itself to get the miter edge I wanted with this script:

test.gh (14.9 KB)

It’s just not working in rhino.inside.revit for me unfortunately.

I think I found the problem. I had two versions of .dll’s running because of a plugin called pyrevit. Rhino using RhinoCommon and Revit using Rhino3dmOne. One of them also running on the .NET 8 framework the other on .NET 4.8 framework.

Fixed it with the following steps:

  1. In the rhino commandline typed: SetDotNetRuntime
  2. Then changed runtime to from NETcore to NETframework (chaning to .NET 4.8 for both)
  3. And this might be a quick fix breaking my pyrevit plugin :sweat_smile: but I simply renamed the rhino3dmone.dll file in the pyrevit map to rhino3dmone.dll.old
  4. Then restarted Rhino and Revit

And that seemed to fix things. Now both are using the same RhinoCommon.dll again with the same .NET version.

Thanks to everyone for helping out!

1 Like