.NET

Reply
*Laurence Skoropinski
Message 1 of 5 (124 Views)

XData - extracting specific appname

124 Views, 4 Replies
08-24-2005 01:01 AM
You appear to be able to add xdata to an entity with different application
names with multiple calls to the XData property, yet to extract them there
only appears to be a way to get all applicationnames from the XData
property.

The question is there a way to extract only the applicationnamed xdata I am
interested in, or do I just accept walking the xdata buffer until I find the
application name I want and then process it?



Below function just proves multiple calls with different application names
works, note SkorXData is my helper class for xdata.



[CommandMethod("TEST1", CommandFlags.Modal)]

public static void TestCommand_1()

{

Database db = HostApplicationServices.WorkingDatabase;

Editor Ed = AppServ.Application.DocumentManager.MdiActiveDocument.Editor;

TransactionManager tm = db.TransactionManager;

Transaction trans = tm.StartTransaction();

string AppName = "LOZTEST";

SkorXData.CreateXDAppName(AppName);

try

{

BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId,
OpenMode.ForWrite);

Point3d CtrPt = new Point3d(10, 20, 30);

Point2d TestPt = new Point2d(100, 200);

Circle circle = new Circle(CtrPt, Vector3d.ZAxis, 2);

ObjectId CircleID = btr.AppendEntity(circle);

//=============xdata==========================================

ResultBuffer buf = new ResultBuffer();

buf.Add( new TypedValue((int) DxfCode.ExtendedDataRegAppName, AppName));

SkorXData.AddTypeToBuf(ref buf, "Test Text");

SkorXData.AddTypeToBuf(ref buf, 123456789);



circle.XData = buf;

SkorXData.CreateXDAppName("TESTXDATA");

ResultBuffer buf2 = new ResultBuffer();

buf2.Add( new TypedValue((int) DxfCode.ExtendedDataRegAppName,
"TESTXDATA"));

SkorXData.AddTypeToBuf(ref buf2, "Test Xdata");

SkorXData.AddTypeToBuf(ref buf2, 987654321);


circle.XData = buf2;

trans.AddNewlyCreatedDBObject(circle, true);

trans.Commit();

}

catch( Autodesk.AutoCAD.Runtime.Exception e )

{

Ed.WriteMessage("Error: " + e.Message);

}

finally

{

trans.Dispose();

}

}
*TomD
Message 2 of 5 (124 Views)

Re: XData - extracting specific appname

08-24-2005 10:09 AM in reply to: *Laurence Skoropinski
I'm not the most experienced XData person, but I've never experienced what
you're describing.

The GetXData method should return the XData for ONLY the application name
specified. You'd have to post your SkorXData code. If I had to guess,
based on this information, I'd say you have the GetXData parameters wrong.
If passed with an empy string for the appname, you may get the results
you're describing, I don't know.

"Laurence Skoropinski" wrote in message
news:4937038@discussion.autodesk.com...
You appear to be able to add xdata to an entity with different application
names with multiple calls to the XData property, yet to extract them there
only appears to be a way to get all applicationnames from the XData
property.

The question is there a way to extract only the applicationnamed xdata I am
interested in, or do I just accept walking the xdata buffer until I find the
application name I want and then process it?



Below function just proves multiple calls with different application names
works, note SkorXData is my helper class for xdata.



[CommandMethod("TEST1", CommandFlags.Modal)]

public static void TestCommand_1()

{

Database db = HostApplicationServices.WorkingDatabase;

Editor Ed = AppServ.Application.DocumentManager.MdiActiveDocument.Editor;

TransactionManager tm = db.TransactionManager;

Transaction trans = tm.StartTransaction();

string AppName = "LOZTEST";

SkorXData.CreateXDAppName(AppName);

try

{

BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId,
OpenMode.ForWrite);

Point3d CtrPt = new Point3d(10, 20, 30);

Point2d TestPt = new Point2d(100, 200);

Circle circle = new Circle(CtrPt, Vector3d.ZAxis, 2);

ObjectId CircleID = btr.AppendEntity(circle);

//=============xdata==========================================

ResultBuffer buf = new ResultBuffer();

buf.Add( new TypedValue((int) DxfCode.ExtendedDataRegAppName, AppName));

SkorXData.AddTypeToBuf(ref buf, "Test Text");

SkorXData.AddTypeToBuf(ref buf, 123456789);



circle.XData = buf;

SkorXData.CreateXDAppName("TESTXDATA");

ResultBuffer buf2 = new ResultBuffer();

buf2.Add( new TypedValue((int) DxfCode.ExtendedDataRegAppName,
"TESTXDATA"));

SkorXData.AddTypeToBuf(ref buf2, "Test Xdata");

SkorXData.AddTypeToBuf(ref buf2, 987654321);


circle.XData = buf2;

trans.AddNewlyCreatedDBObject(circle, true);

trans.Commit();

}

catch( Autodesk.AutoCAD.Runtime.Exception e )

{

Ed.WriteMessage("Error: " + e.Message);

}

finally

{

trans.Dispose();

}

}
*Tony Tanzillo
Message 3 of 5 (124 Views)

Re: XData - extracting specific appname

08-24-2005 03:36 PM in reply to: *Laurence Skoropinski
This is the dotNet newsgroup.

He's not talking about the ActiveX method you describe,
although that may be faster if there's a lot of XDATA.

--
http://www.caddzone.com

AcadXTabs: MDI Document Tabs for AutoCAD 2004/2005/2006
http://www.acadxtabs.com

"TomD" wrote in message news:4937638@discussion.autodesk.com...
I'm not the most experienced XData person, but I've never experienced what
you're describing.

The GetXData method should return the XData for ONLY the application name
specified. You'd have to post your SkorXData code. If I had to guess,
based on this information, I'd say you have the GetXData parameters wrong.
If passed with an empy string for the appname, you may get the results
you're describing, I don't know.

"Laurence Skoropinski" wrote in message
news:4937038@discussion.autodesk.com...
You appear to be able to add xdata to an entity with different application
names with multiple calls to the XData property, yet to extract them there
only appears to be a way to get all applicationnames from the XData
property.

The question is there a way to extract only the applicationnamed xdata I am
interested in, or do I just accept walking the xdata buffer until I find the
application name I want and then process it?



Below function just proves multiple calls with different application names
works, note SkorXData is my helper class for xdata.



[CommandMethod("TEST1", CommandFlags.Modal)]

public static void TestCommand_1()

{

Database db = HostApplicationServices.WorkingDatabase;

Editor Ed = AppServ.Application.DocumentManager.MdiActiveDocument.Editor;

TransactionManager tm = db.TransactionManager;

Transaction trans = tm.StartTransaction();

string AppName = "LOZTEST";

SkorXData.CreateXDAppName(AppName);

try

{

BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId,
OpenMode.ForWrite);

Point3d CtrPt = new Point3d(10, 20, 30);

Point2d TestPt = new Point2d(100, 200);

Circle circle = new Circle(CtrPt, Vector3d.ZAxis, 2);

ObjectId CircleID = btr.AppendEntity(circle);

//=============xdata==========================================

ResultBuffer buf = new ResultBuffer();

buf.Add( new TypedValue((int) DxfCode.ExtendedDataRegAppName, AppName));

SkorXData.AddTypeToBuf(ref buf, "Test Text");

SkorXData.AddTypeToBuf(ref buf, 123456789);



circle.XData = buf;

SkorXData.CreateXDAppName("TESTXDATA");

ResultBuffer buf2 = new ResultBuffer();

buf2.Add( new TypedValue((int) DxfCode.ExtendedDataRegAppName,
"TESTXDATA"));

SkorXData.AddTypeToBuf(ref buf2, "Test Xdata");

SkorXData.AddTypeToBuf(ref buf2, 987654321);


circle.XData = buf2;

trans.AddNewlyCreatedDBObject(circle, true);

trans.Commit();

}

catch( Autodesk.AutoCAD.Runtime.Exception e )

{

Ed.WriteMessage("Error: " + e.Message);

}

finally

{

trans.Dispose();

}

}
*TomD
Message 4 of 5 (124 Views)

Re: XData - extracting specific appname

08-25-2005 10:58 AM in reply to: *Laurence Skoropinski
Yes, I realized that this morning. Thank you very much.

......I'm considering getting into .NET, so I've been breezing through
here.......I forgot where I was.

Sorry for any confusion caused by those following this thread.

"Tony Tanzillo" wrote in message
news:4938137@discussion.autodesk.com...
This is the dotNet newsgroup.

He's not talking about the ActiveX method you describe,
although that may be faster if there's a lot of XDATA.
*Laurence Skoropinski
Message 5 of 5 (124 Views)

Re: XData - extracting specific appname

08-26-2005 07:29 AM in reply to: *Laurence Skoropinski
OK then walk the buffer it is

Laurence

"Laurence Skoropinski" wrote in message
news:4937038@discussion.autodesk.com...
You appear to be able to add xdata to an entity with different application
names with multiple calls to the XData property, yet to extract them there
only appears to be a way to get all applicationnames from the XData
property.

The question is there a way to extract only the applicationnamed xdata I am
interested in, or do I just accept walking the xdata buffer until I find the
application name I want and then process it?



Below function just proves multiple calls with different application names
works, note SkorXData is my helper class for xdata.



[CommandMethod("TEST1", CommandFlags.Modal)]

public static void TestCommand_1()

{

Database db = HostApplicationServices.WorkingDatabase;

Editor Ed = AppServ.Application.DocumentManager.MdiActiveDocument.Editor;

TransactionManager tm = db.TransactionManager;

Transaction trans = tm.StartTransaction();

string AppName = "LOZTEST";

SkorXData.CreateXDAppName(AppName);

try

{

BlockTableRecord btr = (BlockTableRecord)trans.GetObject(db.CurrentSpaceId,
OpenMode.ForWrite);

Point3d CtrPt = new Point3d(10, 20, 30);

Point2d TestPt = new Point2d(100, 200);

Circle circle = new Circle(CtrPt, Vector3d.ZAxis, 2);

ObjectId CircleID = btr.AppendEntity(circle);

//=============xdata==========================================

ResultBuffer buf = new ResultBuffer();

buf.Add( new TypedValue((int) DxfCode.ExtendedDataRegAppName, AppName));

SkorXData.AddTypeToBuf(ref buf, "Test Text");

SkorXData.AddTypeToBuf(ref buf, 123456789);



circle.XData = buf;

SkorXData.CreateXDAppName("TESTXDATA");

ResultBuffer buf2 = new ResultBuffer();

buf2.Add( new TypedValue((int) DxfCode.ExtendedDataRegAppName,
"TESTXDATA"));

SkorXData.AddTypeToBuf(ref buf2, "Test Xdata");

SkorXData.AddTypeToBuf(ref buf2, 987654321);


circle.XData = buf2;

trans.AddNewlyCreatedDBObject(circle, true);

trans.Commit();

}

catch( Autodesk.AutoCAD.Runtime.Exception e )

{

Ed.WriteMessage("Error: " + e.Message);

}

finally

{

trans.Dispose();

}

}
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Announcements
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.