.NET

.NET

Reply
Contributor
19 Posts
0 Kudos
Registered: ‎11-13-2013
Post 1 of 7
Accepted Solution

Finding text elements near to the specified point

192 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
231 Posts
30 Kudos
Registered: ‎11-09-2012
Post 2 of 7

Re: Finding text elements near to the specified point

05-08-2014 07:07 AM in reply to: autogis
*Expert Elite*
2,140 Posts
253 Kudos
Registered: ‎04-29-2006
Post 3 of 7

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
19 Posts
0 Kudos
Registered: ‎11-13-2013
Post 4 of 7

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
19 Posts
0 Kudos
Registered: ‎11-13-2013
Post 5 of 7

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
246 Posts
44 Kudos
Registered: ‎07-20-2011
Post 6 of 7

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
19 Posts
0 Kudos
Registered: ‎11-13-2013
Post 7 of 7

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