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

A couple basic net questions

6 REPLIES 6
Reply
Message 1 of 7
Anonymous
392 Views, 6 Replies

A couple basic net questions

One of the first things I learned doing Arx programming was that the Acad
block table could not be modified. Only the records it contains can be
(modelspace, paperspace). Thus, I never even attempted to open the block
table in write mode, dont know if you can (in Arx). However, most of the .Net
examples I have seen so far do exactly this. They dont attemp to modify the
block table, but they do open it in write mode, then go on to open the block
table records. In fact they pretty much open every table/record in write mode.
Is this the new (.Net) way of dealing with this?
Is there any harm in just opening everything for write, regardless if your
going to modify it or not?
In the same vein, I have to say I do feel kinda weird opening all these objects
(like when Im iterating through the blocktable) and then just leaving them and
waiting for the system to close them. Keep expecting some horrendous crash.
I do dispose() all my databases & transactions in which the table operations reside.

Another question, when starting a transaction against a database, whats the difference
between this code:
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction t = db.TransactionManager.StartTransaction())

and this code?
Document doc = Application.DocumentManager.MdiActiveDocument;
using (Transaction t = doc.TransactionManager.StartTransaction())

The both appear to be using the current database.

Thanks for any insights
Perry
6 REPLIES 6
Message 2 of 7
Anonymous
in reply to: Anonymous

No one's talking about opening the block table, you
have to open each block reference for write.

--
http://www.caddzone.com

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

"perry" wrote in message news:5164605@discussion.autodesk.com...
One of the first things I learned doing Arx programming was that the Acad
block table could not be modified. Only the records it contains can be
(modelspace, paperspace). Thus, I never even attempted to open the block
table in write mode, dont know if you can (in Arx). However, most of the .Net
examples I have seen so far do exactly this. They dont attemp to modify the
block table, but they do open it in write mode, then go on to open the block
table records. In fact they pretty much open every table/record in write mode.
Is this the new (.Net) way of dealing with this?
Is there any harm in just opening everything for write, regardless if your
going to modify it or not?
In the same vein, I have to say I do feel kinda weird opening all these objects
(like when Im iterating through the blocktable) and then just leaving them and
waiting for the system to close them. Keep expecting some horrendous crash.
I do dispose() all my databases & transactions in which the table operations reside.

Another question, when starting a transaction against a database, whats the difference
between this code:
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction t = db.TransactionManager.StartTransaction())

and this code?
Document doc = Application.DocumentManager.MdiActiveDocument;
using (Transaction t = doc.TransactionManager.StartTransaction())

The both appear to be using the current database.

Thanks for any insights
Perry
Message 3 of 7
RonnieWilkins
in reply to: Anonymous

Wouldn't you need to have the BlockTable open for write if you wanted to add a new block?
Ronnie Wilkins, Jr.
Message 4 of 7
Anonymous
in reply to: Anonymous

Tony Tanzillo wrote:
> No one's talking about opening the block table, you
> have to open each block reference for write.
>
Perhaps I did not phrase the question(s) correctly.
I know that you must open a reference for write if you
intend to modify it.
However, does not the following line (from Arx .net labs)
open the block table for write?

//Now, drill into the database and obtain a reference to the BlockTable
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForWrite);
Message 5 of 7
Anonymous
in reply to: Anonymous

rwilkins wrote:
> Wouldn't you need to have the BlockTable open for write if you wanted to add a new block?
But you cannot add/modify the block table. You must work with the block table
records, ie modelspace/paperspace.
Message 6 of 7
Anonymous
in reply to: Anonymous

Apparently Alzheimers is setting in.
My apologies for weird questions.
I could have sworn that the BLOCKTABLE was not
modifyable, that ALL entities belonged to either
modelspace or paperspace. But I just ran the following
code snippet:
BlockTable bt = (BlockTable)t.GetObject(db.BlockTableId, OpenMode.ForWrite);
foreach (ObjectId btrId in bt)
{
BlockTableRecord btr = (BlockTableRecord)t.GetObject(btrId, OpenMode.ForRead);
Utilities.prompt("\nBlocktable record name is: " + btr.Name.ToString());
}
and, as I expected, it returned *modelspace and *paperspace, but it also
returned every other block in the drawing as well.
Guess I'm half right. ALL block defs belong to block table, of which *modelspace
and *paperspace are special cases, and can be listed therein. ALL entities belong to either *modelspace
or *paperspace.

Dont know if I should get a lot more coffee, or just get started on the beer
(Its almost noon here!)
Perry
Message 7 of 7
Anonymous
in reply to: Anonymous

Still curious about the transaction question though!

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