.NET

Reply
*Paul Richardson
Message 21 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-25-2007 02:44 PM in reply to: Prakashdotc
Is this nested properly?
[code]
using (Transaction tr = ed.Document.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId,
OpenMode.ForRead);
ObjectId blkRecId = bt[BlockTableRecord.ModelSpace];

using (DocumentLock myLock = newDoc.LockDocument())
{
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(blkRecId,
OpenMode.ForWrite);
btr.AppendEntity(line);
tr.AddNewlyCreatedDBObject(line, true);
}

tr.Commit();
}
[/code]

"Tony Tanzillo" wrote in message
news:5499486@discussion.autodesk.com...
>> newDoc.LockDocument();

The result of LockDocument() must be
Disposed() of explicitly, because that is
what unlocks the document.

If you let the runtime do it (e.g., whenever
it gets around to it), the document remains
locked until that happens.

So,

using( DocumentLock myLock = newDoc.LockDocument() )
{
// work with locked document here

} // document is unlocked here


--
http://www.caddzone.com

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

"Paul Richardson" wrote in message
news:5499364@discussion.autodesk.com...
CommandFlags.Session -> makes the command available in the application
context
instead of just the calling doc.

newDoc.LockDocument ->Before you edit a doc you must lock it. When an app
runs
in the doc context the doc is locked for you. Others must be locked
manually.

Attached is a sample of a test. Keyword test!



wrote in message news:5499346@discussion.autodesk.com...
Thank you,Palul.

What I can clear. ---> Adding commandFlags.Session,

newDoc is activated to the current drawing.

What I can get. --->I don't know what change was made with using
method of newDoc.LockDocument.
*Paul Richardson
Message 22 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-25-2007 02:47 PM in reply to: Prakashdotc
The api has not only matured - how you work with it has changed.
Time to upgrade...)

wrote in message news:5499516@discussion.autodesk.com...
Thanks for the quick reply
I agree I need to install a newer
VS version on my machine
I saw Acad07 Training VB.NET
and main problem is on many stuffs
frome there are not available for me

Regards,

Fatty

~'J'~
Active Contributor
deepa
Posts: 37
Registered: ‎01-10-2007
Message 23 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-25-2007 07:39 PM in reply to: Prakashdotc
Sweet!Thank u gilseorin
Active Contributor
deepa
Posts: 37
Registered: ‎01-10-2007
Message 24 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-25-2007 07:44 PM in reply to: Prakashdotc
Paul ,

I have one doubt.How to get the number of levels for nested Block in .net?Pls explain details with example.
*Tony Tanzillo
Message 25 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-25-2007 08:16 PM in reply to: Prakashdotc
"Paul Richardson" wrote

>> Is this nested properly?

Easy to determine this yourself. You just have
to be sure that anything that you do which
requires the document to be locked, must be
placed within the scope of the lock variable.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006/2007
http://www.acadxtabs.com
Active Contributor
deepa
Posts: 37
Registered: ‎01-10-2007
Message 26 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-25-2007 08:32 PM in reply to: Prakashdotc
no tony.

I dont want to place the nested Block tony.I need to get all the nested Block and I want to Calculate number of Levels for the nested Block in .net.

Pls help me
*Tony Tanzillo
Message 27 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-25-2007 09:17 PM in reply to: Prakashdotc
I see no reason to not also nest the read-only
operations in the lock scope, for the sake of
clarity.

Also, you can dispense with one pair of curly
braces when you have two using() clauses
with the same scope, like this:

public void singleblock()
{
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
DocumentLock doclock = doc.LockDocument();
Transaction trans = doc.TransactionManager.StartTransaction();
using( doclock )
using( trans )
{
// Do stuff here
}
}

which is precisely equivlent to:

public void multipleblock()
{
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
using( DocumentLock doclock = doc.LockDocument() )
{
using( Transaction trans = doc.TransactionManager.StartTransaction() )
{
// Do stuff here
}
}
}

that works because using() is like many other
constructs that can precede either a single line
of code, or a block of code:

if( test )
{
then();
}

verses

if( test )
then();



--
http://www.caddzone.com

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

"Paul Richardson" wrote in message news:5499519@discussion.autodesk.com...
Is this nested properly?
[code]
using (Transaction tr = ed.Document.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId,
OpenMode.ForRead);
ObjectId blkRecId = bt[BlockTableRecord.ModelSpace];

using (DocumentLock myLock = newDoc.LockDocument())
{
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(blkRecId,
OpenMode.ForWrite);
btr.AppendEntity(line);
tr.AddNewlyCreatedDBObject(line, true);
}

tr.Commit();
}
[/code]

"Tony Tanzillo" wrote in message
news:5499486@discussion.autodesk.com...
>> newDoc.LockDocument();

The result of LockDocument() must be
Disposed() of explicitly, because that is
what unlocks the document.

If you let the runtime do it (e.g., whenever
it gets around to it), the document remains
locked until that happens.

So,

using( DocumentLock myLock = newDoc.LockDocument() )
{
// work with locked document here

} // document is unlocked here


--
http://www.caddzone.com

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

"Paul Richardson" wrote in message
news:5499364@discussion.autodesk.com...
CommandFlags.Session -> makes the command available in the application
context
instead of just the calling doc.

newDoc.LockDocument ->Before you edit a doc you must lock it. When an app
runs
in the doc context the doc is locked for you. Others must be locked
manually.

Attached is a sample of a test. Keyword test!



wrote in message news:5499346@discussion.autodesk.com...
Thank you,Palul.

What I can clear. ---> Adding commandFlags.Session,

newDoc is activated to the current drawing.

What I can get. --->I don't know what change was made with using
method of newDoc.LockDocument.
*Tony Tanzillo
Message 28 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-26-2007 12:16 AM in reply to: Prakashdotc
I was talking about code blocks, not drawing
blocks.

This is not an online classroom. Contact
Autodesk and ask them if they have any
API training classes in your area.

--
http://www.caddzone.com

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

wrote in message news:5499671@discussion.autodesk.com...
no tony.

I dont want to place the nested Block tony.I need to get all the nested Block and I want to Calculate number of Levels for the nested Block in .net.

Pls help me
Active Contributor
deepa
Posts: 37
Registered: ‎01-10-2007
Message 29 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-26-2007 02:31 AM in reply to: Prakashdotc
Thanks Tony.
*Paul Richardson
Message 30 of 32 (95 Views)

Re: Creating .dwg file Programmatically

02-26-2007 03:26 AM in reply to: Prakashdotc
Thank you - Much appreciated!
"Tony Tanzillo" wrote in message
news:5499666@discussion.autodesk.com...
I see no reason to not also nest the read-only
operations in the lock scope, for the sake of
clarity.

Also, you can dispense with one pair of curly
braces when you have two using() clauses
with the same scope, like this:

public void singleblock()
{
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
DocumentLock doclock = doc.LockDocument();
Transaction trans = doc.TransactionManager.StartTransaction();
using( doclock )
using( trans )
{
// Do stuff here
}
}

which is precisely equivlent to:

public void multipleblock()
{
Document doc = AcadApp.DocumentManager.MdiActiveDocument;
using( DocumentLock doclock = doc.LockDocument() )
{
using( Transaction trans =
doc.TransactionManager.StartTransaction() )
{
// Do stuff here
}
}
}

that works because using() is like many other
constructs that can precede either a single line
of code, or a block of code:

if( test )
{
then();
}

verses

if( test )
then();



--
http://www.caddzone.com

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

"Paul Richardson" wrote in message
news:5499519@discussion.autodesk.com...
Is this nested properly?
[code]
using (Transaction tr = ed.Document.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)tr.GetObject(db.BlockTableId,
OpenMode.ForRead);
ObjectId blkRecId = bt[BlockTableRecord.ModelSpace];

using (DocumentLock myLock = newDoc.LockDocument())
{
BlockTableRecord btr = (BlockTableRecord)tr.GetObject(blkRecId,
OpenMode.ForWrite);
btr.AppendEntity(line);
tr.AddNewlyCreatedDBObject(line, true);
}

tr.Commit();
}
[/code]

"Tony Tanzillo" wrote in message
news:5499486@discussion.autodesk.com...
>> newDoc.LockDocument();

The result of LockDocument() must be
Disposed() of explicitly, because that is
what unlocks the document.

If you let the runtime do it (e.g., whenever
it gets around to it), the document remains
locked until that happens.

So,

using( DocumentLock myLock = newDoc.LockDocument() )
{
// work with locked document here

} // document is unlocked here


--
http://www.caddzone.com

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

"Paul Richardson" wrote in message
news:5499364@discussion.autodesk.com...
CommandFlags.Session -> makes the command available in the application
context
instead of just the calling doc.

newDoc.LockDocument ->Before you edit a doc you must lock it. When an app
runs
in the doc context the doc is locked for you. Others must be locked
manually.

Attached is a sample of a test. Keyword test!



wrote in message news:5499346@discussion.autodesk.com...
Thank you,Palul.

What I can clear. ---> Adding commandFlags.Session,

newDoc is activated to the current drawing.

What I can get. --->I don't know what change was made with using
method of newDoc.LockDocument.
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.