.NET

Reply
Distinguished Contributor
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 11 of 32 (165 Views)

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
Message 12 of 32 (165 Views)

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
gilseorin
Posts: 177
Registered: ‎09-05-2006
Message 13 of 32 (165 Views)

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
Message 14 of 32 (165 Views)

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
Message 15 of 32 (165 Views)

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
Fatty
Posts: 1,986
Registered: ‎08-02-2004
Message 16 of 32 (165 Views)

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
Message 17 of 32 (165 Views)

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
Message 18 of 32 (165 Views)

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
Message 19 of 32 (165 Views)

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
Fatty
Posts: 1,986
Registered: ‎08-02-2004
Message 20 of 32 (165 Views)

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'~

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community