.NET
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic to the Top
- Bookmark
- Subscribe
- Printer Friendly Page
Define a polyline.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
85 Views, 5 Replies
08-23-2005 08:30 AM
I have three point3d objects defined as follows:
Dim corner1 As New Point3d(0, 0, 0)
Dim corner2 As New Point3d(10, 0, 0)
Dim corner3 As New Point3d(10, 10, 0)
I have been looking at the following line out of a sample program that defines a circle:
Dim center As New Point3d(10, 10, 0)
My question is what code do I need to add to my program similar to the line above that will connect my three point3d objects with a polyline.
Thank you,
Eric Sepich
Dim corner1 As New Point3d(0, 0, 0)
Dim corner2 As New Point3d(10, 0, 0)
Dim corner3 As New Point3d(10, 10, 0)
I have been looking at the following line out of a sample program that defines a circle:
Dim center As New Point3d(10, 10, 0)
My question is what code do I need to add to my program similar to the line above that will connect my three point3d objects with a polyline.
Thank you,
Eric Sepich
Re: Define a polyline.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-23-2005 08:30 AM in reply to:
sepich4567
Addendum:
Circle code was actually
Dim circle As Circle = New Circle(center, Vector3d.ZAxis, 2.0)
Circle code was actually
Dim circle As Circle = New Circle(center, Vector3d.ZAxis, 2.0)
*Mike Tuersley
Re: Define a polyline.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-23-2005 09:41 AM in reply to:
sepich4567
You need to determine whether you are going to draw a PolyLine or a
LWPolyLine. Both require a point list with the LWP requiring it to be only
2D points. So assuming you want an open LWPline, it'd look something like:
Dim corner1 As New Point3d(0, 0, 0)
Dim corner2 As New Point3d(10, 0, 0)
Dim corner3 As New Point3d(10, 10, 0)
Dim dPtList(6) As Double
dPtList(0) = corner1.X
dPtList(1) = corner1.Y
dPtList(2) = corner2.X
dPtList(3) = corner2.Y
dPtList(4) = corner3.X
dPtList(5) = corner3.Y
then create your lwpolyline passing the dPtList as the point list
-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
LWPolyLine. Both require a point list with the LWP requiring it to be only
2D points. So assuming you want an open LWPline, it'd look something like:
Dim corner1 As New Point3d(0, 0, 0)
Dim corner2 As New Point3d(10, 0, 0)
Dim corner3 As New Point3d(10, 10, 0)
Dim dPtList(6) As Double
dPtList(0) = corner1.X
dPtList(1) = corner1.Y
dPtList(2) = corner2.X
dPtList(3) = corner2.Y
dPtList(4) = corner3.X
dPtList(5) = corner3.Y
then create your lwpolyline passing the dPtList as the point list
-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Re: Define a polyline.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-23-2005 09:49 AM in reply to:
sepich4567
I have searched the ObjectARX reference manual for "LWPolyline" and have not found anything. Can anyone tell me where this thing is defined and how to use it properly?
*Mike Tuersley
Re: Define a polyline.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
08-23-2005 01:12 PM in reply to:
sepich4567
try Autodesk.AutoCAD.DatabaseServices.Polyline2d - LWPolylIne is an AutoCAD
and COM term
-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
and COM term
-- Mike
___________________________
Mike Tuersley
___________________________
the trick is to realize that there is no spoon...
Re: Define a polyline.
Options
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Highlight
- Email to a Friend
- Report Inappropriate Content
09-29-2005 08:05 AM in reply to:
sepich4567
Hi Mike:
I am working on a function to draw a box in LWPolyline in C#. Now everything looks OK but the rectangle does not show up in the drawing. Please see code below:
public static Entity DrawBox(Point2d pt, double Width, double Height, BlockTableRecord btr)
{
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
Polyline plBox;
try
{
plBox = new Polyline(4);
plBox.AddVertexAt (0, pt, 0,0,0);
plBox.AddVertexAt (1, new Point2d(pt.X+Width, pt.Y),0,0,0);
plBox.AddVertexAt (2, new Point2d(pt.X+Width,pt.Y+Height),0,0,0);
plBox.AddVertexAt (3, new Point2d(pt.X,pt.Y+Height),0,0,0);
plBox.Closed = true;
btr.AppendEntity(plBox);
trans.AddNewlyCreatedDBObject(plBox,true);
trans.Commit();
}
finally
{
trans.Dispose();
}
return plBox;
}
//// Here is the code to test it
[CommandMethod("DrawBox_TEST")]
public static void DrawBox_Test()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.D ocumentManager.MdiActiveDocument.Editor;
Transaction trans = db.TransactionManager.StartTransaction();
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId,OpenMo de.ForWrite);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRec ord.ModelSpace],OpenMode.ForWrite);
PromptPointOptions prPtOpts = new PromptPointOptions("Please pick a point:");
PromptPointResult prPtRes = ed.GetPoint(prPtOpts);
if (prPtRes.Status != PromptStatus.OK )
return;
Point3d pt1 = prPtRes.Value;
Point2d pt = new Point2d(pt1.X, pt1.Y);
Entity ent = AutoCADLib.DrawBox(pt,100,50,btr);
if (ent != null)
ed.WriteMessage("{0}",ent.GetType().Name);
else
ed.WriteMessage("No Box Drawed.");
}
do you what's wrong is there? Thank you.
Also, I found in AutoCAD .Net help,
"AcDbPolyline is often called a lightweight polyline because of its efficient use of memory. AcDbPolyline provides greater performance and reduced overhead compared to AcDb2dPolyline"
I kind of confused:
the LWPolyline in AutoCAD is AcDbPolyline
old style Polyline is AcDB2dPolyline. Which is correct?
Wes
I am working on a function to draw a box in LWPolyline in C#. Now everything looks OK but the rectangle does not show up in the drawing. Please see code below:
public static Entity DrawBox(Point2d pt, double Width, double Height, BlockTableRecord btr)
{
Database db = HostApplicationServices.WorkingDatabase;
Transaction trans = db.TransactionManager.StartTransaction();
Polyline plBox;
try
{
plBox = new Polyline(4);
plBox.AddVertexAt (0, pt, 0,0,0);
plBox.AddVertexAt (1, new Point2d(pt.X+Width, pt.Y),0,0,0);
plBox.AddVertexAt (2, new Point2d(pt.X+Width,pt.Y+Height),0,0,0);
plBox.AddVertexAt (3, new Point2d(pt.X,pt.Y+Height),0,0,0);
plBox.Closed = true;
btr.AppendEntity(plBox);
trans.AddNewlyCreatedDBObject(plBox,true);
trans.Commit();
}
finally
{
trans.Dispose();
}
return plBox;
}
//// Here is the code to test it
[CommandMethod("DrawBox_TEST")]
public static void DrawBox_Test()
{
Database db = HostApplicationServices.WorkingDatabase;
Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.D
Transaction trans = db.TransactionManager.StartTransaction();
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId,OpenMo
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRec
PromptPointOptions prPtOpts = new PromptPointOptions("Please pick a point:");
PromptPointResult prPtRes = ed.GetPoint(prPtOpts);
if (prPtRes.Status != PromptStatus.OK )
return;
Point3d pt1 = prPtRes.Value;
Point2d pt = new Point2d(pt1.X, pt1.Y);
Entity ent = AutoCADLib.DrawBox(pt,100,50,btr);
if (ent != null)
ed.WriteMessage("{0}",ent.GetType().Name);
else
ed.WriteMessage("No Box Drawed.");
}
do you what's wrong is there? Thank you.
Also, I found in AutoCAD .Net help,
"AcDbPolyline is often called a lightweight polyline because of its efficient use of memory. AcDbPolyline provides greater performance and reduced overhead compared to AcDb2dPolyline"
I kind of confused:
the LWPolyline in AutoCAD is AcDbPolyline
old style Polyline is AcDB2dPolyline. Which is correct?
Wes
