TheSwamp
Code Red => .NET => Topic started by: Kerry on October 28, 2011, 03:37:07 AM
-
I have been re-building some old code in VS2010 using the 2012 ObjectARX SDK and came across some
'blablabla is obsolete: use thingy instead' warnings.
The code still compiles and runs fine but I want to start thinking about the future.
a few examples will follow, please add any others you come across.
Regards,
-
WARNING :
'Autodesk.AutoCAD.DatabaseServices.Entity.IntersectWith(
Autodesk.AutoCAD.DatabaseServices.Entity,
Autodesk.AutoCAD.DatabaseServices.Intersect,
Autodesk.AutoCAD.Geometry.Point3dCollection,
long,
long)' is obsolete:
'Use the overload taking IntPtr instead.'
The reflected signatures are
[Obsolete("Use the overload taking IntPtr instead.")]
public void IntersectWith(Entity entityPointer, Intersect intersectType, Point3dCollection points, long thisGraphicSystemMarker, long otherGraphicSystemMarker)
{
}
public void IntersectWith(Entity entityPointer, Intersect intersectType, Point3dCollection points, IntPtr thisGraphicSystemMarker, IntPtr otherGraphicSystemMarker)
{
}
This was pretty easy
This was the offending statement :
ent1.IntersectWith(ent2, intersectType, pts, 0, 0);
could have used
ent1.IntersectWith(ent2, intersectType, pts, new IntPtr(0), new IntPtr(0));
decided to use
ent1.IntersectWith(ent2, intersectType, pts, IntPtr.Zero, IntPtr.Zero;
-
The next was to do with the Table Class
ie Autodesk.AutoCAD.DatabaseServices.Table
In fact, there are a myriad of obsolete warnings in the Table class ... some of them appear to have no documented resolution, some appear to not work using the suggested resolutiom.
The reflected signatures that have the Obsolete Attribute set.
[Obsolete("Use Table.Columns.Count instead.")]
public virtual int NumColumns
{
[Category("Table")]
get { }
set { }
}
[Obsolete("Use Table.Rows.Count instead.")]
public virtual int NumRows
{
[Category("Table")]
get { }
set { }
}
Offending code :
Table table;
int rows = table.NumRows;
int cols = table.NumColumns;
Amended property usage :
Table table;
int rows = table.Rows.Count;
int cols = table.Columns.Count;
-
Still with the Table ...
Here's a couple I can't find a resolution for :
Reflected signatures :-
[UnitType(UnitType.Distance), Obsolete("Use Table.Cells[row, column].HorizontalLine.Margin instead."), Category("Table")]
public virtual double HorizontalCellMargin
{
get { }
set { }
}
[UnitType(UnitType.Distance), Obsolete("Use Table.Cells[row, column].VerticalLine.Margin instead."), Category("Table")]
public virtual double VerticalCellMargin
{
get { }
set { }
}
[Obsolete("Use Cell functionality instead.")]
public virtual bool IsHeaderSuppressed
{
[return: MarshalAs(UnmanagedType.U1)]
[Category("Table")]
get { }
[param: MarshalAs(UnmanagedType.U1)]
set { }
}
[Obsolete("Use Cell functionality instead.")]
public virtual bool IsTitleSuppressed
{
[return: MarshalAs(UnmanagedType.U1)]
[Category("Table")]
get { }
[param: MarshalAs(UnmanagedType.U1)]
set { }
}
Has anyone come across a resolution to these ??
-
Not those specific ones but others.
They changed from a bunch of functions to a better "object properties" approach. It made a mess of some of my code too.
[Warning: this is not actual code.]
Where they had SetColumnWidth(ColumnNumber, Value) it became Table.Column[ColumnNumber].Width = Value.
A lot of the SetColumnThis and SetCellThat functions went away.
You now set the properties of the column, row and cell objects.
Or did I completely miss the point of your question?
-
Hello Mark
I was mainly looking for a resolution to the properties posted in Reply #3
ie
[Obsolete("Use Cell functionality instead.")]
public virtual bool IsHeaderSuppressed
{ // ..........
}
etc
.... and for the general education of all, any others that members have modified to suit the most recent build.
-
Kerry,
Do they work by using it's
TableStyle.HorizontalCellMargin
TableStyle.IsHeaderSuppressed
etc.........?
Table tbl = new Table();
tbl.TableStyle = db.Tablestyle;
TableStyle ts = (TableStyle)trx.GetObject(tbl.TableStyle, OpenMode.ForRead);
ts.HorizontalCellMargin = 12;
ts.IsHeaderSuppressed = true;
////etc.......
TableStyle class objects are used to store the table formatting properties (for example, grid visibility, lineweight, line color, and cell font, height, color, and background fill) used by Table entities.
Because tables appear in a variety of forms, table objects will be based on a table style similar to the way text objects and dimension objects are based on styles in AutoCAD. The table style controls the initial formatting of a newly created table object and whether the table includes a title and header row.
-
Chances are you're correct Jeff
..... the confusing issue is that the message says use the Cell functionality.
I'm guessing that the Acad_Table API is not complete.
.... time to 'phone a friend' I think.
Regards
-
And to add to the confusion they tell you use a method that does not exist or I can not find
HorizontalLine.Margin
-
And to add to the confusion they tell you use a method that does not exist or I can not find
HorizontalLine.Margin
Yep, That's one of these :)
The next was to do with the Table Class
ie Autodesk.AutoCAD.DatabaseServices.Table
In fact, there are a myriad of obsolete warnings in the Table class ... some of them appear to have no documented resolution, some appear to not work
-
Sort of off topic :
I wonder why the Class is called Table.
... Have [you] tried to do a search for table :ugly:
-
Off your "off topic"
It's especially miserable when your program has database elements.
Now VS doesn't know which Table you mean.
Would have been better to call it AcadTable or something.
I looked back through my table code and didn't come across any instances where I used those particular properties so this comment is as useless as my last one.
-
Hello everyone,
At Kerry's suggestion, I've written a blog post to (hopefully) address this topic:
http://through-the-interface.typepad.com/through_the_interface/2011/11/handling-protocol-changes-to-autocads-table-in-net.html
By the way: we've avoided using "Acad" as a prefix (as we did for COM) in our .NET API (if I recall correctly it's recommended to use namespaces rather than prefixes in the .NET Framework Design Guidelines, although I may have that wrong). Anyway - if it's hard to find information about classes of a particular name, that's really a tooling issue rather than an API design issue, in my opinion.
Cheers,
Kean
-
Thanks for the post, Kean. And thanks to Kerry for asking about it.
I ran into this last year when I first was tackling Tables, I never found a resolution and since it worked I just left it alone. It's funny how easy it is now, seeing what Kean did, but I must've spent 5-6 hours trying various things. I wish I had been as smart as Kerry and just asked the right people :-) Off to fix my code now.....
-
Thank you Kean for your continued support.
That should solve the issue for a lot of people.
... not to forget kudos to Stephen, Philippe and Balaji
Regards
-
Hi,
As for the VS confusing db tables and acad tables, that can be avoided using an alias, like:
using fTable = Autodesk.AutoCAD.DatabaseServices.Table
-gnb
-
Welcome to theSwamp Gasty.
Yes, using an alias works fine locally ... though I've had no issue with the compiler understanding the Class.
My issue is with 'google' and desktop searches for the word 'Table'.
... probably just a personal problem :)
-
IMHO, some warnings are just to keep the newbie's out of trouble.
For Tables, I see no issue with setting the number of rows and columns when creating a table, it's the subsequent calls that can cause problems. A safer and more generic way to "add" rows & columns would be.
tb.InsertRows( tb.Rows.Count, rowHeight, numRows - tb.Rows.Count);
tb.InsertColumns(tb.Columns.Count, colWidth, numCols - tb.Columns.Count);
in fact, this might make a good extension method. (Add)
I do like the newer style, its more dataset like
-
< ... >
in fact, this might make a good extension method. (Add)
I do like the newer style, its more dataset like
yes, and I like it too.
-
Hi,
As for the VS confusing db tables and acad tables, that can be avoided using an alias, like:
using fTable = Autodesk.AutoCAD.DatabaseServices.Table
-gnb
Welcome indeed!
I hadn't thought of that. Thank you.
BTW - This is only an issue if you are "using" both Autodesk.AutoCAD.DatabaseServices and System.Data in the same class.