[Question] HiddenLineDrawing

Hi @GregArden,

I have a question regarding the class HiddenLineDrawing.

I understand you have to use a viewport for the calculation and not a simple plane because plane doesn’t hold enough information. Could you please break down a bit more? What kind of information is required? Can I substitute the view port by a plane and several vectors?

Thanks in advance.

This creates an ‘artificial’ viewport - it’s not added to the document - but you can then use it for the HiddenLineDrawing calculation:

    #artificially set a top view projection
    #variable ht is some arbitrary number

HTH, --Mitch

1 Like

Thanks a lot Mitch.

The requirement for a ON_Viewport is really to handle perspective views. For a perspective view we clearly need the camera location, but also we use the view frustum ( left, right, top and bottom edges of the view for clipping). This is in contrast to a parallel projection where there are no clipping planes by default. Also for a perspective view, the target point is used, rather subtlely, to define the scale of the output which in turn defines the interpretation of the tolerance setting.

So bottom line there is a lot more information needed by Make2d for a perspective view projection.

That is why ON_HiddenLineDrawing has a
SetParallelViewport( ON_3dVector CameraDirection, ON_3dVector CameraUp)
method that allows the view information to be determined by two orthogonal vectors .

Thanks for the reply @GregArden,

I cannot see SetParallelViewport in RhinoCommon. What is its counterpart there? Can I use any two vector3d to define the arguments or they must come from a camera?

I assume the CameraUp vector will define how the result is rotated about WorldZ axis, is that right?

Hi @ivelin.peychev, try viewport.ChangeToParallelProjection(True)


Thanks Clement, but that’s really not what I’m looking for.
I need to be able to use an arbitrary plane for HiddenLineDrawing

I think what Mitch shared above is the current way to go. I need to test it a bit when I find time.

Hi @ivelin.peychev,

instead of an existing viewport, you can pass Rhino.DocObjects.ViewportInfo to the hidden line drawing parameters. You might try setting that up with the required values first eg:

# create new vp info
viewport_info = Rhino.DocObjects.ViewportInfo()
viewport_info.IsParallelProjection = True

# set camera properties

hld_params = Rhino.Geometry.HiddenLineDrawingParameters()


@dale Could we get ON_HiddenLineDrawing::SetParallelViewport added to Rhino Common.
Seems like it belongs on HiddenLineDrawingParameters as a overload of SetViewport(…) ?

1 Like

@GregArden - sure, just make me a YT item.

– Dale