.NET

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

c#.net .GetXDataForApplication ?

384 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 (384 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 (384 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 (384 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 (384 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 (384 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.
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 or visit the Installation and Licensing Forum to get help installing your software.