.NET

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

Finding text elements near to the specified point

178 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 (170 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,103
Registered: ‎04-29-2006
Message 3 of 7 (159 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 (157 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 (155 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: 180
Registered: ‎07-20-2011
Message 6 of 7 (141 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 (134 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
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.