Page 1 of 1

Extrude a polygon

Posted: Wed Jan 02, 2019 11:55 pm
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

Re: Extrude a polygon

Posted: Sat Jan 05, 2019 5:04 am
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

Re: Extrude a polygon

Posted: Mon Jan 07, 2019 12:05 am
by Carlos
This would do fine
Thank You, Prashant