.NET

.NET

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

Finding text elements near to the specified point

186 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 (178 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,125
Registered: ‎04-29-2006
Message 3 of 7 (167 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 (165 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 (163 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: 229
Registered: ‎07-20-2011
Message 6 of 7 (149 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 (142 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
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.