What's the best way to refresh the drawing after adding blocks?

What's the best way to refresh the drawing after adding blocks?

Anonymous
Not applicable
2,567 Views
8 Replies
Message 1 of 9

What's the best way to refresh the drawing after adding blocks?

Anonymous
Not applicable
Hi,

I've got some C# code (VS 2003 and AutoCAD 2006) that adds some blocks to a
drawing. It works, but the blocks are initially invisible. I have to pan
or zoom (or do anything, as far as I know) for them to appear.

I'd like to try calling the Zoom command with a scale of 1x. How do I
accomplish this from .NET?

Thanks so much for any help.
-Carlos
0 Likes
2,568 Views
8 Replies
Replies (8)
Message 2 of 9

Anonymous
Not applicable
Have you tried calling TransactionManager.FlushGraphics ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message news:[email protected]...
Hi,

I've got some C# code (VS 2003 and AutoCAD 2006) that adds some blocks to a
drawing. It works, but the blocks are initially invisible. I have to pan
or zoom (or do anything, as far as I know) for them to appear.

I'd like to try calling the Zoom command with a scale of 1x. How do I
accomplish this from .NET?

Thanks so much for any help.
-Carlos
0 Likes
Message 3 of 9

Anonymous
Not applicable
That sounds like what I want, but for some reason FlushGraphics is not
listed as a method of TransactionManager. I see QueueForGraphicsFlush, but
not FlushGraphics. How is that method used?

Here's my code:

Database db=Application.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.TransactionManager TM =
db.TransactionManager;
Transaction trans = TM.StartTransaction();

try
{
<<>>
trans.Commit();
}
catch
{
}
finally
{
trans.Dispose();
TM.FlushGraphics(); ???
Autodesk.AutoCAD.DatabaseServices.TransactionManager.FlushGraphics?
}





"Tony Tanzillo" wrote in message
news:[email protected]...
Have you tried calling TransactionManager.FlushGraphics ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
Hi,

I've got some C# code (VS 2003 and AutoCAD 2006) that adds some blocks to a
drawing. It works, but the blocks are initially invisible. I have to pan
or zoom (or do anything, as far as I know) for them to appear.

I'd like to try calling the Zoom command with a scale of 1x. How do I
accomplish this from .NET?

Thanks so much for any help.
-Carlos
0 Likes
Message 4 of 9

Anonymous
Not applicable
There are two of them:

Autodesk.AutoCAD.ApplicationServices.TransactionManager
Autodesk.AutoCAD.DatabaseServices.TransactionManager

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message news:[email protected]...
That sounds like what I want, but for some reason FlushGraphics is not
listed as a method of TransactionManager. I see QueueForGraphicsFlush, but
not FlushGraphics. How is that method used?

Here's my code:

Database db=Application.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.TransactionManager TM =
db.TransactionManager;
Transaction trans = TM.StartTransaction();

try
{
<<>>
trans.Commit();
}
catch
{
}
finally
{
trans.Dispose();
TM.FlushGraphics(); ???
Autodesk.AutoCAD.DatabaseServices.TransactionManager.FlushGraphics?
}





"Tony Tanzillo" wrote in message
news:[email protected]...
Have you tried calling TransactionManager.FlushGraphics ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
Hi,

I've got some C# code (VS 2003 and AutoCAD 2006) that adds some blocks to a
drawing. It works, but the blocks are initially invisible. I have to pan
or zoom (or do anything, as far as I know) for them to appear.

I'd like to try calling the Zoom command with a scale of 1x. How do I
accomplish this from .NET?

Thanks so much for any help.
-Carlos
0 Likes
Message 5 of 9

Anonymous
Not applicable
Thanks very much for your help so far, but FlushGraphics doesn't seem to be
doing the trick. Am I calling it incorrectly? My code is attached in a
text file.

I've noticed that the PAN command seems to be the only thing that will make
things work (as opposed to what I thought earlier). If I insert the blocks
from C# and then type Redrawall, Regenall, or Zoom 1x, the last block that
was inserted remains invisible until I pan. If I move my mouse over the
block, a dotted outline appears, but the block does not remain visible until
I pan.

Any other ideas?

Thanks again.
-Carlos


"Tony Tanzillo" wrote in message
news:[email protected]...
There are two of them:

Autodesk.AutoCAD.ApplicationServices.TransactionManager
Autodesk.AutoCAD.DatabaseServices.TransactionManager

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
That sounds like what I want, but for some reason FlushGraphics is not
listed as a method of TransactionManager. I see QueueForGraphicsFlush, but
not FlushGraphics. How is that method used?

Here's my code:

Database db=Application.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.TransactionManager TM =
db.TransactionManager;
Transaction trans = TM.StartTransaction();

try
{
<<>>
trans.Commit();
}
catch
{
}
finally
{
trans.Dispose();
TM.FlushGraphics(); ???
Autodesk.AutoCAD.DatabaseServices.TransactionManager.FlushGraphics?
}





"Tony Tanzillo" wrote in message
news:[email protected]...
Have you tried calling TransactionManager.FlushGraphics ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
Hi,

I've got some C# code (VS 2003 and AutoCAD 2006) that adds some blocks to a
drawing. It works, but the blocks are initially invisible. I have to pan
or zoom (or do anything, as far as I know) for them to appear.

I'd like to try calling the Zoom command with a scale of 1x. How do I
accomplish this from .NET?

Thanks so much for any help.
-Carlos
0 Likes
Message 6 of 9

Anonymous
Not applicable
Since you're doing this in a modal command handler,
there should be no problem like this.

You're not showing the whole picture, so can you
confirm that the code that creates the new entities
calsl AddNewlyCreatedDBObject() ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message news:[email protected]...
Thanks very much for your help so far, but FlushGraphics doesn't seem to be
doing the trick. Am I calling it incorrectly? My code is attached in a
text file.

I've noticed that the PAN command seems to be the only thing that will make
things work (as opposed to what I thought earlier). If I insert the blocks
from C# and then type Redrawall, Regenall, or Zoom 1x, the last block that
was inserted remains invisible until I pan. If I move my mouse over the
block, a do
tted outline appears, but the block does not remain visible until
I pan.

Any other ideas?

Thanks again.
-Carlos


"Tony Tanzillo" wrote in message
news:[email protected]...
There are two of them:

Autodesk.AutoCAD.ApplicationServices.TransactionManager
Autodesk.AutoCAD.DatabaseServices.TransactionManager

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" <
carlos at sensametrics dot com> wrote in message
news:[email protected]...
That sounds like what I want, but for some reason FlushGraphics is not
listed as a method of TransactionManager. I see QueueForGraphicsFlush, but
not FlushGraphics. How is that method used?

Here's my code:

Database db=Application.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.TransactionManager TM =

db.TransactionManager;
Transaction trans = TM.StartTransaction();

try
{
<<>>
trans.Commit();
}
catch
{
}
finally
{
trans.Dispose();
TM.FlushGraphics(); ???
Autodesk.AutoCAD.DatabaseServices.TransactionManager.FlushGraphics?
}





"Tony Tanzillo" wrote in message
news:[email protected]...
Have you tried calling TransactionManager.FlushGraphics ?

--
http://www.cadd
zone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
Hi,

I've got some C# code (VS 2003 and AutoCAD 2006) that adds some blocks to a
drawing. It works, but the blocks are initially invisible. I have to pan
or zoom (or do anything, as far as I know) for them to appear.

I'd like to try calling the Zoom command with a scale of 1x. How do I
accomplish thi
s from .NET?

Thanks so much for any help.
-Carlos
0 Likes
Message 7 of 9

Anonymous
Not applicable
I'm fairly sure the call to AddNewlyCreatedDBObject is working, but I've
attached the code for actually inserting the blocks into AutoCAD just in
case.

I've tried all sorts of stuff. Can you see the problem?

Thanks,
Carlos

"Tony Tanzillo" wrote in message
news:[email protected]...
Since you're doing this in a modal command handler,
there should be no problem like this.

You're not showing the whole picture, so can you
confirm that the code that creates the new entities
calsl AddNewlyCreatedDBObject() ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
Thanks very much for your help so far, but FlushGraphics doesn't seem to be
doing the trick. Am I calling it incorrectly? My code is attached in a
text file.

I've noticed that the PAN command seems to be the only thing that will make
things work (as opposed to what I thought earlier). If I insert the blocks
from C# and then type Redrawall, Regenall, or Zoom 1x, the last block that
was inserted remains invisible until I pan. If I move my mouse over the
block, a do
tted outline appears, but the block does not remain visible until
I pan.

Any other ideas?

Thanks again.
-Carlos


"Tony Tanzillo" wrote in message
news:[email protected]...
There are two of them:

Autodesk.AutoCAD.ApplicationServices.TransactionManager
Autodesk.AutoCAD.DatabaseServices.TransactionManager

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" <
carlos at sensametrics dot com> wrote in message
news:[email protected]...
That sounds like what I want, but for some reason FlushGraphics is not
listed as a method of TransactionManager. I see QueueForGraphicsFlush, but
not FlushGraphics. How is that method used?

Here's my code:

Database db=Application.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.TransactionManager TM =

db.TransactionManager;
Transaction trans = TM.StartTransaction();

try
{
<<>>
trans.Commit();
}
catch
{
}
finally
{
trans.Dispose();
TM.FlushGraphics(); ???
Autodesk.AutoCAD.DatabaseServices.TransactionManager.FlushGraphics?
}





"Tony Tanzillo" wrote in message
news:[email protected]...
Have you tried calling TransactionManager.FlushGraphics ?

--
http://www.cadd
zone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
Hi,

I've got some C# code (VS 2003 and AutoCAD 2006) that adds some blocks to a
drawing. It works, but the blocks are initially invisible. I have to pan
or zoom (or do anything, as far as I know) for them to appear.

I'd like to try calling the Zoom command with a scale of 1x. How do I
accomplish thi
s from .NET?

Thanks so much for any help.
-Carlos
0 Likes
Message 8 of 9

Anonymous
Not applicable
As a side note,

I've never had to use the call to db.ReadDwgFile() because the condition
(bt.Has("Sensing Unit")) has always been met. I've had some issues with
that call anyway, so that is why it's commented out.

-Carlos


"Tony Tanzillo" wrote in message
news:[email protected]...
Since you're doing this in a modal command handler,
there should be no problem like this.

You're not showing the whole picture, so can you
confirm that the code that creates the new entities
calsl AddNewlyCreatedDBObject() ?

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
Thanks very much for your help so far, but FlushGraphics doesn't seem to be
doing the trick. Am I calling it incorrectly? My code is attached in a
text file.

I've noticed that the PAN command seems to be the only thing that will make
things work (as opposed to what I thought earlier). If I insert the blocks
from C# and then type Redrawall, Regenall, or Zoom 1x, the last block that
was inserted remains invisible until I pan. If I move my mouse over the
block, a do
tted outline appears, but the block does not remain visible until
I pan.

Any other ideas?

Thanks again.
-Carlos


"Tony Tanzillo" wrote in message
news:[email protected]...
There are two of them:

Autodesk.AutoCAD.ApplicationServices.TransactionManager
Autodesk.AutoCAD.DatabaseServices.TransactionManager

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" <
carlos at sensametrics dot com> wrote in message
news:[email protected]...
That sounds like what I want, but for some reason FlushGraphics is not
listed as a method of TransactionManager. I see QueueForGraphicsFlush, but
not FlushGraphics. How is that method used?

Here's my code:

Database db=Application.DocumentManager.MdiActiveDocument.Database;
Autodesk.AutoCAD.DatabaseServices.TransactionManager TM =

db.TransactionManager;
Transaction trans = TM.StartTransaction();

try
{
<<>>
trans.Commit();
}
catch
{
}
finally
{
trans.Dispose();
TM.FlushGraphics(); ???
Autodesk.AutoCAD.DatabaseServices.TransactionManager.FlushGraphics?
}





"Tony Tanzillo" wrote in message
news:[email protected]...
Have you tried calling TransactionManager.FlushGraphics ?

--
http://www.cadd
zone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"Carlos" wrote in message
news:[email protected]...
Hi,

I've got some C# code (VS 2003 and AutoCAD 2006) that adds some blocks to a
drawing. It works, but the blocks are initially invisible. I have to pan
or zoom (or do anything, as far as I know) for them to appear.

I'd like to try calling the Zoom command with a scale of 1x. How do I
accomplish thi
s from .NET?

Thanks so much for any help.
-Carlos
0 Likes
Message 9 of 9

Anonymous
Not applicable
Hi,

Did you already try to use this:
Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor.UpdateScreen();

Pedro Henrique Liberato, sorry the 'little' delay and the poor English 🙂
0 Likes