.NET

.NET

Reply
Contributor
lukasz.taraszka
Posts: 13
Registered: ‎10-07-2011
Message 1 of 3 (742 Views)
Accepted Solution

Refresh drawing when modal form is running

742 Views, 2 Replies
01-03-2012 12:52 AM

Hello everyone

 

Is it possible to refresh drawing content when modal form is running?

 

I placed sample project in attachment.


There is simple form with only one button.

 

Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        Class1.DrawLineOnScreen()
    End Sub

 

After button is pressed, application prompting user for picking 2 points, and draw a line (based on picked points).

 

Public Shared Sub DrawLineOnScreen()
        Dim editor As Editor = Application.DocumentManager.MdiActiveDocument.Editor

        Dim pFirst As PromptPointOptions = New PromptPointOptions("First point: ")
        Dim rFirst As PromptPointResult = editor.GetPoint(pFirst)

        Dim pSecond As PromptPointOptions = New PromptPointOptions("Second point: ")
        Dim rSecond As PromptPointResult = editor.GetPoint(pSecond)

        If rFirst.Status = PromptStatus.OK AndAlso rSecond.Status = PromptStatus.OK Then

            Dim line As Line = New Line(rFirst.Value, rSecond.Value)

            Dim tr As Transaction =                Application.DocumentManager.MdiActiveDocument.TransactionManager.StartTransaction
            Using tr
                Dim modelSpace As BlockTableRecord = tr.GetObject(Application.DocumentManager.MdiActiveDocument.Database.CurrentSpaceId, OpenMode.ForWrite)
                modelSpace.AppendEntity(line)
                tr.AddNewlyCreatedDBObject(line, True)
                tr.Commit()
            End Using

        End If
    End Sub

 

Problem is that line had been added to transaction (to Model Space block table record) but nothing change on a drawing. Line will appear on a drawing after closing the form.

 

In opposite situation, without using modal form (only console) everyting works fine.

 

<CommandMethod("DrawLine", CommandFlags.Modal)> _
        Public Sub DrawLine()
            Class1.DrawLineOnScreen()
        End Sub

 

did you tried editor.Regen()

 

c# sample:

       private void Select_Click(object sender, EventArgs e)
        {
            Document doc = Acad.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            using (EditorUserInteraction preventFlikkering = ed.StartUserInteraction(this))
            {
                PromptPointOptions getPntPrmpt = new PromptPointOptions("\nGet Center");
                //Modal Form: will hide because of ed.GetPoint
                PromptPointResult getPnt = ed.GetPoint(getPntPrmpt);
                ed.WriteMessage("\nPoint: {0}", getPnt.Value);
                ed.Regen();
                preventFlikkering.End();
            }
        }

Mentor
SENL1362
Posts: 231
Registered: ‎07-20-2011
Message 2 of 3 (736 Views)

Re: Refresh drawing when modal form is running

01-03-2012 03:12 AM in reply to: lukasz.taraszka

did you tried editor.Regen()

 

c# sample:

       private void Select_Click(object sender, EventArgs e)
        {
            Document doc = Acad.DocumentManager.MdiActiveDocument;
            Database db = doc.Database;
            Editor ed = doc.Editor;
            using (EditorUserInteraction preventFlikkering = ed.StartUserInteraction(this))
            {
                PromptPointOptions getPntPrmpt = new PromptPointOptions("\nGet Center");
                //Modal Form: will hide because of ed.GetPoint
                PromptPointResult getPnt = ed.GetPoint(getPntPrmpt);
                ed.WriteMessage("\nPoint: {0}", getPnt.Value);
                ed.Regen();
                preventFlikkering.End();
            }
        }

Contributor
lukasz.taraszka
Posts: 13
Registered: ‎10-07-2011
Message 3 of 3 (730 Views)

Re: Refresh drawing when modal form is running

01-03-2012 03:55 AM in reply to: SENL1362

No, I have no idea about this method. I tried UpdateScreen but it didn't work.

 

Your post resolved my problem. 

 

Thank You very much.

Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.