.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

.NET(C#) Wrapper for viewChanged Callback

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
dynamicscope
1856 Views, 7 Replies

.NET(C#) Wrapper for viewChanged Callback

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.

7 REPLIES 7
Message 2 of 8
norman.yuan
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...");
        }

 

Message 3 of 8
owenwengerd
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
Message 4 of 8
dynamicscope
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?

Message 5 of 8
dynamicscope
in reply to: owenwengerd

Overruling ViewportDraw....
Hmmm.....
Would there be any hint to start with?
(I have no idea how to start...)
Message 6 of 8
norman.yuan
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.

Message 7 of 8
dynamicscope
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?
Message 8 of 8
norman.yuan
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.

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost