Extrude a polygon

Technical discussions
Post Reply
Carlos
Posts: 2
Joined: Wed Jan 02, 2019 11:49 pm

Extrude a polygon

Post by Carlos »

Hi
I am looking for a way to create at runtime a compass needle/3D pointer. I need just make a straight lines polygon thick with some height. Can you suggest a way?
I am using dg kernel with C#
Thank you

Prashant Kande
Posts: 121
Joined: Mon Apr 04, 2016 4:55 am

Re: Extrude a polygon

Post by Prashant Kande »

Hello Carlos
Try something like this:

Code: Select all

IObjectGenerator_DG iGener = iModel;

double S = 500;	//Size
double h = 50;	// Thickness

IPointArray_DG points = iGener.Create("PointArray_DG");

// Define the polygon
points.SetCount(7);
points.SetPoint1(0, S, 0, 0);
points.SetPoint1(1, 0.4*S, 0.4*S, 0);
points.SetPoint1(2, 0.5*S, 0.2*S, 0);
points.SetPoint1(3, -S, 0.2*S, 0);
points.SetPoint1(4, -S, -0.2*S, 0);
points.SetPoint1(5, 0.5*S, -0.2*S, 0);
points.SetPoint1(6, 0.4*S, -0.4*S, 0);

IBRepBuilder_DG iBuilder = iGener.Create("BRepBuilder_DG");
IBRepWire_DG iWire = iBuilder.CreateWire3(points, true);

IBRepShape_DG iShape = iGener.Create1("BRepFace_DG", iWire);

IBRepBuilderEx_DG iBuilderEx = iGener.Create("BRepBuilderEx_DG");

VectDg vExtrusion( 0, 0, h );
IBRepShape_DG iShapeExtruded = iBuilderEx.Extrude(iShape, vExtrusion);

IEntity_DG entity = iModel.AddBRepShape(iShapeExtruded);
entity.SetColor(1, 0, 0);
Regards

Carlos
Posts: 2
Joined: Wed Jan 02, 2019 11:49 pm

Re: Extrude a polygon

Post by Carlos »

This would do fine
Thank You, Prashant

Post Reply