TheSwamp

Code Red => ARX Programming => Topic started by: simor on September 27, 2008, 05:38:09 PM

Title: How to draw a Point?
Post by: simor on September 27, 2008, 05:38:09 PM
I'm using AutoCAD 2008 and VS.NET 2003. Trying to write my first ObjectARX application. I can create a line but I don't know how to create a 3d point. There doesn't seem to be anything like it in Autodesk.AutoCad.DatabaseServices  :?

Can anyone solve this impossible puzzle for me?  :?
Title: Re: How to draw a Point?
Post by: MickD on September 27, 2008, 06:07:57 PM
AcGePoint3d is the class you want (acge17.lib), it takes 3 doubles in one of it's constructors
eg.
AcGePoint3d pnt = new AcGePoint3d(23, 34, 0);

I'm not sure how you are going to go with VS2003 with arx2008, or at least how far you will get until it won't work (it's an MFC thing).

Oh, I just noticed this in your post -> Autodesk.AutoCad.DatabaseServices
Are you doing this in C#?

If that's the case you need Autodesk.AutoCad.Geometry or something like that and use the Point3d class, fire up the object browser and have a look at what lives where is probably the easiest way to find things apart from the doc's.

Another thing, the database only holds objects and entities, objects are things like dictionaries that don't have a graphical representation whereas lines and circles (entities) do. Things like points and even geometrical lines (in the geometry classes that is) are not database entities as such but are helpers to create and modify entities, arx has a very good geometry lib so you better get acquainted early :)
hth.

Title: Re: How to draw a Point?
Post by: simor on September 27, 2008, 07:15:43 PM
Yeap C#, forgot to mention it..

I found some Point in Geometry but I wasn't able to add it using AppendEntity because it wants something of type declared by the DatabaseServices class... I don't know how to draw it otherwise? Why are lines drawn by adding to the database (saw samples of code - but you state they aren't??) and points are drawn in some other way?

Really confused..  :|

Edit: oh I missed it.. "AcGePoint3d pnt = new AcGePoint3d(23, 34, 0);" <- will this draw me a point in autocad? I'll test it tomorrow 1st thing in the morning  :oops:
Title: Re: How to draw a Point?
Post by: MickD on September 27, 2008, 07:37:28 PM
Sorry Simor, I thought you just wanted a geometry point, have a look at DBPoint.

I didn't say that lines were not database residents, they are, geometric points are not. Anything that you can 'see' in the editor/dwg is a database object. A 'point' object that you can see is therefore a database resident, I think DBPoint is what you're after.

Edit: oh I missed it.. "AcGePoint3d pnt = new AcGePoint3d(23, 34, 0);" <- will this draw me a point in autocad? I'll test it tomorrow 1st thing in the morning  :oops:

That's an example of a geometric point (in C++ btw), it does not get added to the database but it is used to create lines (start and end points), even the DBPoint needs a Point3d object so it knows its position in space, they are 2 different things though, you'll get it after you play around a while ;)
Title: Re: How to draw a Point?
Post by: Kerry on September 27, 2008, 07:52:23 PM
Have a look at  
Autodesk.AutoCAD.DatabaseServices.DBPoint


something like
using Autodesk.AutoCAD.DatabaseServices;
// for the DBPoint

//....

DBPoint pointEnt = new DBPoint(new Autodesk.AutoCAD.Geometry.Point3d(23, 34, 0));


As Mick indicated, the Geometry classes are not graphical representations, you'll need the  DataBase Classes for that.
Title: Re: How to draw a Point?
Post by: simor on September 29, 2008, 09:25:27 AM
Yes, I was looking for DBPoint, I don't know how I missed it.. :oops:
Thanks guys but I'm still stuck on the following line:

BlockTableRecord btr = (BlockTableRecord)tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);

I found examples using tr.getobject and tm.getobject (transactions or manager). When I run this in AutoCAD (2008) I get a nasty error saying:

Field not found:
'Autodesk.AutoCAD.DatabaseServices.BlockTableRecord.ModelSpace'

but I do see ModelSpace in VS. I googled and found a few guys complaining about it in Autocad's disc-groups but there was no solution.
ps. I also have AutoCAD 2006 installed on this PC but I'm only using 2008 for this test application.

What am I doing wrong?  :?
Title: Re: How to draw a Point?
Post by: simor on September 29, 2008, 09:40:19 AM
Got it! I found some reference path pointing to the Autocad 2006 folder (not sure why?)... once I changed it to 2008 it was all perfect.

 :lol: