TheSwamp

Code Red => .NET => Topic started by: Jeff_M on July 21, 2012, 12:45:24 PM

Title: Object type conversion
Post by: Jeff_M on July 21, 2012, 12:45:24 PM
That may not be the correct description, not sure what else to call it. Programming in C# for Civil3d. I have a lot of working code for C3D2010-2012 that I'm wanting to port the C3D2013. Previous versions called the basic Cogo Point a PointEntity, for 2013 this object has been changed to CogoPoint. In hopes of being able to re-use the code with minimal changes, I would like to be able define a PointEntity class which would inherit the CogoPoint class...but it is a Public Sealed class.

Am I out of luck and need to just rewrite the code specifically for 2013? Or is there a simple way to get 2013 to recognize the PointEntity type as a CogoPoint?

Does that make sense?
Title: Re: Object type conversion
Post by: TheMaster on July 21, 2012, 01:20:24 PM
That may not be the correct description, not sure what else to call it. Programming in C# for Civil3d. I have a lot of working code for C3D2010-2012 that I'm wanting to port the C3D2013. Previous versions called the basic Cogo Point a PointEntity, for 2013 this object has been changed to CogoPoint. In hopes of being able to re-use the code with minimal changes, I would like to be able define a PointEntity class which would inherit the CogoPoint class...but it is a Public Sealed class.

Am I out of luck and need to just rewrite the code specifically for 2013? Or is there a simple way to get 2013 to recognize the PointEntity type as a CogoPoint?

Does that make sense?

API changes like that are hard to explain or justify, but you might try using aliases:

Code: [Select]

#if C3D_RELEASE > 2012
   using PointEntity = Autodesk.Civil.Land.DatabaseServices.CogoPoint;
#endif

Title: Re: Object type conversion
Post by: huiz on July 21, 2012, 01:20:56 PM
I think you better use the CogoPoint and not the PointEntity class. You already needs to rename so many things in specific Civil3D code that it it not such a hard job renaming PointEntity. Or do you have a serious reason to keep using PointEntity?
Title: Re: Object type conversion
Post by: huiz on July 21, 2012, 01:22:29 PM
..

API changes like that are hard to explain or justify, but you might try using aliases:

Code: [Select]

   using PointEntity = Autodesk.Civil.Land.DatabaseServices.CogoPoint;


Without the Land would that be :-)
Title: Re: Object type conversion
Post by: Jeff_M on July 21, 2012, 03:00:08 PM
Thanks Tony and Huiz!

Tony's suggestion, sans the Land, is what I was looking for. Had a case of Saturday morning brain freeze.

Huiz, for my existing COM-less code working with points I really wanted the code to work in all versions, 2010+. For new features, 2013+, I am using the CogoPoint directly.