.NET

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

.NET(C#) Wrapper for viewChanged Callback

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

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.

*Expert Elite*
norman.yuan
Posts: 1,021
Registered: ‎04-27-2009
Message 2 of 8 (411 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...");
        }

 

Distinguished Mentor
owenwengerd
Posts: 645
Registered: ‎08-06-2002
Message 3 of 8 (399 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 (391 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 (386 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*
norman.yuan
Posts: 1,021
Registered: ‎04-27-2009
Message 6 of 8 (369 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 (348 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*
norman.yuan
Posts: 1,021
Registered: ‎04-27-2009
Message 8 of 8 (343 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.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.