When I use HiddenLineDrawing.Compute to calculate contour lines for complex surfaces in Rhinoceros, I find that there are some missing lines, how can I solve this problem?
This is the original model.
Here are the calculations.
When I use HiddenLineDrawing.Compute to calculate contour lines for complex surfaces in Rhinoceros, I find that there are some missing lines, how can I solve this problem?
This is the original model.
Ps: I’ve tried expanding or reducing the AbsoluteTolerance in the HiddenLineDrawingParameters, but to no avail!
Please, if possible, share your 3dm file and your code.
this is my model
This is the code I found from the official case
using System;
using Rhino;
using Rhino.Commands;
using Rhino.DocObjects;
using Rhino.Geometry;
using Rhino.Input.Custom;
namespace PythonToCSharp.PythonToCSharp
{
public class FMake2D : Command
{
public FMake2D()
{
Instance = this;
}
///<summary>The only instance of the MyCommand command.</summary>
public static FMake2D Instance { get; private set; }
public override string EnglishName => "FMake2D";
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
var go = new GetObject();
go.SetCommandPrompt("Select objects to test Make2D Points");
go.GeometryFilter = ObjectType.Point | ObjectType.Surface | ObjectType.PolysrfFilter;
go.GroupSelect = true;
go.GetMultiple(1, 0);
if (go.CommandResult() != Result.Success)
return go.CommandResult();
var obj_refs = go.Objects();
var view = doc.Views.ActiveView;
if (null == view)
return Result.Failure;
var hld_params = new HiddenLineDrawingParameters
{
AbsoluteTolerance = doc.ModelAbsoluteTolerance,
IncludeTangentEdges = false,
IncludeHiddenCurves = true
};
hld_params.SetViewport(view.ActiveViewport);
foreach (var obj_ref in obj_refs)
{
var obj = obj_ref?.Object();
if (obj != null)
hld_params.AddGeometry(obj.Geometry, Transform.Identity, obj.Id);
}
var hld = HiddenLineDrawing.Compute(hld_params, true);
if (hld != null)
{
var flatten = Transform.PlanarProjection(Plane.WorldXY);
BoundingBox page_box = hld.BoundingBox(true);
var delta_2d = new Vector2d(0, 0);
delta_2d = delta_2d - new Vector2d(page_box.Min.X, page_box.Min.Y);
var delta_3d = Transform.Translation(new Vector3d(delta_2d.X, delta_2d.Y, 0.0));
flatten = delta_3d * flatten;
var h_attribs = new ObjectAttributes { Name = "H" };
h_attribs.Visible = false ;
var v_attribs = new ObjectAttributes { Name = "V" };
foreach (var hld_curve in hld.Segments)
{
if (hld_curve?.ParentCurve == null || hld_curve.ParentCurve.SilhouetteType == SilhouetteType.None)
continue;
var crv = hld_curve.CurveGeometry.DuplicateCurve();
if (crv != null)
{
crv.Transform(flatten);
switch (hld_curve.SegmentVisibility)
{
case HiddenLineDrawingSegment.Visibility.Visible:
doc.Objects.AddCurve(crv, v_attribs);
break;
case HiddenLineDrawingSegment.Visibility.Hidden:
doc.Objects.AddCurve(crv, h_attribs);
break;
}
}
}
foreach (var hld_pt in hld.Points)
{
if (hld_pt == null)
continue;
var pt = hld_pt.Location;
if (pt.IsValid)
{
pt.Transform(flatten);
switch (hld_pt.PointVisibility)
{
case HiddenLineDrawingPoint.Visibility.Visible:
doc.Objects.AddPoint(pt, v_attribs);
break;
case HiddenLineDrawingPoint.Visibility.Hidden:
doc.Objects.AddPoint(pt, h_attribs);
break;
}
}
}
}
doc.Views.Redraw();
return Result.Success;
}
}
}
Looks like the Rhino Make2D command has the same problem. This seems to be a shortcoming for Make2D; you should report this to the McNeel staff.
I don’t know who is suitable for reporting.Could you please give me some advice?
then look for e-mail support. In my case I see tech.eu@mcneel.com as the mail address for this; in de US the mail address may be tech@mcneel.com I’m not sure.
Another option is to tag @dale to see if this issue can be looked at by McNeel staff.
Ok,thank you!
Hi Fan -
The file that you posted is in the Rhino 5 format but that’s, perhaps, not the version you tested this with?
At any rate, it looks like Rhino 8 does a somewhat better job:
I’ve put the issue around your right arrow on the list as
RH-76994 Make2D: Silhouette failure
-wim
While creating a Grasshopper plugin I noticed that some solid breps are missing a curve segment if you only want Silhouette contour (boundary) lines.
Below is a screenshot of 3 breps. The breps are imported from a step file generated by Fusion360. The 3 parts are the same, but two of the 3 breps are missing a line segment:
I put some of the plugin’s code in a grasshopper script for testing:
MissingSegment.gh (7.4 KB)
MissingSegment.3dm (393.0 KB)
I use Rhino 8
Is this the same bug as above, or am I missing something?
This is the version I’m using now:
So the problem is not the C# script in the grasshopper file that I added as an attachment?
I just installed the latest version of rhino 8. At first it seemed that I was not getting a closed contour after all. When I started baking the curves, I received a message that not all lines were valid.
I found out that if I change my script to:
So the problem is solved for this script, but if you look at the:
“segment.ParentCurve.SilhouetteType == SilhouetteType.Boundary” property, then you get all line segments that overlaps each other. This was not the case in the previous rhino version. But perhaps this is a normal result for the ParentCurve.SilhouetteType property.
In any case, thanks for the response.