Hello,
How do you manage SourceCode and Dll, when you need to write an application which must work with multi-version of AutoCAD?
In my case, I've AutoCAD 2008, 2010 and 2012 installed in my company. When methods or properties have changed, I don't know if its possible to use the same DLL.
I develop for 2008 with framework 2.0 and it works fine, but for exemple on a DBText, in A2008, to read or assign ID of text style, the properties is DBText.TextStyle. In 2010, this property is now named DBText.TextStyleId
Is it possible to compile only ONE version which could work for both AutoCAD?
Thanks
Olivier
Olivier Eckmann
hi i have the same prob.. you cant have 1 DLL for acad 2010 and 2012
2010 --> framework v3.5
2012 --> framework v4
so you need 2 DLL..
no choose here.. 😛
Thanks, but it's not a problem for framework.
I've compiled my DLL to target Framework 2.0 (AnyCPU), so my DLL work fine from AutoCAD 2007 to AutoCAD 2012 32&64 bits .
Problem appears only when method or properties have changed between versions.
If it ins't possible to have only 1 DLL, is it possible to have only 1 code for sources (with IF DEF), certainly in 2 solutions to reference good AUtoCAD DLL?
Olivier
Olivier Eckmann
Hi,
As far as I know, you have to compile 2 different projects but you can have them in the same solution and share the code with some 'conditional compilation'.
In your solution add a new project targeting the framework 3.5, reference the 2010 acdbmgd.dll and acmgd.dll, add a conditional compilation symbol (project propeties > Build tab) i.e. ACAD_18.
Right click on the new project > Add > Existing element > select your source codes in the old project and add them as links (popup the Add button)
Then in your source code, add some compilation conditions :
#if ACAD_18
text.TextStyleId = id;
#else
text TextStyle = id;
#endif
PS: feel free to ask this question on a french site (CADxp, AcadLabs, ExMateria), I 'd be more comfortable to reply in French.
Thanks.
I try to apply your suggestion.
Olivier
PS: Merci, je pensais avoir plus de réponse sur le site US, d'où mon post. Si je n'y arrive pas, je posterais sur CadXP
Olivier Eckmann
You will definitely need a new project for 2013 because of the changed references. But for 2012 and earlier you can use a single project. Here is an example using reflection.
Dim ThisDoc As DocumentManager.MdiActiveDocument Dim vcText As New VersionCode Dim tsTable As TextStyleTable
Dim TextEnt As DBText
Dim tsTableID As ObjectId = ThisDoc.Database.TextStyleTableId
Dim Style as String = "Standard" Using Trans As Transaction = ThisDoc.TransactionManager.StartTransaction() tsTable = CType(Trans.GetObject(tsTableID , OpenMode.ForRead), TextStyleTable) vcText.SetTextStyleId(TextEnt, tsTable(Style)) ' for both 2009/2010
Trans.Commit()
End Using
--------
Imports Autodesk.AutoCAD.DatabaseServices
Imports System.Reflection
Public Class VersionCode
Public Function GetTextStyleId(ByVal Instance As DBText) As ObjectId
If textStyleProperty IsNot Nothing Then
Return DirectCast(textStyleProperty.GetValue(Instance, Nothing), ObjectId)
Else
Throw New MissingMemberException()
End If
End Function
Public Function GetTextStyleId(ByVal Instance As MText) As ObjectId
If mtextStyleProperty IsNot Nothing Then
Return DirectCast(mtextStyleProperty.GetValue(instance, Nothing), ObjectId)
Else
Throw New MissingMemberException()
End If
End Function
Public Sub SetTextStyleId(ByVal Instance As DBText, ByVal value As ObjectId)
If textStyleProperty IsNot Nothing Then
textStyleProperty.SetValue(instance, value, Nothing)
Else
Throw New MissingMemberException()
End If
End Sub
Public Sub SetTextStyleId(ByVal Instance As MText, ByVal value As ObjectId)
If mtextStyleProperty IsNot Nothing Then
mtextStyleProperty.SetValue(instance, value, Nothing)
Else
Throw New MissingMemberException()
End If
End Sub
Public Sub New()
textStyleProperty = GetType(DBText).GetProperty("TextStyle")
If textStyleProperty Is Nothing Then
textStyleProperty = GetType(DBText).GetProperty("TextStyleId")
End If
mtextStyleProperty = GetType(MText).GetProperty("TextStyle")
If mtextStyleProperty Is Nothing Then
mtextStyleProperty = GetType(MText).GetProperty("TextStyleId")
End If
End Sub
Private textStyleProperty As PropertyInfo = Nothing
Private mtextStyleProperty As PropertyInfo = Nothing
End Class
I also had an issue with 2013 where the DLLs for the COM components are different. What I did there to avoid multiple solutions was to create one solution with two projects. The second project referenced the 64-bit DLLs and what I did was Add>Existing Item... and then in the browse dialog I used the Add As Link option to add all the 32-bit code modules and forms to the 64-bit project. Then with a bit of fiddling with the output options I was able to create a 32-bit DLL and 64-bit DLL with one compile and one set of source code.
I succesfully use Add as link, to share source code and ressoures.
I don't know reflexion, but it seems to be a good solution, I try to explore this way too.
Thanks a lot for all of your answers.
Olivier
Olivier Eckmann
Can't find what you're looking for? Ask the community or share your knowledge.