AutoCAD Map 3D Developer

Reply
Valued Contributor
Posts: 61
Registered: ‎04-14-2010
Message 1 of 7 (648 Views)
Accepted Solution

PointMonitor on Feature Objects

648 Views, 6 Replies
05-30-2011 03:06 PM

Is it posible to implement PointMonitor to show some info about Feature Objects linked with FDO?

 

Thanks

*Expert Elite*
Posts: 890
Registered: ‎04-27-2009
Message 2 of 7 (630 Views)

Re: PointMonitor on Feature Objects

06-06-2011 07:37 AM in reply to: kob4lt

Yes, it is definitely possible. Just as you can show regular Acad entity info with PointMonitor event hanlder (PointMonitorEventArgs.AppendToolTip()), you can use Autodesk.Gis.Map.Platform.Interop.AcMapFeatureEntityService class to obtain feature object information from an Acad entity's ObjectId.

 

Here is an runable example:

using System.Text;

using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;

using Autodesk.Gis.Map.Platform.Interop;
using OSGeo.MapGuide;

[assembly: CommandClass(typeof(MapFeatureTest.MyCommands))]

namespace MapFeatureTest
{
    public class MyCommands
    {
        private Document _dwg = null;
        private bool _msgOn = false;

        [CommandMethod("MapMsgOn")]
        public void MsgOn()
        {
            if (_dwg == null)
            {
                _dwg = Application.DocumentManager.MdiActiveDocument;
                _dwg.Editor.PointMonitor += 
                    new PointMonitorEventHandler(Editor_PointMonitor);
            }

            _msgOn = true;
        }

        [CommandMethod("MapMsgOff")]
        public void MsgOff()
        {
            if (_dwg == null)
            {
                return;
            }
            else
            {
                _dwg.Editor.PointMonitor -= Editor_PointMonitor;
            }

            _msgOn = false;
        }

        private void Editor_PointMonitor(
            object sender, PointMonitorEventArgs e)
        {
            if (_dwg == null) return;
            if (!_msgOn) return;

            Editor ed = _dwg.Editor;

            FullSubentityPath[] paths = e.Context.GetPickedEntities();
            if (paths.Length > 0)
            {
                ObjectId[] ids=paths[0].GetObjectIds();
                if (ids.Length > 0)
                {
                    ObjectId selId = ids[ids.Length - 1];

                    string tipText = GetToolTip(selId);
                    e.AppendToolTipText(tipText);
                }
            }
        }

        private string GetToolTip(ObjectId selId)
        {
            StringBuilder str = new StringBuilder();
            str.Append("ObjectId: " + selId.ToString() + "\n");
            str.Append("DxfName: " + selId.ObjectClass.DxfName + "\n");

            if (selId.ObjectClass.DxfName.ToUpper() == "MAPBULKFEATURE")
            {
                str.Append("Feature: " + 
                    AcMapFeatureEntityService.
                    GetLayer(selId).FeatureClassName + "\n");
            }

            return str.ToString();
        }
    }
}

 "Netload" this code into AutoCAD and enter "MapMsgOn" command. Then if you move cursor over an Acad entity or a map feature entity in Acad editor and wait a moment, a tooltip will show.

 

 

Valued Contributor
Posts: 61
Registered: ‎04-14-2010
Message 3 of 7 (629 Views)

Re: PointMonitor on Feature Objects

06-06-2011 07:54 AM in reply to: norman.yuan

I load SDF file with few Feature objects

 

I dont know why but I am getting this error

 

Error on Feature object

*Expert Elite*
Posts: 890
Registered: ‎04-27-2009
Message 4 of 7 (622 Views)

Re: PointMonitor on Feature Objects

06-06-2011 08:25 AM in reply to: kob4lt

I have no idea. In my test, I added feature objects from a shape file. It works well.

 

See this vidoe clip

 

Mentor
Posts: 244
Registered: ‎03-11-2008
Message 5 of 7 (569 Views)

Re: PointMonitor on Feature Objects

07-06-2011 11:34 PM in reply to: kob4lt

i don't know if this helps, but i was also getting this error and it stopped when i turned off the rollover tooltips

Valued Contributor
Posts: 61
Registered: ‎04-14-2010
Message 6 of 7 (564 Views)

Re: PointMonitor on Feature Objects

07-07-2011 01:03 AM in reply to: matus.brlit

That's it! It worked!

 

Thanks

Active Member
br-br-br
Posts: 7
Registered: ‎08-17-2011
Message 7 of 7 (332 Views)

Re: PointMonitor on Feature Objects

03-28-2012 10:09 AM in reply to: norman.yuan

Sorry, but i have the same question.

We can see feature object information, can we read object data?

 

I think that we have to use mgfeaturereder to read odject data, for this reason I link mgselectionbase:

 

Dim paths As FullSubentityPath() = e.Context.GetPickedEntities()
If paths.Length > 0 Then
 Dim ids As ObjectId() = paths(0).GetObjectIds()
If ids.Length > 0 Then
 Dim selId As ObjectId = ids(ids.Length - 1)
Dim selIdCollection as objectidcollection = nothing

sellidcollection.add(selid)

Dim MgSelBas as new mgselectionbase =  Autodesk.Gis.Map.Platform.Interop.AcMapFeatureEntityService.getfeatures(sellidcollectionl) ' after this line my Autocad Map 3D crashes 
  End If
End If

 

Can we read data and show it on tooltips?

 

 

 

 

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
Welcome to the new Autodesk Community!
If this is your first visit, click here to get started and make the most of the Community. Let us know what you think of the new experience in the Community Feedback Forum.

Need installation help?

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

Ask the Community