.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

first try to convert a vb.net projet 2010 to 2014

6 REPLIES 6
Reply
Message 1 of 7
AubelecBE
938 Views, 6 Replies

first try to convert a vb.net projet 2010 to 2014

hi all. i have to convert 2010 projet on vs2010 to 2012 on acad2014.

i have copied my projet 2010 on path for 2012 --> ok

 

 i loaded my projet on vs2012 --> ok

i check the reference. (add accoremdg.dll and the 2 other) --> ok.

 changed the target x64 and changer the compil for framwork 4 --> ok

 

i changed few code for the change and compiling --> ok

 

i launched acad2014 + netload my project. i see the part of my code : Public Class Initialization --> OK

 

but autocad dont know the commandmethod in this example :  QT.

 

where i am missed ?

 

 

here my code : (with 1 commande method)

(i have 10 commandMethod in Class Commandes. and the code work fin in acad2010 on framework 3.5

 

Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.ApplicationServices.Application
Imports System.Reflection
Imports System.IO
Imports Autodesk.AutoCAD.Geometry

Public Class Initialization
    Implements Autodesk.AutoCAD.Runtime.IExtensionApplication

    Public Sub Initialize() Implements IExtensionApplication.Initialize
        Dim objEditor As Autodesk.AutoCAD.EditorInput.Editor = Application.DocumentManager.MdiActiveDocument.Editor
        objEditor.WriteMessage(vbCrLf & "Chargement Lanceur VB.NET Aubelec (v" & My.Application.Info.Version.ToString & ")" & vbCrLf)


        '--> V1.01
        Dim mg As Object = Nothing
        If GestionAUTOCAD.RecupererNomFichierCUI(My.Settings.GlobalNomCui, _
                                                               True, _
                                                               "Veuillez charger le Menu Groupe Aubelec dans AUTOCAD", _
                                                               "FIN DU PROGRAMME", mg) = True Then

            '--> récupération du répertoire de base des app autocad grace au menu GROUPEAUBELEC.
            Dim cnt As Long
            Dim MemTexte As String
            Dim Rep, NbRep As Integer
            Dim Ok As Boolean
            Dim repertoire As String
            NbRep = 2
            'conversion en maj.
            repertoire = UCase(mg.MenuFileName)
            repertoire = StrConv(mg.MenuFileName, VbStrConv.Uppercase)
            cnt = 1
            MemTexte = ""
            Rep = 0
            Ok = True
            MemTexte = ""
            While cnt <= Len(repertoire) And Ok
                If Mid(repertoire, cnt, 1) = "\" Then
                    Rep = Rep + 1
                    If Rep >= NbRep Then
                        Ok = False
                    End If
                    My.Settings.GlobalRepertoireAutocad = Mid(repertoire, 1, cnt)
                End If
                cnt = cnt + 1
            End While
        End If
        '<-- V1.01
    End Sub

    Public Sub Terminate() Implements IExtensionApplication.Terminate
        Dim objEditor As Autodesk.AutoCAD.EditorInput.Editor = Application.DocumentManager.MdiActiveDocument.Editor
        objEditor.WriteMessage("Fermeture Lanceur VB.NET Aubelec (v" & My.Application.Info.Version.ToString & ")")
    End Sub
End Class

'*************************************************************************************
'**  Debut de la class Générale                                                     **
'*************************************************************************************
Public Class Commandes
    '*************************************************************************************
    '**  Commande Générale Texte Rapide                                                 **
    '*************************************************************************************
    <CommandMethod("QT")> _
    Public Shared Sub QT()

        Dim doc As Document = Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor

        Dim pso As PromptStringOptions = New PromptStringOptions(vbCrLf & "Entrez votre texte : ")
        pso.AllowSpaces = True
        Dim pr As PromptResult = ed.GetString(pso)

        If pr.Status <> PromptStatus.OK Then Exit Sub
        If pr.StringResult = "" Then Exit Sub

        Dim tr As Transaction = doc.TransactionManager.StartTransaction()

        Using tr

            Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)

            'Création de l'objet
            Dim txt As DBText = New DBText()
            txt.Normal = ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis
            txt.TextString = pr.StringResult

            'Ajout du DBText  à la base pour la gestion des alignements

            btr.AppendEntity(txt)
            tr.AddNewlyCreatedDBObject(txt, True)

            'gestion du Jig de base
            Dim Jig As JigDBText = New JigDBText(doc, tr, db, txt)
            If Jig.Run() <> PromptStatus.OK Then
                tr.Abort() 'Jig.Entity.Dispose()
                Exit Sub
            End If

            tr.TransactionManager.QueueForGraphicsFlush()
            doc.TransactionManager.FlushGraphics()
            doc.Editor.UpdateScreen()
            tr.Commit()
        End Using


    End Sub

End class

 

 

6 REPLIES 6
Message 2 of 7
Hallex
in reply to: AubelecBE

   'Set temp point outside of sub scope:

    Private Shared tmp As Point3d = Point3d.Origin
    <CommandMethod("QT")> _
    Public Shared Sub QT()

        Dim doc As Document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument
        Dim db As Database = doc.Database
        Dim ed As Editor = doc.Editor
        ' Dim tmp As Point3d = Point3d.Origin
        Dim pso As PromptStringOptions = New PromptStringOptions(vbCrLf & "Enter your text : ")
        pso.AllowSpaces = True
        Dim pr As PromptResult = ed.GetString(pso)

        If pr.Status <> PromptStatus.OK Then Exit Sub
        If pr.StringResult = "" Then Exit Sub

        Dim tr As Transaction = doc.TransactionManager.StartTransaction()

        Using tr

            Dim btr As BlockTableRecord = tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite)

            'Création de l'objet
            Dim txt As DBText = New DBText()
            tmp = txt.Position
            txt.Normal = ed.CurrentUserCoordinateSystem.CoordinateSystem3d.Zaxis
            txt.TextString = pr.StringResult

            'Ajout du DBText  à la base pour la gestion des alignements

            btr.AppendEntity(txt)
            tr.AddNewlyCreatedDBObject(txt, True)

            Dim psr As PromptSelectionResult = ed.SelectLast()
            tmp = txt.Position

            ' Select the last entity added (our Text)

            Dim res As PromptSelectionResult = ed.SelectLast()

            ' Assuming that worked, we'll drag it
            Dim ppr As PromptPointResult = ed.Drag(res.Value, vbLf & "Select text location: ", New DragCallback(AddressOf TextDragCallback))
            If (ppr.Status = PromptStatus.OK) Then
                ' Get the final translation matrix
                Dim mat As Matrix3d = Matrix3d.Displacement(tmp.GetVectorTo(ppr.Value))
                ' Transform our MText
                txt.TransformBy(mat)
                ' Finally we commit our transaction
                tr.Commit()
            End If

        End Using

    End Sub
'' based on Kean Walmsley solution
    Private Shared Function TextDragCallback(ByVal pt As Point3d, ByRef mat As Matrix3d) As SamplerStatus

     	' If no change has been made, say so
        If (tmp = pt) Then
            Return SamplerStatus.NoChange
        Else
            ' Otherwise we set the displacement
            ' matrix for the current position
            mat = Matrix3d.Displacement(tmp.GetVectorTo(pt))
        End If
        Return SamplerStatus.OK
    End Function



 

    At the first glance the mistake is in this line:
  tr.Abort()

          You have never use tr.Abort within Using ... End Using statement, it will crash program in A2014
         So try next
 Add to References from .NET tab:
 PresentationCore.dll
 PresentationFrameWork.dll
 WidowsBase.dll
 Change Settings.vb
 Try Rebulid solution
 Here is my rework,
 Tested from windows form in 2014 - OK

_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 3 of 7
AubelecBE
in reply to: Hallex

my question is not on the command QT. but why autocad dont see my command !

 

Autocad write my msg when i netload the DLL but after the load i cant launch the command QT.

 

I dont see my command QT but only QTextemode etc..

 

so Why ?

 

I have added the reference presentation.. but not used by the program.

 

Message 4 of 7
Hallex
in reply to: AubelecBE

I've created a sample project with winform and this code
is working like a charm in my A2014, what else?
_____________________________________
C6309D9E0751D165D0934D0621DFF27919
Message 5 of 7
AubelecBE
in reply to: Hallex

I dunno why.

I used a sample project from lab_complete on vs2010

i delete all other projet

i add all my vb.form in this project.

i add reference from system.drawing et windows.

 

i compiled --> work now...

I check the difference but found nothing.. so dont know...

 

But now. the autoload via Registry not work. Autocad know the command but it is not load the DLL. I have checked the registry all it is ok..

 

So why ? 🙂

Message 6 of 7
AubelecBE
in reply to: AubelecBE

I have found why my DLL is not loading on startup.

the reason : http://forums.autodesk.com/t5/NET/AutoCAD-2014-Automatic-dll-loading/td-p/4580115

 

I have the description empty... such error for this....

 

But now, why my old project dont run ? I need to transfert all my DLL into a sample project.... I have checked the diff and see nothing.... I have export import the pref of VS2012 and nothing..

 

any idea ?

Message 7 of 7
Hallex
in reply to: AubelecBE

Sorry, no ideas about this issue
_____________________________________
C6309D9E0751D165D0934D0621DFF27919

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost