AutoCAD Map 3D Developer

AutoCAD Map 3D Developer

Reply
Valued Contributor
61 Posts
2 Kudos
Registered: ‎04-14-2010
Post 1 of 7
Accepted Solution

PointMonitor on Feature Objects

716 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

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

*Expert Elite*
1,088 Posts
217 Kudos
Registered: ‎04-27-2009
Post 2 of 7

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
61 Posts
2 Kudos
Registered: ‎04-14-2010
Post 3 of 7

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*
1,088 Posts
217 Kudos
Registered: ‎04-27-2009
Post 4 of 7

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
247 Posts
6 Kudos
Registered: ‎03-11-2008
Post 5 of 7

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
61 Posts
2 Kudos
Registered: ‎04-14-2010
Post 6 of 7

Re: PointMonitor on Feature Objects

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

That's it! It worked!

 

Thanks

Active Member
7 Posts
0 Kudos
Registered: ‎08-17-2011
Post 7 of 7

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?

 

 

 

 

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!