.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Define a polyline.

5 REPLIES 5
Reply
Message 1 of 6
sepich4567
277 Views, 5 Replies

Define a polyline.

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
5 REPLIES 5
Message 2 of 6
sepich4567
in reply to: sepich4567

Addendum:

Circle code was actually

Dim circle As Circle = New Circle(center, Vector3d.ZAxis, 2.0)
Message 3 of 6
Anonymous
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...
Message 4 of 6
sepich4567
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?
Message 5 of 6
Anonymous
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...
Message 6 of 6
wesbird
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.DocumentManager.MdiActiveDocument.Editor;
Transaction trans = db.TransactionManager.StartTransaction();

BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId,OpenMode.ForWrite);
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.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
Windows 10 64 bit, AutoCAD (ACA, Map) 2023

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost