Easiest method to convert PolyLine2d to Wpf Shape

1
muratcam1989
3/18/2020 6:30 AM

Hello,

My target is to open a 2d dxf and extract the data from it and use it to draw it in Wpf Viewport3D so I can extrude and add other shapes to the drawing and view it in 3d.

Method 1 - I considered using WireframeGraphicsFactory and I managed to get the PolyLine2d objects.
Method 2 - Getting all Entities from the model and using the entities to draw it again with the entity data depending on Entity type.


I understand from other posts Method 1 is the easiest way and that PolyLine2d also includes data for arcs but How can I understand if its an arc or a straight line for seperating it in Wpf drawing. I managed to get the points of the vertexes but this data is not enough to create arcs.

So Im in desperate need for your advice.

Thank you so much in advance.

Wout
3/18/2020 10:14 AM

Hi,

For 2D polylines, each vertex has a Bulge property, which defines the curvature of the arc. See the documentation for more details.

You can get the arc center of the arc by passing 2 vertex positions and the bulge value to method DxfVertex2D.GetArcCenterFromEndPointsAndBulge(Point2D arcStart, Point2D arcEnd, double bulge).

You probably have to implement your own rendering in your case, I don't see how CadLib's rendering can be used, since it renders everything to flat 3D polylines (arcs are converted to polylines).

- Wout

muratcam1989
3/18/2020 12:33 PM

The 2DPolyLine that is aquired from WireFrameGraphics doesnt have a Bulge property.

Only 2 points. I guess Ill have to use DxfEntity.Polyline for my cause.

Thank you.

1