.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

c#.net .GetXDataForApplication ?

5 REPLIES 5
Reply
Message 1 of 6
Anonymous
1064 Views, 5 Replies

c#.net .GetXDataForApplication ?

Hi,

How do you get, and iterate through, object xdata in c#.net?
Sample code would be a huge help - please...
Thanks...
5 REPLIES 5
Message 2 of 6
Anonymous
in reply to: Anonymous

[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]
Message 3 of 6
Anonymous
in reply to: Anonymous

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]
Message 4 of 6
Anonymous
in reply to: Anonymous

With my english grammatics it is easy post complete code then explain how it work. 🙂
Message 5 of 6
Anonymous
in reply to: Anonymous

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. 🙂
Message 6 of 6
Anonymous
in reply to: Anonymous

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


Autodesk Design & Make Report