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

XData - extracting specific appname

4 REPLIES 4
Reply
Message 1 of 5
Anonymous
261 Views, 4 Replies

XData - extracting specific appname

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();

}

}
4 REPLIES 4
Message 2 of 5
Anonymous
in reply to: Anonymous

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();

}

}
Message 3 of 5
Anonymous
in reply to: Anonymous

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();

}

}
Message 4 of 5
Anonymous
in reply to: Anonymous

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

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();

}

}

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost