Draw Silhouette of solid object on a given plane

Hi,
I am wondering if its is possible to do what Make2d command does in Rhino from C#. I need to extract the outline (silhouette) of a solid object on a given plane. I get very closed to this using
HiddenLineDrawing
but the result is not satisfactory as you can see in the screenshot. Any idea?

Fixing these is not nuclear science … but why bother? See Plan B:

Brep_ToPlane_EntryLevel_V1.3dm (309.8 KB)

Brep_ToPlane_EntryLevel_V1.gh (118.4 KB)

BTW: Elaborate more on that: provide various options for the proj plane (maybe using a BBox and the derived planes) and/or visualize the plane and/or follow a circle around the buildings (for the orig pt) and/or create shadows and/or … etc etc.

1 Like

Thansk Peter, for me the M.GetOutlines() always return null , until I set the param.SimplePlanes = true in MeshingParameters . the issue is now that all curves are converted to polyline as result of converting brep to mesh. I am developing a tool for machine milling that needs to identify the outline of the object in order to cut it from a raw part. this looks to a solution as I am not so keen to make it perfect ( at the end it is a raw cut) . but I am not sure how stable is the M.GetOutlines() method . Before your post I end up extracting outer loop of each face in solid and project them to the plane and finally create boolean union from them. This also works but boolean operations are not my favorite :wink:

Well … if you don’t want Polylines in your party then indeed converting Breps to Meshes doesn’t sound as the Holly Grail of things. BTW: the loop approach is the long way home (and slow as well) - and is several million miles away from some sort of true HLR (Hidden Line Removal).

Anyway: out of curiosity (related with the Outlines thingy) can you post (in R5 format) some test data where that one yields bananas?

Hi Peter,
I did a bit of fine tuning around the Brep to Mesh conversion as my objects are normally milled from a planar piece of wood. so far the following gives out the best result,

private Polyline getSilouhette(Brep brep,Plane plane)
        {

            MeshingParameters mp = new MeshingParameters();
            // the below settings may need to be changed as per results 
            mp.ComputeCurvature = false;
            mp.SimplePlanes = true;             
            mp.GridAmplification = 0;
            mp.GridAngle = 0;
            mp.GridAspectRatio = 0;
            mp.GridMaxCount = 0;
            mp.GridMinCount = 0;
            mp.MaximumEdgeLength = 0;
            mp.MinimumEdgeLength = 0;

            Mesh M = new Mesh();
            Mesh[] meshes =Mesh.CreateFromBrep(brep, mp);
            foreach (Mesh mesh in meshes) M.Append(mesh);
            M.Vertices.CombineIdentical(true, true);
            M.UnifyNormals();
            M.Compact();

            Polyline[] pl = M.GetOutlines(plane);


            if (pl==null || pl.Length!=1)
            {
                return null;
            }
            return pl[0];
        }

however this is only good when I am dealing with polyhedric objects, once I change to objects with smooth boundaries then making polyline are not desirable because of CNC or Robot likes to move smoothly rather than jumping from one line segment to another, I can also think of making a tiny fillet (anyhow corner smoothing is what we usually do in other CAM software) to overcome this problem, I attached some test example in R5. thanks again for your prompt feedback, finding outerloop on XY plane.3dm (833.9 KB)

I’ll test your stuff soon.

In the mean time given an outline Polyline is easy to detect if a given “portion” in the range of points is “in line” (thus getting the first and last) or not (thus attempting to get an interpolated Crv). But … well … indeed … this B > M > Outlines() > NurbsCrvs/LineCrvs > BrepFace(s)/Polycurve(s) approach is kinda flying from DC to NY via LA.

BTW: Your test Breps yield 100% working Outlines (as in the C# provited above - nothing changed). Either you are using some later to R5 build (with probably some issue on that Method) or is a Karma related thingy (in this case quit the game + abandon ship + adios amigos).

1 Like

Note: this would prevent extracting Outlines of a Brep with holes (if the projection is suitable).

1 Like

Yes , you are right
I need to extract the holes that are bigger than a threshold , thanks for the note

Strange ! For me it worked only after changing meshing parameters, I am using rhino 7
Cheers

For the type of work (solely AEC/BIM things) that is done in my practice post R5 builds are not required (R/GH play a very small role, mind [if any at all]).

BTW: As Plan C … you can attempt to do a PolyCurve out of the Polyline (a bit tricky in places). Like this (contolled by 2 filter angles - one for what an “in-line” sub collection is and one for if a sub collection defines a segment crv [interpolated or via cntrl pts]):



1 Like

Looks interesting! I developed something similar, is there a chance to have a look at your C# script?

BTW I am very close to mark your answer as solution :grinning:

I did this long time ago (for very specific purposes) … thus it needs some checks more [general case: any open/closed Polyline] an/or maybe a shift in the approach using a custom Class with suitable for the scope properties (angles on a per Node basis). Anyway I’ll be back in the practice tomorrow and if time permits I’ll add a thing or two.