TheSwamp

Code Red => .NET => Topic started by: Viktor on October 30, 2009, 03:48:53 PM

Title: 2010 to 2009 downgrade of .net code, need some help...
Post by: Viktor 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.
Title: Re: 2010 to 2009 downgrade of .net code, need some help...
Post by: Viktor 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
Title: Re: 2010 to 2009 downgrade of .net code, need some help...
Post by: jmaeding 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.
Title: Re: 2010 to 2009 downgrade of .net code, need some help...
Post by: Viktor 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.
Title: Re: 2010 to 2009 downgrade of .net code, need some help...
Post by: Viktor on October 30, 2009, 07:08:42 PM
i goofed, didn't reference the internal dll.
Title: Re: 2010 to 2009 downgrade of .net code, need some help...
Post by: Kerry 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. 
Title: Re: 2010 to 2009 downgrade of .net code, need some help...
Post by: Viktor 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?
Title: Re: 2010 to 2009 downgrade of .net code, need some help...
Post by: Kerry on October 30, 2009, 09:11:32 PM

Personally, I'd build a destinct dll for each version.