.NET

Reply
Contributor
autogis
Posts: 19
Registered: ‎11-13-2013
Message 1 of 7 (184 Views)
Accepted Solution

Finding text elements near to the specified point

184 Views, 6 Replies
05-08-2014 06:30 AM

Is there a method to find all text elements near a certain distance from a specified point?  Thanks.

Thanks everyone.   Also I found this:

 

http://www.stormconsultancy.co.uk/blog/development/code-snippets/the-haversine-formula-in-c-and-sql/

 

"Haversine Formula"

 


I think it might help me.

Mentor
mzakiralam
Posts: 231
Registered: ‎11-09-2012
Message 2 of 7 (176 Views)

Re: Finding text elements near to the specified point

05-08-2014 07:07 AM in reply to: autogis
*Expert Elite*
_gile
Posts: 2,115
Registered: ‎04-29-2006
Message 3 of 7 (165 Views)

Re: Finding text elements near to the specified point

05-08-2014 08:53 AM in reply to: mzakiralam

Doesn't the Leader.Annotation property help ?

Gilles Chanteau
Contributor
autogis
Posts: 19
Registered: ‎11-13-2013
Message 4 of 7 (163 Views)

Re: Finding text elements near to the specified point

05-08-2014 08:56 AM in reply to: _gile

The text objects I am trying to find are actually separate elements.  They are not part of the leader:  leaderAndText.png

Contributor
autogis
Posts: 19
Registered: ‎11-13-2013
Message 5 of 7 (161 Views)

Re: Finding text elements near to the specified point

05-08-2014 09:01 AM in reply to: autogis

// Start Transaction
                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    BlockTableRecord modelSpace = (BlockTableRecord)tr.GetObject(
                        SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForRead);
                    foreach (ObjectId id in modelSpace)
                    {
                        // Pick only Leaders
                        if (id.ObjectClass.DxfName == "LEADER")
                        {
                            // Pick only HOMES
                            Leader leader = (Leader)tr.GetObject(id, OpenMode.ForRead);
                            if (leader.Layer == "HOMES")
                            { 

                                // Leader Points (Just use the last point)
                                Point3dCollection pts = new Point3dCollection();
                                leader.GetStretchPoints(pts);       // NOTE: pts will have all the points of the leader

                                // HERE I would call a method
                                // that would get all text elements within a certain distance of:   pts[pts.Count-1]  <<The last point of the leader

Mentor
SENL1362
Posts: 214
Registered: ‎07-20-2011
Message 6 of 7 (147 Views)

Re: Finding text elements near to the specified point

05-08-2014 11:32 PM in reply to: autogis

You might write some code that test object locations within a area.

I just wrote one my self using the region test based on a idea of Tony T.

However i changed the code to do simple inside polygon tests because i needed more speed and my area's are simple 2D rectangles.

 

 

Contributor
autogis
Posts: 19
Registered: ‎11-13-2013
Message 7 of 7 (140 Views)

Re: Finding text elements near to the specified point

05-09-2014 06:18 AM in reply to: SENL1362

Thanks everyone.   Also I found this:

 

http://www.stormconsultancy.co.uk/blog/development/code-snippets/the-haversine-formula-in-c-and-sql/

 

"Haversine Formula"

 


I think it might help me.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!