.NET

Reply
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 1 of 8 (291 Views)
Accepted Solution

.NET(C#) Wrapper for viewChanged Callback

291 Views, 7 Replies
11-17-2013 09:30 PM

Hi, everyone.

 

I would like to detect view change (especially when orbiting the view around) to automatically reposition table-like(block) entity such that the user can always see the face of the entity.

I figured out that there is viewChanged event in AcEditorReactor, but it doesn't seem like it is visible in .NET.

How could I use this callback function? Does anyone have tried it before?

Or would there be anyother way to solve the issue I mentioned above?

 

Any tip would be appreciated.

Thank you.

*Expert Elite*
Posts: 893
Registered: ‎04-27-2009
Message 2 of 8 (263 Views)

Re: .NET(C#) Wrapper for viewChanged Callback

11-18-2013 12:17 PM in reply to: dynamicscope

You can handle Autodesk.AutoCAD.ApplicationServices.Document.ViewChanged event.

 

Somethign like:

 

        private bool _viewChangeHandled=false

        [CommandMethod("VewChanged")]
        public void HoodViewChanged()
        {
            Document dwg = Application.DocumentManager.MdiActiveDocument;

            if (!_viewChangeHandled)
            {
                dwg.ViewChanged += dwg_ViewChanged;
                _viewChangeHandled = true;
            }
            else
            {
                dwg.ViewChanged -= dwg_ViewChanged;
                _viewChangeHandled = false;
            }
        }

        private void dwg_ViewChanged(object sender, EventArgs e)
        {
            Document dwg = Application.DocumentManager.MdiActiveDocument;
            dwg.Editor.WriteMessage("\nView changed...");
        }

 

Valued Mentor
owenwengerd
Posts: 499
Registered: ‎08-06-2002
Message 3 of 8 (251 Views)

Re: .NET(C#) Wrapper for viewChanged Callback

11-18-2013 03:26 PM in reply to: dynamicscope

I think you will find that making dynamic changes to the entity in real time is not practical. I would try to overrule ViewportDraw instead; then you can transform the graphics as desired without modifying the entity (which requires write access and undo filing).

--
Owen Wengerd
ManuSoft
Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 4 of 8 (243 Views)

Re: .NET(C#) Wrapper for viewChanged Callback

11-18-2013 04:19 PM in reply to: norman.yuan

Hmmm... my Documnet class does not have ViewChanged event handler.

I am currently using ObjectARX 2007.

From what version, does it get supported?

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 5 of 8 (238 Views)

Re: .NET(C#) Wrapper for viewChanged Callback

11-18-2013 06:26 PM in reply to: owenwengerd
Overruling ViewportDraw....
Hmmm.....
Would there be any hint to start with?
(I have no idea how to start...)
*Expert Elite*
Posts: 893
Registered: ‎04-27-2009
Message 6 of 8 (221 Views)

Re: .NET(C#) Wrapper for viewChanged Callback

11-19-2013 07:08 AM in reply to: dynamicscope

Well, if you still work with AutoCAD 2007, there is no ViewChanged event, at least up to AutoCAD 2009. The oldest version I have access to is Acad2012, so cannot say exactly which version introduced ViewChanged event in .NET API.

 

Also, you can forget anything about Overrule unless you work with AutoCAD 2010 or later.

 

With 7 version behind (Acad2007 to 2014), you may want to assess whether your .NET API development is worth the effort, IMO.

Valued Contributor
dynamicscope
Posts: 95
Registered: ‎04-04-2012
Message 7 of 8 (200 Views)

Re: .NET(C#) Wrapper for viewChanged Callback

11-20-2013 12:02 AM in reply to: norman.yuan
I can also go with AutoCAD 2010 or later.
If so, would there be any starting guide? (Couldn't find one in this forum.)

And why do you think it is not worth developing with .NET API?
*Expert Elite*
Posts: 893
Registered: ‎04-27-2009
Message 8 of 8 (195 Views)

Re: .NET(C#) Wrapper for viewChanged Callback

11-20-2013 06:31 AM in reply to: dynamicscope

I said it might not be worth the effort, not because of doing .NET API programming, but because of using very old version of AutoCAD.

 

For your interest of knowing when AutoCAD's view is changed, you need to start with a version of AutoCAd that has ViewChanged event available in .NET API, which I only know it was not available at least up to acad2009, and for sure it is available in Acad2012, but not very sure about Acad2010/2011.

 

As for using Overrule as Owen suggested, I can say without knowing well what you want to do exactly. Do searching for AutoCAD Overrule would lead you to some examples.

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