Author Topic: 2010 to 2009 downgrade of .net code, need some help...  (Read 2595 times)

0 Members and 1 Guest are viewing this topic.

Viktor

  • Guest
2010 to 2009 downgrade of .net code, need some help...
« on: October 30, 2009, 03:48:53 PM »
Well, we live and learn, the hard way sometimes. I developed my .net application targetting 2010 and ended up using some 2010 api changes without knowing it. For example I used the Internal.Utils.SelectObjects, which is apparently new and I used TextStyleId to set the textstyle objectid. So now I'm looking at ways to downgrade these things to 2009 and I'm stuck with these 2 issues.

1. I can't seem to find a way to select/highlight objects without using interop.
2. How do I check for current application version? so that I can test and use the proper property since TextStyle is not availablein 2010 and TextStyleID is not available in 2009.

Thanks,
Viktor.

Viktor

  • Guest
Re: 2010 to 2009 downgrade of .net code, need some help...
« Reply #1 on: October 30, 2009, 04:16:55 PM »
Well, the textstyle thing can be solved a number of way i guess, I chose this one because I do this in my code in other places so not to introduce anything new. Any performance issues with this approach?

Code: [Select]
Dim Attpdc As PropertyDescriptorCollection = TypeDescriptor.GetProperties(attref)
If Autodesk.AutoCAD.ApplicationServices.Application.Version.Major <= 17 Then
       Dim pd As PropertyDescriptor = Attpdc("TextStyle")
       pd.SetValue(attref, ValidTR.ObjectId)
ElseIf Autodesk.AutoCAD.ApplicationServices.Application.Version.Major >= 18 Then
       Dim pd As PropertyDescriptor = Attpdc("TextStyleId")
       pd.SetValue(attref, ValidTR.ObjectId)
End If

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: 2010 to 2009 downgrade of .net code, need some help...
« Reply #2 on: October 30, 2009, 04:24:25 PM »
selecting objects is bread and butter for .net api, interop not needed.
Do a search on this site for select to find lots of examples.
Your handling of the versions seems good to me, I do version forks in several places.
James Maeding

Viktor

  • Guest
Re: 2010 to 2009 downgrade of .net code, need some help...
« Reply #3 on: October 30, 2009, 04:57:55 PM »
selecting objects is bread and butter for .net api, interop not needed.
Do a search on this site for select to find lots of examples.
Your handling of the versions seems good to me, I do version forks in several places.

Just to verify, cause I'm not finding much about this, I'm talking about creating a visual selection on the screen, an alternative to highlighting because highlighting is not always very visible. I want to click a button and show a selected object on screen.

Viktor

  • Guest
Re: 2010 to 2009 downgrade of .net code, need some help...
« Reply #4 on: October 30, 2009, 07:08:42 PM »
i goofed, didn't reference the internal dll.

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: 2010 to 2009 downgrade of .net code, need some help...
« Reply #5 on: October 30, 2009, 08:14:08 PM »

To clarify for anyone following along

Prior to AC2010, acmgdinternal.DLL required referencing for access to the Autodesk.AutoCAD.Internal.<..> namespaces.
In AC2010 acmgdinternal.DLL no longer exists, the contents has been included with the acmgd.dll Module. 
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.

Viktor

  • Guest
Re: 2010 to 2009 downgrade of .net code, need some help...
« Reply #6 on: October 30, 2009, 09:07:19 PM »
Yea, thanks for clarifying this, but this brings me to the next question, sooooo how do you build your dll so that both version can use the internal namespace? It seems that if I compile with 2010 then any function that calls internal functions crash the program, and when i compile with 2009 and reference the acmgdinternal.dll then it crashes on 2010 but works fine on 2009. So what do I do?

Kerry

  • Mesozoic relic
  • Seagull
  • Posts: 11654
  • class keyThumper<T>:ILazy<T>
Re: 2010 to 2009 downgrade of .net code, need some help...
« Reply #7 on: October 30, 2009, 09:11:32 PM »

Personally, I'd build a destinct dll for each version.
kdub, kdub_nz in other timelines.
Perfection is not optional.
Everything will work just as you expect it to, unless your expectations are incorrect.
Discipline: None at all.