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

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

8 REPLIES 8
Reply
Message 1 of 9
Anonymous
1602 Views, 8 Replies

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

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
8 REPLIES 8
Message 2 of 9
Anonymous
in reply to: Anonymous

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:4936528@discussion.autodesk.com...
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
Message 3 of 9
Anonymous
in reply to: Anonymous

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:4936774@discussion.autodesk.com...
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:4936528@discussion.autodesk.com...
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
Message 4 of 9
Anonymous
in reply to: Anonymous

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:4936807@discussion.autodesk.com...
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:4936774@discussion.autodesk.com...
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:4936528@discussion.autodesk.com...
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
Message 5 of 9
Anonymous
in reply to: Anonymous

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:4936836@discussion.autodesk.com...
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:4936807@discussion.autodesk.com...
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:4936774@discussion.autodesk.com...
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:4936528@discussion.autodesk.com...
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
Message 6 of 9
Anonymous
in reply to: Anonymous

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:4936876@discussion.autodesk.com...
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:4936836@discussion.autodesk.com...
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:4936807@discussion.autodesk.com...
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:4936774@discussion.autodesk.com...
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:4936528@discussion.autodesk.com...
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
Message 7 of 9
Anonymous
in reply to: Anonymous

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:4936905@discussion.autodesk.com...
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:4936876@discussion.autodesk.com...
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:4936836@discussion.autodesk.com...
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:4936807@discussion.autodesk.com...
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:4936774@discussion.autodesk.com...
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:4936528@discussion.autodesk.com...
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
Message 8 of 9
Anonymous
in reply to: Anonymous

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:4936905@discussion.autodesk.com...
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:4936876@discussion.autodesk.com...
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:4936836@discussion.autodesk.com...
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:4936807@discussion.autodesk.com...
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:4936774@discussion.autodesk.com...
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:4936528@discussion.autodesk.com...
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
Message 9 of 9
phol
in reply to: Anonymous

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 🙂

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