本文整理汇总了C#中Polyline.AddVertexAt方法的典型用法代码示例。如果您正苦于以下问题:C# Polyline.AddVertexAt方法的具体用法?C# Polyline.AddVertexAt怎么用?C# Polyline.AddVertexAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Polyline
的用法示例。
在下文中一共展示了Polyline.AddVertexAt方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Create
public void Create(BlockTableRecord btrPanel, Transaction t)
{
Polyline plContour = new Polyline();
plContour.LayerId = panelBase.Service.Env.IdLayerContourPanel;
// Определение подрезок и пустот
defineUndercuts();
// Outsides - части сторон панели без плитки - заходит под торец другой угловой панели
addOutsides(btrPanel, t);
definePtsLeftSide();
definePtsTopSide();
definePtsRightSide();
definePtsBotSide();
int i = 0;
ptsLeftSide.ForEach(p => plContour.AddVertexAt(i++, p, 0, 0, 0));
ptsTopSide.ForEach(p => plContour.AddVertexAt(i++, p, 0, 0, 0));
ptsRightSide.ForEach(p => plContour.AddVertexAt(i++, p, 0, 0, 0));
ptsBotSide.ForEach(p => plContour.AddVertexAt(i++, p, 0, 0, 0));
plContour.Closed = true;
btrPanel.AppendEntity(plContour);
t.AddNewlyCreatedDBObject(plContour, true);
}
示例2: ExtrudedSolidCommand
public void ExtrudedSolidCommand()
{
var document = Application.DocumentManager.MdiActiveDocument;
if (document == null) // don't bother doing anything else
return;
using (var polyline = new Polyline())
{
var extrudedSquareInputResult = GetExtrusionInputFromUser();
// convenience variables
var width = extrudedSquareInputResult.Width;
var height = extrudedSquareInputResult.Height;
var depth = extrudedSquareInputResult.Depth;
// Using the polyline, we add vertices based on the user's input
polyline.AddVertexAt(0, Point2d.Origin, 0.0, 0.0, 0.0);
polyline.AddVertexAt(1, new Point2d(width, 0.0), 0.0, 0.0, 0.0);
polyline.AddVertexAt(2, new Point2d(width, height), 0.0, 0.0, 0.0);
polyline.AddVertexAt(3, new Point2d(0.0, height), 0.0, 0.0, 0.0);
polyline.Closed = true;
// add polyline to DBObjectCollection for us in creating region from curves
using (var dbObjectCollection = new DBObjectCollection { polyline })
{
using (var regionCollection = Region.CreateFromCurves(dbObjectCollection))
{
using (var region = (Region)regionCollection[0])
{
using (var solid = new Solid3d())
{
// extrude the region to the depth the user specified
solid.Extrude(region, depth, 0.0);
using (document.LockDocument())
{
using (var database = document.Database)
{
using (var transaction = database.TransactionManager.StartTransaction())
{
// get the current space for appending our extruded solid
using (var currentSpace = (BlockTableRecord)transaction.GetObject(database.CurrentSpaceId, OpenMode.ForWrite))
{
currentSpace.AppendEntity(solid);
}
transaction.AddNewlyCreatedDBObject(solid, true);
transaction.Commit();
}
}
}
}
}
}
}
}
}
示例3: ProjectExtents
/// <summary>
/// Creates a new Polyline that is the result of projecting the transformed MinPoint and MaxPoint of 'extents'
/// parallel to 'direction' onto 'plane' and returns it.
/// </summary>
/// <param name="extents">The Extents3d of a transformed from World to dirPlane Polyline.</param>
/// <param name="plane">The plane onto which the points are to be projected.</param>
/// <param name="direction">Direction (in WCS coordinates) of the projection</param>
/// <param name="dirPlane">The plane which origin is 0, 0, 0 and 'direction' is the normal.</param>
/// <returns>The newly created Polyline.</returns>
internal static Polyline ProjectExtents(Extents3d extents, Plane plane, Vector3d direction, Plane dirPlane)
{
Point3d pt1 = extents.MinPoint.TransformBy(Matrix3d.PlaneToWorld(dirPlane));
Point3d pt2 = extents.MaxPoint.TransformBy(Matrix3d.PlaneToWorld(dirPlane));
Polyline projectedPline = new Polyline(2);
projectedPline.AddVertexAt(0, pt1.Project(plane, direction).Convert2d(), 0.0, 0.0, 0.0);
projectedPline.AddVertexAt(1, pt2.Project(plane, direction).Convert2d(), 0.0, 0.0, 0.0);
return projectedPline;
}
示例4: GetPolyline
public static Polyline GetPolyline(this Extents3d ext)
{
var pl = new Polyline();
pl.AddVertexAt(0, ext.MinPoint.Convert2d(), 0, 0, 0);
pl.AddVertexAt(1, new Point2d (ext.MinPoint.X, ext.MaxPoint.Y) , 0, 0, 0);
pl.AddVertexAt(2, ext.MaxPoint.Convert2d(), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(ext.MaxPoint.X, ext.MinPoint.Y), 0, 0, 0);
pl.Closed = true;
return pl;
}
示例5: Sierpinski
public Sierpinski(Point2d a, Point2d b, Point2d c)
{
Triangle = new Polyline();
A = a;
B = b;
C = c;
this.Size = B.GetDistanceTo(A);
Triangle.AddVertexAt(0, A, 0, 0, 0);
Triangle.AddVertexAt(1, B, 0, 0, 0);
Triangle.AddVertexAt(2, C, 0, 0, 0);
Triangle.Closed = true;
depth = 0;
}
示例6: Create
public void Create(Point2d ptCell, BlockTableRecord cs, Transaction t)
{
var cellWidth = ColorBookHelper.CellWidth;
var cellHeight = ColorBookHelper.CellHeight;
var margin = ColorBookHelper.Margin;
var marginHalf = margin * 0.5;
Point3d ptText = new Point3d(ptCell.X + cellWidth * 0.5, ptCell.Y - ColorBookHelper.TextHeight-margin, 0);
Polyline pl = new Polyline(4);
pl.AddVertexAt(0, new Point2d(ptCell.X+margin, ptText.Y- marginHalf), 0, 0, 0);
pl.AddVertexAt(1, new Point2d(ptCell.X+cellWidth- margin, ptText.Y- marginHalf), 0, 0, 0);
pl.AddVertexAt(2, new Point2d(ptCell.X + cellWidth-margin, ptCell.Y-cellHeight+margin), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(ptCell.X+margin, ptCell.Y - cellHeight+margin), 0, 0, 0);
pl.Closed = true;
pl.SetDatabaseDefaults();
pl.Color = Color;
cs.AppendEntity(pl);
t.AddNewlyCreatedDBObject(pl, true);
Hatch h = new Hatch();
h.SetDatabaseDefaults();
h.SetHatchPattern(HatchPatternType.PreDefined, "Solid");
h.Annotative = AnnotativeStates.False;
cs.AppendEntity(h);
t.AddNewlyCreatedDBObject(h, true);
h.Associative = true;
h.AppendLoop(HatchLoopTypes.Default, new ObjectIdCollection(new[] { pl.Id }));
h.Color = Color;
h.EvaluateHatch(true);
DBText text = new DBText();
text.SetDatabaseDefaults();
text.HorizontalMode = TextHorizontalMode.TextCenter;
text.Annotative = AnnotativeStates.False;
text.Height = ColorBookHelper.TextHeight;
text.AlignmentPoint = ptText;
text.AdjustAlignment(cs.Database);
text.TextStyleId = ColorBookHelper.IdTextStylePik;
text.TextString = Name;
cs.AppendEntity(text);
t.AddNewlyCreatedDBObject(text, true);
}
示例7: CreatePolyline
/// <summary>
/// Creates a Polyline with default settings (layer, color, etc.) with the specified vertices.
/// Only the X and Y coordinates are taken into account, width is zero, and no bulges are added.
/// </summary>
/// <param name="vertices">Vertices that will compose the polyline.</param>
public static Polyline CreatePolyline(Point3dCollection vertices)
{
Polyline polyline = new Polyline();
polyline.SetDatabaseDefaults();
for (int i = 0; i < vertices.Count; i++)
{
polyline.AddVertexAt(i, new Point2d(vertices[i].X, vertices[i].Y), 0, 0, 0);
}
return polyline;
}
示例8: GetDistance
// Get distance between two user selected points.
public Double GetDistance()
{
Double dist = 0;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
//Prompt for user selection of points to calculate distance.
PromptPointResult ppr;
Point2dCollection colPt = new Point2dCollection();
PromptPointOptions ppo = new PromptPointOptions("");
//Prompt for first point
ppo.Message = "\nSpecify mid of Leftmost Rack: ";
ppr = ed.GetPoint(ppo);
colPt.Add(new Point2d(ppr.Value.X, ppr.Value.Y));
//Exit if the user presses ESC or cancels cmd
if (ppr.Status == PromptStatus.Cancel) return 0;
int count = 1;
while (count <= 2)
{
//Prompt for next points
switch (count)
{
case 1:
ppo.Message = "\nSpecify mid of Center Rack: ";
break;
case 2:
ppo.Message = "\nSpecify mid of Rightmost Rack: ";
break;
}
//use the previous point as the base point
ppo.UseBasePoint = true;
ppo.BasePoint = ppr.Value;
ppr = ed.GetPoint(ppo);
colPt.Add(new Point2d(ppr.Value.X, ppr.Value.Y));
if (ppr.Status == PromptStatus.Cancel) return 0;
//Increment
count = count + 1;
}
//Create the polyline
using (Polyline acPoly = new Polyline())
{
acPoly.AddVertexAt(0, colPt[0], 0, 0, 0);
acPoly.AddVertexAt(1, colPt[1], 0, 0, 0);
acPoly.AddVertexAt(2, colPt[2], 0, 0, 0);
//Don't close polyline
acPoly.Closed = false;
//Query the length
dist = acPoly.Length;
}//Dispose of polyline.
return dist; //returns the value of the distance.
}
示例9: GetOffsetPolyline
public static Polyline GetOffsetPolyline(Polyline line, bool IsLeftComp, double r)
{
Polyline newLine = new Polyline();
double offsetValue = (IsLeftComp) ? -r : r;
for (int i = 1; i <= line.NumberOfVertices - 1; i++)
{
Polyline pl1 = new Polyline();
pl1.AddVertexAt(0, line.GetPoint2dAt(i - 1), line.GetBulgeAt(i - 1), 0, 0);
pl1.AddVertexAt(1, line.GetPoint2dAt(i), line.GetBulgeAt(i), 0, 0);
Polyline pl1Offset = pl1.GetOffsetCurves(offsetValue)[0] as Polyline;
AddToDrawing(pl1Offset);//debug
if (i == 1)//第一点,且当前曲线并不是封闭的
{
newLine.AddVertexAt(0, new Point2d(pl1Offset.StartPoint.X, pl1Offset.StartPoint.Y), 0, 0, 0);
if (line.NumberOfVertices == 2)//如果只是一条线的话
{
newLine.AddVertexAt(0, new Point2d(pl1Offset.EndPoint.X, pl1Offset.EndPoint.Y), -pl1Offset.GetBulgeAt(0), 0, 0);
}
}
if (line.NumberOfVertices > 2 && i < line.NumberOfVertices - 1)
{
Polyline pl2 = new Polyline();
pl2.AddVertexAt(0, line.GetPoint2dAt(i), line.GetBulgeAt(i), 0, 0);
pl2.AddVertexAt(1, line.GetPoint2dAt(i + 1), line.GetBulgeAt(i + 1), 0, 0);
Polyline pl2Offset = pl2.GetOffsetCurves(offsetValue)[0] as Polyline;
AddToDrawing(pl2Offset);//debug
//两个偏移后的Polyline进行相交
Point3dCollection points = new Point3dCollection();
pl2Offset.IntersectWith(pl1Offset, Intersect.ExtendBoth, points, IntPtr.Zero, IntPtr.Zero);
Point2d TheIntersectPoint;
if (points.Count == 0)
{
//无交点,只存在于两个在同一根直线上的情况
//或者同一个圆上
newLine.AddVertexAt(0, pl1Offset.GetPoint2dAt(1), -pl1Offset.GetBulgeAt(1), 0, 0);
continue;
}
else if (points.Count == 1)
TheIntersectPoint = new Point2d(points[0].X, points[0].Y);//1个交点,说明是直线和直线相交
else
{
//2个交点,那就需要判断是哪一个了
//与pl2offset的终点进行比较,距离较近的那个就是了
double dist1 = points[0].DistanceTo(pl2.StartPoint);
double dist2 = points[1].DistanceTo(pl2.StartPoint);
if (dist1 > dist2)
TheIntersectPoint = new Point2d(points[1].X, points[1].Y);
else
TheIntersectPoint = new Point2d(points[0].X, points[0].Y);
}
double newBulge = GetOffsetCurveBulge.Get(IsLeftComp, r, line, TheIntersectPoint, i, pl1Offset.GetPoint2dAt(0));
newLine.AddVertexAt(0, TheIntersectPoint, newBulge, 0, 0);
if (i == line.NumberOfVertices - 2)//最后一个点的时候
{
double bulge = GetOffsetCurveBulge.Get(IsLeftComp, r, line, pl2Offset.GetPoint2dAt(1), i + 1, pl2Offset.GetPoint2dAt(0));
newLine.AddVertexAt(0, new Point2d(pl2Offset.EndPoint.X, pl2Offset.EndPoint.Y), bulge, 0, 0);
}
pl2.Dispose();
pl2Offset.Dispose();
}
pl1.Dispose();
pl1Offset.Dispose();
}
ReversePolyline(newLine);
// newLine.ReverseCurve();//反转多段线
return newLine;
}
示例10: addCloudLineSegment
private static void addCloudLineSegment(Polyline plCloud, LineSegment2d lineSeg)
{
var lenCur = 0d;
var ptCur = lineSeg.StartPoint;
while (lenCur< lineSeg.Length)
{
if ((lineSeg.Length-lenCur) <100)
ptCur = ptCur + lineSeg.Direction * (lineSeg.Length-lenCur);
else
ptCur = ptCur + lineSeg.Direction * 100;
plCloud.AddVertexAt(plCloud.NumberOfVertices, ptCur, -1, 0, 0);
lenCur +=100;
}
}
示例11: start_DIMline
public void start_DIMline()
{
CurrPoint = tr.AC_Doc.Editor.GetPoint("Pick a Point");
preview.beginDraw_PreviewLine(CurrPoint.Value);
Points.Add(CurrPoint.Value);
Polyline PLine = new Polyline();
PLine.AddVertexAt(0, new Point2d(CurrPoint.Value.X, CurrPoint.Value.Y), 0, 0, 0);
DIMline = tr.addObject(PLine);
}
示例12: addOutsides
private void addOutsides(BlockTableRecord btrPanel, Transaction t)
{
if (panelBase.Panel.outsides?.outside?.Count()>0)
{
foreach (var outside in panelBase.Panel.outsides.outside)
{
Polyline plOut = new Polyline();
Point2d pt;// =new Point2d(outside.posi.X, outside.posi.Y);
double width = Math.Abs(outside.width)+70;
// Если это левое примыкание Outside
if (Math.Abs(outside.posi.X)<10)
{
pt = new Point2d(outside.posi.X, outside.posi.Y);
panelBase.XMinContour = width;
panelBase.XStartTile = width+11;
//panelBase.XMinPanel = pt.X;
panelBase.IsOutsideLeft = true;
}
else
{
pt = new Point2d(outside.posi.X-70, outside.posi.Y);
panelBase.XMaxContour += -70;
panelBase.XMaxPanel = pt.X + width;
panelBase.IsOutsideRight = true;
}
plOut.AddVertexAt(0, pt, 0, 0, 0);
pt = new Point2d(pt.X+ width, pt.Y);
plOut.AddVertexAt(1, pt, 0, 0, 0);
pt = new Point2d(pt.X, pt.Y+outside.height);
plOut.AddVertexAt(2, pt, 0, 0, 0);
pt = new Point2d(pt.X- width, pt.Y);
plOut.AddVertexAt(3, pt, 0, 0, 0);
plOut.Closed = true;
plOut.Layer = "0";
btrPanel.AppendEntity(plOut);
t.AddNewlyCreatedDBObject(plOut, true);
}
}
}
示例13: DrawGeometry
public static ObjectId DrawGeometry(Point3dCollection pts,
Boolean close = true)
{
ObjectId id = new ObjectId();
//Abrimos el documento activo
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
//Abrimos la BD
Database dwg = doc.Database;
//Se utiliza el using para cerrar la
//transacción
//El Transaction Manager administra las transacciones y se
//encuentra dentro de la BD
using (Transaction tr = dwg.TransactionManager.StartTransaction())
{
try
{
//1: Abre el espacio activo de la aplicación
BlockTableRecord currentSpace = (BlockTableRecord)
dwg.CurrentSpaceId.GetObject(OpenMode.ForWrite);
//2: Dibujar la geometría como una polilínea
Polyline pl = new Polyline();
for (int i = 0; i < pts.Count; i++)
pl.AddVertexAt(i, pts[i].Convert2d(
new Plane(new Point3d(0, 0, 0), Vector3d.ZAxis)),
0, 0, 0);
pl.Closed = close;
pl.Color = Color.FromRgb(0, 255, 0);
//3: Anexar geometría al espacio
currentSpace.AppendEntity(pl);
tr.AddNewlyCreatedDBObject(pl, true);
tr.Commit();
}
catch (Exception exc)
{
//Si algo sale mal aborta
ed.WriteMessage(exc.Message);
tr.Abort();
}
}
return id;
}
示例14: addLayout
private static void addLayout(Point3d pt,int layout ,double width, double height , BlockTableRecord cs, Transaction t)
{
// Полилиния контура листа
Polyline pl = new Polyline(4);
pl.AddVertexAt(0, new Point2d(pt.X, pt.Y), 0, 0, 0);
pl.AddVertexAt(1, new Point2d(pt.X +width, pt.Y), 0, 0, 0);
pl.AddVertexAt(2, new Point2d(pt.X + width, pt.Y - height), 0, 0, 0);
pl.AddVertexAt(3, new Point2d(pt.X, pt.Y-height), 0, 0, 0);
pl.Closed = true;
pl.SetDatabaseDefaults();
cs.AppendEntity(pl);
t.AddNewlyCreatedDBObject(pl, true);
// Подпись номера листа
var textHeight = height * 0.008;
Point3d ptText = new Point3d(pt.X+textHeight*0.5, pt.Y-textHeight*1.5, 0);
DBText text = new DBText();
text.SetDatabaseDefaults();
text.Height = textHeight;
text.TextStyleId = IdTextStylePik;
text.TextString = layout.ToString();
text.Position = ptText;
cs.AppendEntity(text);
t.AddNewlyCreatedDBObject(text, true);
// Layout
//createLayout(pl, layout, width, height, t);
}
示例15: Create
public static DBObject Create(this Grevit.Types.Room r, Transaction tr)
{
DictionarySpaceStyle ss = new DictionarySpaceStyle(Command.Database);
try
{
BlockTable bt = (BlockTable)tr.GetObject(Command.Database.BlockTableId, OpenMode.ForRead);
BlockTableRecord ms = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
Polyline acPoly = new Polyline();
acPoly.SetDatabaseDefaults();
int i = 0;
foreach (Grevit.Types.Point p in r.points)
{
acPoly.AddVertexAt(i, new Point2d(p.x, p.y), 0, 0, 0);
i++;
}
acPoly.Closed = true;
ms.AppendEntity(acPoly);
tr.AddNewlyCreatedDBObject(acPoly, true);
Autodesk.Aec.Geometry.Profile myProfile = Autodesk.Aec.Geometry.Profile.CreateFromEntity(acPoly, Command.Editor.CurrentUserCoordinateSystem);
Space space;
bool newEnt = false;
if (Command.existing_objects.ContainsKey(r.GID))
{
space = (Space)tr.GetObject(Command.existing_objects[r.GID], OpenMode.ForWrite);
}
else
{
newEnt = true;
space = new Space();
space.SetDatabaseDefaults(Command.Database);
space.SetToStandard(Command.Database);
}
space.Associative = r.associative;
space.Name = r.name;
space.GeometryType = SpaceGeometryType.TwoD;
space.Location = new Point3d(0, 0, 0);
space.SetBaseProfile(myProfile, Matrix3d.Identity);
LayerTable lt = (LayerTable)tr.GetObject(Command.Database.LayerTableId, OpenMode.ForRead);
if (r.TypeOrLayer != "") { if (lt.Has(r.TypeOrLayer)) space.LayerId = lt[r.TypeOrLayer]; }
if (ss.Has(r.FamilyOrStyle, tr)) space.StyleId = ss.GetAt(r.FamilyOrStyle);
if (newEnt)
{
ms.AppendEntity(space);
tr.AddNewlyCreatedDBObject(space, true);
ms.Dispose();
}
return space;
}
catch (Autodesk.AutoCAD.Runtime.Exception e)
{
}
return null;
}