PointEntity3D

PointEntity3D

Anonymous
Not applicable
644 Views
4 Replies
Message 1 of 5

PointEntity3D

Anonymous
Not applicable
Hi all,

In a previous post I was advised by Jason Booth (thanks Jason) to use the PointEntity2d or PointEntity3d classes in order to create a point which can be added to the database / model space.

I am unable to find any information on how to create an object with those classes. They have an " unusual " constructor,

Create(System.IntPtr unmanagedPointer, System.Boolean autoDelete)

Parameters
unmanagedPointer Input System.IntPtr object.
autoDelete Input System.Boolean object.

I understand that I need to create an unmanagedPointer to a point3D object, and then use it to crete the PointEntity3D. Am I correct ? How can it be done ?

I cannot find any reference to PointEntity3D on any Autodesk forum, and nothing useful on the rest of the internet , so any help will be very appreciated.

j.
0 Likes
645 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
It is not PointEntity2d or PointEntity3d but it is DBPoint:
Autodesk.AutoCAD.DatabaseServices.DBPoint
For example:
[code]
[CommandMethod("AddPoint")]
static public void AddPoint()
{
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
PromptPointResult rs = ed.GetPoint("\nSelect point: ");
if (rs.Status == PromptStatus.OK)
{
DBPoint dbpt = new DBPoint(rs.Value); // If UCS != WCS you need translate point UCS->WCS
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTableRecord btr = tr.GetObject(doc.Database.CurrentSpaceId,OpenMode.ForWrite) as BlockTableRecord;
if (btr != null) {
dbpt.SetDatabaseDefaults(db);
btr.AppendEntity(dbpt);
tr.AddNewlyCreatedDBObject(dbpt,true);
}
tr.Commit();
}
}
}
[/code] Message was edited by: Alexander Rivilis
0 Likes
Message 3 of 5

Anonymous
Not applicable
Thanks a lot Alex, that solved it.

j.
0 Likes
Message 4 of 5

jbooth
Advocate
Advocate
I should have noticed this since PointEntity2d and PointEntity3d are in the Autocad.Geometry namespace. Everything in that namespace from what I've seen can't be added directly to the drawing database (hence the reason for the Autocad.DatabaseServices namespace).

Sorry to confuse you, DbPoint is correct (as you already know).
0 Likes
Message 5 of 5

Anonymous
Not applicable
Hi Jason,

No worries, I actually learned quite a few things trying to get things to work with the PointEntity2d / PointEntity3d classes, plus its the intention that counts !

j.
0 Likes