vb.net with AutoCad 2013

vb.net with AutoCad 2013

Anonymous
Not applicable
1,061 Views
4 Replies
Message 1 of 5

vb.net with AutoCad 2013

Anonymous
Not applicable

I using following Code to create a property "ThisDrawing". I want to use this to run customised program.

 

 

Public Class Class1
     Public ReadOnly Property ThisDrawing As AcadDocument
          Get
                Return _  

                Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.acaddocument
         End Get
     End Property

End Class

 

I am getting error message as "acaddocument' is not a member of Autodesk.AutoCAD.ApplicationServices.Document".

 

Can any one help me to solve this problem.

0 Likes
1,062 Views
4 Replies
Replies (4)
Message 2 of 5

augusto.goncalves
Alumni
Alumni

Please use GetAcadDocument instead AcadDocument

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thanks a lot for answering. 

When I type GetAcadDocument it is still not identified.

The code I mentioned below works fine with AutoCad 2011.

 

For AutoCad 2013 I wrote this code and it worked fine

 

Module DrawLine2P

    <CommandMethod("DrawL")> _
     Public Sub DrawL()

          Dim acdoc As Document = Application.DocumentManager.MdiActiveDocument
          Dim acCurDb As Database = acdoc.Database
          Dim PT1 As Point3d = New Point3d(0, 0, 0)
           Dim PT2 As Point3d = New Point3d(PT1.X, _
                                                                    PT1.Y + 10, _
                                                                     0)
             Dim PT1 As DBPoint = New DBPoint(New Point3d(0, 0, 0))
            Dim PT2 As DBPoint = New DBPoint(New Point3d(PT1.Position.X, _
                                                                                             PT1.Position.Y + 10, _
                                                                                             0)

            Using acTrans As Transaction = acCurDb.TransactionManager.StartTransaction()
                  Dim acBlkTbl As BlockTable = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead)
                  Dim acBlkTblRec As BlockTableRecord = acTrans.GetObject(acBlkTbl(BlockTableRecord.ModelSpace),                        

                                                       OpenMode.ForRead)

                   Dim acLine As Line = New Line(PT1, PT2)
                   acLine.SetDatabaseDefaults()
                    acBlkTblRec.AppendEntity(acLine)
                     acTrans.AddNewlyCreatedDBObject(acLine, True)

                   acTrans.Commit()

             End Using
       End Sub

End Module

 

I understand that there are lot of changes in API for AutoCAD 2013. Is it so.

0 Likes
Message 4 of 5

augusto.goncalves
Alumni
Alumni

This code you mention it's not using COM, only .NET API, therefore there is no need for GetAcadDocument....

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network
0 Likes
Message 5 of 5

Anonymous
Not applicable

Thanks a Lot Mr. Augusta for your kind help.

I will do some further study and get back to you.

 

Ajit Joshi

0 Likes