.NET

Reply
Contributor
grinchman
Posts: 20
Registered: ‎08-16-2006
Message 1 of 6 (399 Views)

c#.net .GetXDataForApplication ?

399 Views, 5 Replies
09-29-2006 07:04 AM
Hi,

How do you get, and iterate through, object xdata in c#.net?
Sample code would be a huge help - please...
Thanks...
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 2 of 6 (399 Views)

Re: c#.net .GetXDataForApplication ?

09-29-2006 09:16 AM in reply to: grinchman
[code]
using System ;
using System.Collections ;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.ApplicationServices ;
using Autodesk.AutoCAD.DatabaseServices ;
using Autodesk.AutoCAD.EditorInput ;

[assembly: CommandClass(typeof(ClassLibrary.Class))]

namespace ClassLibrary
{
public class Class
{
static public void PrintXdata()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult res = ed.GetEntity("\nSelect entity: ");
if (res.Status != PromptStatus.OK) return;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity ent = tr.GetObject(res.ObjectId,OpenMode.ForRead) as Entity;
if (ent != null)
{
ResultBuffer xData = ent.GetXDataForApplication(null);
if (xData != null)
{
foreach (TypedValue val in (IEnumerable) xData)
{
ed.WriteMessage("\nCode = {0} Value = {1}", val.TypeCode, val.Value);
}
}
}
tr.Commit();
}
}
}
}
[/code]
*John Reiger
Message 3 of 6 (399 Views)

Re: c#.net .GetXDataForApplication ?

09-29-2006 09:39 AM in reply to: grinchman
Alexander,

I am trying to become a proficient AutoCAD programmer using the C# language.
I'd like to commend you for always posting such complete code.

Regards,

John
wrote in message news:5345593@discussion.autodesk.com...
[code]
using System ;
using System.Collections ;
using Autodesk.AutoCAD.Runtime ;
using Autodesk.AutoCAD.ApplicationServices ;
using Autodesk.AutoCAD.DatabaseServices ;
using Autodesk.AutoCAD.EditorInput ;

[assembly: CommandClass(typeof(ClassLibrary.Class))]

namespace ClassLibrary
{
public class Class
{
static public void PrintXdata()
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
PromptEntityResult res = ed.GetEntity("\nSelect entity: ");
if (res.Status != PromptStatus.OK) return;
Database db = HostApplicationServices.WorkingDatabase;
using (Transaction tr = db.TransactionManager.StartTransaction())
{
Entity ent = tr.GetObject(res.ObjectId,OpenMode.ForRead) as Entity;
if (ent != null)
{
ResultBuffer xData = ent.GetXDataForApplication(null);
if (xData != null)
{
foreach (TypedValue val in (IEnumerable) xData)
{
ed.WriteMessage("\nCode = {0} Value = {1}", val.TypeCode,
val.Value);
}
}
}
tr.Commit();
}
}
}
}
[/code]
Distinguished Contributor
Alexander Rivilis
Posts: 303
Registered: ‎09-26-2004
Message 4 of 6 (399 Views)

Re: c#.net .GetXDataForApplication ?

09-29-2006 09:48 AM in reply to: grinchman
With my english grammatics it is easy post complete code then explain how it work. :smileyhappy:
*John Reiger
Message 5 of 6 (399 Views)

Re: c#.net .GetXDataForApplication ?

09-29-2006 10:00 AM in reply to: grinchman
Well, with my limited Russian / Ukrainian vocabulary all I can say is
Spaceeba! :-)

wrote in message news:5345613@discussion.autodesk.com...
With my english grammatics it is easy post complete code then explain how it
work. :smileyhappy:
*Alexander Rivilis
Message 6 of 6 (399 Views)

Re: c#.net .GetXDataForApplication ?

09-29-2006 10:08 AM in reply to: grinchman
Hi, John Reiger!
JR> Well, with my limited Russian / Ukrainian vocabulary all I can say is
JR> Spaceeba! :-)

:-D In Ukrainian it will be "Dyakuyu"

Best Regards,
Alexander Rivilis.
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!