.NET

Reply
New Member
henkvanes
Posts: 1
Registered: ‎06-01-2007
Message 1 of 4 (262 Views)

Writing summaryInfo inside web service

262 Views, 3 Replies
06-01-2007 07:06 AM
Hey,

I want to read a custom property inside a .dwg file. I have the follwing code (c#) inside a web service (on the web server we have autocad installed) :

AcadApplication theApp = null;
AcadDocument theDoc = null;
try
{
// try get a running instance first
// if this fails it throws an exception
theApp = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.17");
}
catch
{
// try to create a new instance of autocad
theApp = new AcadApplication();
}

theDoc = theApp.Documents.Open(Documentpath, null, null);

string theValue = string.Empty;
theDoc.SummaryInfo.GetCustomByKey(propertyName, out theValue);

if (theDoc != null)
theDoc.Close(false, null);


This code doesn't work when run under IIS using the default IUSR_XXX user. I works when run under a console applicatio n or using the visual studio web server (which runs under the current user), but the first time always give a problem creating an instance of the application object When autocad is already running is works fine. Does anyone have a clue.

Also is it possible to read custom properties from the summaryinfo without having autocad installed?

regards,
Henk
*Norman Yuan
Message 2 of 4 (262 Views)

Re: Writing summaryInfo inside web service

06-01-2007 09:04 AM in reply to: henkvanes
By default the account used run wep application has very limited access to
the computer resources (ASPNET, Network sevice, or IUSER_XXXX, depending on
your OS and the wep app's configuration). AutoCAD, as a compicated, rich
desktop application, certainly demanding more resources. So, you need to
configure your web app (web services, in your case) to run under a user
account with enough previlige. You might have to consider to impersonate to
a local power user or a domain account.

With that said, using AutoCAD in a service, especially a web service, is
highly not recommended. For example, just openning a drawing in Acad, you
may run into many possible problems that are very likely result in a message
box pops up and block the Acad from continuing. Do yo expect some go to the
server room so often to dismiss these possible message boxes?

Also, to use Acad this way, you may violate the Acad lisence (I am not very
certain on this, though).


wrote in message news:5613584@discussion.autodesk.com...
Hey,

I want to read a custom property inside a .dwg file. I have the follwing
code (c#) inside a web service (on the web server we have autocad installed)
:

AcadApplication theApp = null;
AcadDocument theDoc = null;
try
{
// try get a running instance first
// if this fails it throws an exception
theApp = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.17");
}
catch
{
// try to create a new instance of autocad
theApp = new AcadApplication();
}

theDoc = theApp.Documents.Open(Documentpath, null, null);

string theValue = string.Empty;
theDoc.SummaryInfo.GetCustomByKey(propertyName, out theValue);

if (theDoc != null)
theDoc.Close(false, null);


This code doesn't work when run under IIS using the default IUSR_XXX user. I
works when run under a console applicatio n or using the visual studio web
server (which runs under the current user), but the first time always give a
problem creating an instance of the application object When autocad is
already running is works fine. Does anyone have a clue.

Also is it possible to read custom properties from the summaryinfo without
having autocad installed?

regards,
Henk
*J. Daniel Smith
Message 3 of 4 (262 Views)

Re: Writing summaryInfo inside web service

06-02-2007 02:09 PM in reply to: henkvanes
The code you show uses the ActiveX automation API; that is not the same
thing as the .NET API for AutoCAD which is the topic of this newsgroup.

Part of the solution (as far as this newsgroup is concerned) is to use the
.NET version of RealDWG (ObjectDBX) which will allow you to manipulate DWG
files w/o having AutoCAD installed. Unlike ObjectARX (and the accompanying
.NET APIs), RealDWG is not freely available.

Also, as has already been suggested in another reply, instantiating an
AutoCAD instance in a server application is not recommended and may violate
the license agreement:
3.2.4 Hosting or Third Party Use. You may not Install or Access, or allow
the Installation or Access of, the Autodesk Materials over the Internet,
including, without limitation, use in connection with a Web hosting,
commercial time-sharing, service bureau or similar service, or make the
Autodesk Materials available to third parties via the Internet on Your
computer system or otherwise. ...

Dan

"henkvanes" wrote in message news:5613584@discussion.autodesk.com...
Hey,

I want to read a custom property inside a .dwg file. I have the follwing
code (c#) inside a web service (on the web server we have autocad installed)
:

AcadApplication theApp = null;
AcadDocument theDoc = null;
try
{
// try get a running instance first
// if this fails it throws an exception
theApp = (AcadApplication)Marshal.GetActiveObject("AutoCAD.Application.17");
}
catch
{
// try to create a new instance of autocad
theApp = new AcadApplication();
}

theDoc = theApp.Documents.Open(Documentpath, null, null);

string theValue = string.Empty;
theDoc.SummaryInfo.GetCustomByKey(propertyName, out theValue);

if (theDoc != null)
theDoc.Close(false, null);


This code doesn't work when run under IIS using the default IUSR_XXX user. I
works when run under a console applicatio n or using the visual studio web
server (which runs under the current user), but the first time always give a
problem creating an instance of the application object When autocad is
already running is works fine. Does anyone have a clue.

Also is it possible to read custom properties from the summaryinfo without
having autocad installed?

regards,
Henk
Distinguished Contributor
dmarcotte4
Posts: 195
Registered: ‎04-02-2005
Message 4 of 4 (262 Views)

Re: Writing summaryInfo inside web service

06-03-2007 03:24 AM in reply to: henkvanes
Also is it possible to read custom properties from the summaryinfo without having autocad installed?


Maybe you can retrieve this data directly from a DXF file under
$CUSTOMPROPERTYTAG
and
$CUSTOMPROPERTY
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Are You Going To Be @ AU 2014? Feel free to drop by our AU topic post and share your plans, plug a class that you're teaching, or simply check out who else from the community might be in attendance. Ohh and don't forgot to stop by the Autodesk Help | Learn | Collaborate booths in the Exhibit Hall and meet our community team if you get a chance!