AutoCad 2010 dotNet Wizards

AutoCad 2010 dotNet Wizards

mgorecki
Collaborator Collaborator
670 Views
3 Replies
Message 1 of 4

AutoCad 2010 dotNet Wizards

mgorecki
Collaborator
Collaborator

I'm using AutoCad 2010 and Visual Studio.  I have created projects before, but not any new ones in a while.

When I start I pick the Autodesk - AutoCAD plug-in template.  This looks like it starts me out just fine, but in the Application tab for "My Project" it has "WPF Class Library".  In other projects I was able to select just "Class Library".

Anyway, I have the references set for AcDbMgd and AcMgd, Interop and Interop.Common.

The problem is, I can create a quickie program, save it, and try to debug it, but it tells me "Unknown command".

Can anyone help me out?

 

Thanks

0 Likes
671 Views
3 Replies
Replies (3)
Message 2 of 4

hgasty1001
Advisor
Advisor

Hi,

 

Show the code, otherwise it's a guessing play.

 

Gaston Nunez

0 Likes
Message 3 of 4

mgorecki
Collaborator
Collaborator

The code is just a snippet, used for testing.

 

Imports Autodesk.AutoCAD
Imports Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.ApplicationServices.Application
Imports Autodesk.AutoCAD.DatabaseServices
Imports Autodesk.AutoCAD.EditorInput
Imports Autodesk.AutoCAD.Geometry
Imports Autodesk.AutoCAD.Interop
Imports Autodesk.AutoCAD.LayerManager
Imports Autodesk.AutoCAD.Runtime
Imports Autodesk.AutoCAD.Windows
Imports System.Runtime.InteropServices

Public Class myClass
    <CommandMethod("addline")> _
    Public Sub addline()
        Dim podTransMan As DatabaseServices.TransactionManager
        Dim podTrans As DatabaseServices.Transaction
        Dim podDwg As Document

        podDwg = Application.DocumentManager.MdiActiveDocument
        podTransMan = podDwg.TransactionManager
        podTrans = podTransMan.StartTransaction

        Dim X As Double
        Dim newTransMan As DatabaseServices.TransactionManager = podDwg.TransactionManager
        Dim newTrans As Transaction = newTransMan.StartTransaction
        Dim BT As BlockTable = newTrans.GetObject(podDwg.Database.BlockTableId, OpenMode.ForRead)
        Dim BTR As BlockTableRecord = newTrans.GetObject(BT("*Model_Space"), OpenMode.ForWrite)
        Dim PtA As New Point3d(0, 0, 0)
        Dim PtB As Point3d
        For X = -3 To 3
            PtB = New Point3d(X, 4, 0)
            Dim newLine As New Line(PtA, PtB)
            BTR.AppendEntity(newLine)
            newTrans.AddNewlyCreatedDBObject(newLine, True)
        Next
        newTrans.Commit()
        newTrans.Dispose()
        newTransMan.Dispose()
    End Sub
End Class

 In the Application tab of properties, under application type, it only allows "WPF Application", "WPF Class Library", or "WPF Console Application".

In other programs I used "Class Library" as it was the default option.  Those programs were writen a while ago on another computer.  I got a new computer and installed the new template from AutoDesk.  This new template just doesn't seem right.

 

 

 

 

0 Likes
Message 4 of 4

mgorecki
Collaborator
Collaborator

Also, if anyone does not use the template, please let me know your process of setting up. 

Thanks

0 Likes