.NET

Reply
Distinguished Contributor
177 Posts
0 Kudos
Registered: ‎09-05-2006
Post 11 of 32

Re: Creating .dwg file Programmatically

02-24-2007 10:25 PM in reply to: Prakashdotc
Yes, you're right.
I already knew from previous post in this site.
I just wish to know the above method shown by deepa is valid or not.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Public Class GILSclass1
_
Public Sub CreateDrawingFile()
Dim db As Database = New Database(True, True)
db.SaveAs("C:\temp\MySecond.dwg", DwgVersion.Newest)
db.Dispose()
End Sub
End Class
*Paul Richardson
Post 12 of 32

Re: Creating .dwg file Programmatically

02-25-2007 02:07 AM in reply to: Prakashdotc
I got ya... But you tried it...~)
If you want to work on that doc now in the current document context - open
it and lock it.
Also pass "CommandSession.Flags" to your CommandMethod

[CommandMethod("SMD", CommandSession.Flags)]
...
Document newDoc = Application.DocumentManager.Open(dwgpath, false);
newDoc.LockDocument();
//now it's your active database - add lines or such as questioned by the OP.

wrote in message news:5499219@discussion.autodesk.com...
Yes, you're right.
I already knew from previous post in this site.
I just wish to know the above method shown by deepa is valid or not.

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.DatabaseServices
Public Class GILSclass1
_
Public Sub CreateDrawingFile()
Dim db As Database = New Database(True, True)
db.SaveAs("C:\temp\MySecond.dwg", DwgVersion.Newest)
db.Dispose()
End Sub
End Class
Distinguished Contributor
177 Posts
0 Kudos
Registered: ‎09-05-2006
Post 13 of 32

Re: Creating .dwg file Programmatically

02-25-2007 08:19 AM in reply to: Prakashdotc
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
Post 14 of 32

Re: Creating .dwg file Programmatically

02-25-2007 08:59 AM in reply to: Prakashdotc
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
Post 15 of 32

Re: Creating .dwg file Programmatically

02-25-2007 09:24 AM in reply to: Prakashdotc
>DocumentCollection docs
= Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
This is not used in the attached file - I should have deleted it.

"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.
Distinguished Contributor
1,986 Posts
4 Kudos
Registered: ‎08-02-2004
Post 16 of 32

Re: Creating .dwg file Programmatically

02-25-2007 12:34 PM in reply to: Prakashdotc
Paul, can you upload a similar example
for VS .NET 2003 / Acad2005 on VB.NET
Your prior example does not worked for me
Problem is on, I have not found on Browser
EditorInput in my VS version

Thanks in advance,

Fatty

~'J'~
*Paul Richardson
Post 17 of 32

Re: Creating .dwg file Programmatically

02-25-2007 01:52 PM in reply to: Prakashdotc
I don't have 05 installed. If you must use it to learn try getting the
ARX api - although I would avoid it as it was the first incarnation
of the api and not very complete. Not much help/samples available.

How about downloading the Acad07 trial and an Express version
of the .net compilers. Many samples with the ARX api and some
labs available from Autodesk. Also I would start with running
commands in the document context and worry about the session
context once you get up and running.

wrote in message news:5499463@discussion.autodesk.com...
Paul, can you upload a similar example
for VS .NET 2003 / Acad2005 on VB.NET
Your prior example does not worked for me
Problem is on, I have not found on Browser
EditorInput in my VS version

Thanks in advance,

Fatty

~'J'~
*Tony Tanzillo
Post 18 of 32

Re: Creating .dwg file Programmatically

02-25-2007 01:55 PM in reply to: Prakashdotc
>> 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
Post 19 of 32

Re: Creating .dwg file Programmatically

02-25-2007 02:06 PM in reply to: Prakashdotc
Sweet! Thanks Tony. I couldn't find an unlock method so
assumed it was just magic..~)
"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.
Distinguished Contributor
1,986 Posts
4 Kudos
Registered: ‎08-02-2004
Post 20 of 32

Re: Creating .dwg file Programmatically

02-25-2007 02:32 PM in reply to: Prakashdotc
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'~
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are you interested in helping shape the future of the Autodesk Community? To participate in this brief usability study, please click here. Your time and input is greatly appreciated!