regen

regen

Anonymous
Not applicable
3,213 Views
12 Replies
Message 1 of 13

regen

Anonymous
Not applicable
I've made a program and during the running Autocad regenerates the drawing multiple times.
Therefor I want to surpress this. I've used the command

ApplicationServices.Application.DocumentManager.MdiActiveDocumentdatabase..Regenmode = False

on top of the code. And True on the bottom code.

Now I get the question within Autocad "About to regen proceed OK/Cancel". I want to surpress this question and I want to regen automatically (last line of my code).

How can I do this?
0 Likes
3,214 Views
12 Replies
Replies (12)
Message 2 of 13

arcticad
Advisor
Advisor
You need to set "AUTOREGEN" to ON.
Then you can stop the screen from showing any updates until your done with your code.

LockView
... do stuff
unLockView

{code}
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD

Public Class LockView

Declare Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As Long

Sub lockView()
LockWindowUpdate(ThisDrawing.HWND)
End Sub

Sub unlockView()
LockWindowUpdate(0)
regen()
End Sub

Function ThisDrawing() As AcadDocument
'The COM active drawing
Dim objThisDrawing As AcadDocument
'Get the COM AutoCAD application object
Dim objAcadApp As AcadApplication = CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication, AcadApplication)
Try
'Get the COM active drawing
objThisDrawing = objAcadApp.ActiveDocument
Return objThisDrawing
Catch ex As System.Exception
End Try
Return Nothing
End Function

Sub regen()
Dim MyDWG As Autodesk.AutoCAD.ApplicationServices.Document
MyDWG = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim MyEd As EditorInput.Editor
MyEd = MyDWG.Editor
MyEd.Regen()
End Sub

End Class
{code}
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 3 of 13

Anonymous
Not applicable
I'm sorry, I'm not familiar with interop and the given code gives 2 errors in vb Express 2008

Imports Autodesk.AutoCAD.Interop : VB doesn't find this namespace
AcadDocument: VB doesn't recognize this document

What did I do wrong ?
0 Likes
Message 4 of 13

arcticad
Advisor
Advisor
You need to add a reference to the

"AutoCAD 2010 Type Library"
"AutoCAD/ObjectDBX Common 18.0 Type Library"

go to references and com and find it in the list.

Adjust versions as needed.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 5 of 13

Anonymous
Not applicable
Ok, the interop problem is solved.

But I still get:


"Error 1 Type 'AcadDocument' is not defined."
0 Likes
Message 6 of 13

arcticad
Advisor
Advisor
You need to add a reference to these two dll files
and , in properties, set copy local to false for each.

go to add references and browse and select these two.

c:\Program Files\AutoCAD 2010\

acdbmgd.dll
acmgd.dll
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 7 of 13

Anonymous
Not applicable
I'm not sure where you're getting this from, but LockWindowUpdate()
is not how you prevent updates. In fact, that API should never be used
because It causes the entire desktop to be redrawn when you call it with
an argument of 0.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6352436@discussion.autodesk.com...
You need to set "AUTOREGEN" to ON.
Then you can stop the screen from showing any updates until your done with your
code.

LockView
... do stuff
unLockView

{code}
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD

Public Class LockView

Declare Function LockWindowUpdate Lib "user32" (ByVal hWndLock As Long) As
Long

Sub lockView()
LockWindowUpdate(ThisDrawing.HWND)
End Sub

Sub unlockView()
LockWindowUpdate(0)
regen()
End Sub

Function ThisDrawing() As AcadDocument
'The COM active drawing
Dim objThisDrawing As AcadDocument
'Get the COM AutoCAD application object
Dim objAcadApp As AcadApplication =
CType(Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication,
AcadApplication)
Try
'Get the COM active drawing
objThisDrawing = objAcadApp.ActiveDocument
Return objThisDrawing
Catch ex As System.Exception
End Try
Return Nothing
End Function

Sub regen()
Dim MyDWG As Autodesk.AutoCAD.ApplicationServices.Document
MyDWG =
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
Dim MyEd As EditorInput.Editor
MyEd = MyDWG.Editor
MyEd.Regen()
End Sub

End Class
{code}
0 Likes
Message 8 of 13

Anonymous
Not applicable
Rather than trying to cover up the problem, how about
finding out what's causing it to start with?

What is your code doing that is triggering the regens?


--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6351959@discussion.autodesk.com...
I've made a program and during the running Autocad regenerates the drawing
multiple times.
Therefor I want to surpress this. I've used the command

ApplicationServices.Application.DocumentManager.MdiActiveDocumentdatabase..Regenmode= Falseon top of the code. And True on the bottom code.Now I get the question within Autocad "About to regen proceed OK/Cancel". I wantto surpress this question and I want to regen automatically (last line of mycode).How can I do this?
0 Likes
Message 9 of 13

arcticad
Advisor
Advisor
Hey Tony, I was using the code to zoom around the screen and grab objects using intersectwith. I didn't want the user see all the zooming, turning off the screen temporarily works. The Issue I had was that it didn't work if the lines were off the screen.

as for the argument of 0,
is there a way to only affect the window? I don't know of another cleaner method

Thanks.
---------------------------



(defun botsbuildbots() (botsbuildbots))
0 Likes
Message 10 of 13

Anonymous
Not applicable
I don't think there's any remedy for the problem that LockWindowUpdate()
has, other than not using it.

As far as why you need to zoom the display, I think that's really the
problem. You shouldn't need to do that. If you're using object selection
to find objects, that's not a very reliable to start with.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6352722@discussion.autodesk.com...
Hey Tony, I was using the code to zoom around the screen and grab objects using
intersectwith. I didn't want the user see all the zooming, turning off the
screen temporarily works. The Issue I had was that it didn't work if the lines
were off the screen.

as for the argument of 0,
is there a way to only affect the window? I don't know of another cleaner method

Thanks.
0 Likes
Message 11 of 13

Anonymous
Not applicable
Inside my code: 2 viewports are created: this causes 2 times an automatically regen.

Inside my code I call 10 times a subroutine that replaces text: this causes 10 times an automatically regen.
f.i. tekstreplace("<>", "example") (code subroutine in attach)
I can change the subroutine so that is an "array of strings" is send with the command so that it only regens 1 time.

But the sum of all regens remains 2 + 1 times. That's 2 times too much for me.
That is the reason for me to find a way to set regenauto off (and surpress all messages from autocad) and set it on after all the code has finished.
0 Likes
Message 12 of 13

Anonymous
Not applicable
The code to modify text shouldn't trigger a regen unless it is
called from a command handler, and the command is being
invoked multiple times. You don't show how or where you are
calling from.

If you're modifying multiple objects, you should do it within
a single transaction. Start a transaction before you call the
method that modifies the text, and end the transaction after
you've finished modifying all the text.

As far as creating the viewports go, I don't think there is any
way around that one, and LockWindowUpdate() will not stop
it from happening.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD
Supporting AutoCAD 2000 through 2010

http://www.acadxtabs.com

Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");

wrote in message news:6352802@discussion.autodesk.com...
Inside my code: 2 viewports are created: this causes 2 times an automatically
regen.

Inside my code I call 10 times a subroutine that replaces text: this causes 10
times an automatically regen.
f.i. tekstreplace("<>", "example") (code subroutine in attach)
I can change the subroutine so that is an "array of strings" is send with the
command so that it only regens 1 time.

But the sum of all regens remains 2 + 1 times. That's 2 times too much for me.
That is the reason for me to find a way to set regenauto off (and surpress all
messages from autocad) and set it on after all the code has finished.
0 Likes
Message 13 of 13

Anonymous
Not applicable
Thanks Tony, I understand what I have to modify in my code so that it works more efficient.
In Europe they say: "the ball is now completely on my side"
0 Likes