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

How to draw immediately?

3 REPLIES 3
Reply
Message 1 of 4
Bernd_L
387 Views, 3 Replies

How to draw immediately?

Hi there,

in my application I am drawing several thousands of objects following this scheme:

Line^ linie = gcnew Line();

Database^ dwg = HostApplicationServices::WorkingDatabase;
TransactionManager^ tm = dwg->TransactionManager;
Transaction^ ta = tm->StartTransaction();

try
{
linie->StartPoint = Point3d(xVon, yVon, 0.0);
linie->EndPoint = Point3d(xNach, yNach, 0.0);
linie->Layer = layer;

BlockTable^ bt = (BlockTable^)tm->GetObject(dwg->BlockTableId, OpenMode::ForRead);
BlockTableRecord^ modelSpace =
(BlockTableRecord^)tm->GetObject(bt[BlockTableRecord::ModelSpace], OpenMode::ForWrite);

modelSpace->AppendEntity(linie);
handle = linie->Handle.Value;

ta->AddNewlyCreatedDBObject(linie, true);
ta->Commit();
}

catch (Autodesk::AutoCAD::Runtime::Exception^ e)
{
ta->Abort();
return -1;
}

finally
{
delete ta;
}

But unfortunately the graphic's only being drawn at the end of my function, whereas I'd rather like to have it being drawn as the objects are being created. Any idea, how to accomplish that?
Another question is: what's the difference between TransactionManager::Commit() and Transaction::Commit() ?
At least in my code it doesn't change anything making this call or that.
Thanks in advance, Bernd
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Bernd_L

That's usually what we prefer happen (the screen is not updated until all of many objects are created).

If you need to see the objects as they're being added to the database, try using the FlushGraphics() and EnableGraphicsFlush() methods of the Document's TransactionManager, and the Editor's UpdateScreen() method.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:6008899@discussion.autodesk.com...
Hi there,

in my application I am drawing several thousands of objects following this scheme:

Line^ linie = gcnew Line();

Database^ dwg = HostApplicationServices::WorkingDatabase;
TransactionManager^ tm = dwg->TransactionManager;
Transaction^ ta = tm->StartTransaction();

try
{
linie->StartPoint = Point3d(xVon, yVon, 0.0);
linie->EndPoint = Point3d(xNach, yNach, 0.0);
linie->Layer = layer;

BlockTable^ bt = (BlockTable^)tm->GetObject(dwg->BlockTableId, OpenMode::ForRead);
BlockTableRecord^ modelSpace =
(BlockTableRecord^)tm->GetObject(bt[BlockTableRecord::ModelSpace], OpenMode::ForWrite);

modelSpace->AppendEntity(linie);
handle = linie->Handle.Value;

ta->AddNewlyCreatedDBObject(linie, true);
ta->Commit();
}

catch (Autodesk::AutoCAD::Runtime::Exception^ e)
{
ta->Abort();
return -1;
}

finally
{
delete ta;
}

But unfortunately the graphic's only being drawn at the end of my function, whereas I'd rather like to have it being drawn as the objects are being created. Any idea, how to accomplish that?
Another question is: what's the difference between TransactionManager::Commit() and Transaction::Commit() ?
At least in my code it doesn't change anything making this call or that.
Thanks in advance, Bernd
Message 3 of 4
Bernd_L
in reply to: Bernd_L

I have a big drawing with cadastral elements in it and so it's a nice effect watching the drawing being build up. As every creation of an element is packed in a single transaction (which is probably not a good idea from a performance point of view), I found out that it is sufficient to make a call to Editor::UpdateScreen(), thanks for that.
Any idea, what my second questions concerns (difference between the two Commit() methods)?
Message 4 of 4
Anonymous
in reply to: Bernd_L

The TransactionManager operates on the top transaction.

--
http://www.caddzone.com

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

http://www.acadxtabs.com

Introducing AcadXTabs 2010:
http://www.caddzone.com/acadxtabs/AcadXTabs2010.htm

wrote in message news:6009588@discussion.autodesk.com...
I have a big drawing with cadastral elements in it and so it's a nice effect watching the drawing being build up. As every creation of an element is packed in a single transaction (which is probably not a good idea from a performance point of view), I found out that it is sufficient to make a call to Editor::UpdateScreen(), thanks for that.
Any idea, what my second questions concerns (difference between the two Commit() methods)?

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