AutoCAD Map 3D Developer
Welcome to Autodesk’s AutoCAD Map 3D Developer Forums. Share your knowledge, ask questions, and explore popular AutoCAD Map 3D Developer topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

PointMonitor on Feature Objects

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
kob4lt
1205 Views, 6 Replies

PointMonitor on Feature Objects

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

 

Thanks

6 REPLIES 6
Message 2 of 7
norman.yuan
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.

 

 

Message 3 of 7
kob4lt
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

Message 4 of 7
norman.yuan
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

 

Message 5 of 7
matus.brlit
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

Message 6 of 7
kob4lt
in reply to: matus.brlit

That's it! It worked!

 

Thanks

Message 7 of 7
br-br-br
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?

 

 

 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost