.NET

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

Finding text elements near to the specified point

162 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.

Mentor
mzakiralam
Posts: 230
Registered: ‎11-09-2012
Message 2 of 7 (154 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,078
Registered: ‎04-29-2006
Message 3 of 7 (143 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: 14
Registered: ‎11-13-2013
Message 4 of 7 (141 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: 14
Registered: ‎11-13-2013
Message 5 of 7 (139 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: 165
Registered: ‎07-20-2011
Message 6 of 7 (125 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: 14
Registered: ‎11-13-2013
Message 7 of 7 (118 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.

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community