Unroller Class Confusion?

I am trying to reproduce the UnrollSrf(Label=Yes) command in rhino using the IronPython component in grasshopper.

I am using the functions of Rhino.Geometry.Unroller and dealing with BREP, my code works fine in most parts except one.

For example, I want to unroll a cube. A cube has 12 edges and I put a text dot at the center of each edge using “AddFollowingGeometry(TextDot)”. After unrolling, the unrolled BREPs should have altogether 24 edges, since a cube becomes 6 squares. However, the PerformUnroll function only return 12 text dot instead of 24. Does anyone know why the Text Dot does not follow all edges? Since one edge is split to 2

This picture might explain a little bit more.

Thanks

Hi @TianYing,

The _UnrollSrf command with (Label=Yes) produces exactly the output you show in your screenshot, so it looks to me like you succeeded in replicating it?

The command only doubles up the edges, if you choose Explode=Yes, in your case the edges are still glued together, counting as one

Hi @lando,

Thx for your reply.

Sorry for misrepresenting my statement. My screenshot is the _UnrollSrf’s result not what I replicate. What I replicate, I only have 12 edges with labels for the unrolled surfaces instead of 24. I am not sure why. For example, The picture has 2 edges labeled “2”. When I try to replicate this using “AddFollowingGeometry(TextDot), the text dot only shows up on 1 edge instead of 2.

I add TextDot at the center of edge 2 before unrolling. After unrolling, the textdot should be appear at two places. Howerver, only 1 new textdot is generated.


This is my replicated result

Hi,

I think this is expected behaviour. The unroller -probably- checks the closest face for the dot and unrolls it alongside this face.

I’m not able to test it but I’d try this:
For each 3D edge create a circle perpendicular to an edge at the midpoint. The radius can probably be as small as double the file tolerance.

Intersect this circle with the brep and add the dots to the found intersection points.

Typically each internal edge will get 2 dots, each on another face.

After unrolling -where I expect the dots to unroll as expected- you can pull them to the closest edge but it probably is unneeded for your purpose.

Does this makw sense?

-Willem

Hi,

Thank you very much.

I think this sounds like a brilliant solution.

I only have one problem that is I am not quite sure how to use grasshopper script to do the intersection between a circel and a brep. Do you have an suggestion on how to do that since the rhinno.geometry.intersction api does not have a cricelbrep intersection function.

Thank you very much.

Best

You can convert your circle to a NurbsCurve and use Intersection.CurveBrep

# circle and brep defined elsewhere
bSuccess, crvArrOverlap, ptArrIntersections = Rhino.Geometry.Intersect.Intersection.CurveBrep(circle.ToNurbsCurve(), brep, sc.doc.ModelAbsoluteTolerance)
1 Like

Hi,

Thx for your reply.

I found that for the cube. Only four edge’s middle point circle with radius as 4*tol can return non-empty ptArrIntersections. All the intersect function return bSucess=true. Do you knows why is that?

Thx

Hi,

I suspect you did not create the circles on the plane perpendicular to the edge. But aligned to the WorldXY plane.

I’m on my phone and cannot lookup the exact methods, but what you need to do is:

For each edge get the tangent vector ( TangentAt(t) )where t is the parameter at the mid of the curve.

Next create a plane from a normal with the midpoint of the curve as Origin and the tangent vector as normal.

Next create the circle by passing both the plane and the radius.

Hope this makes sense.
-Willem