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

vb.net with AutoCad 2013

4 REPLIES 4
Reply
Message 1 of 5
ajoshi1967
825 Views, 4 Replies

vb.net with AutoCad 2013

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.

4 REPLIES 4
Message 2 of 5

Please use GetAcadDocument instead AcadDocument

 

Regards,



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

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.

Message 4 of 5

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
Message 5 of 5
ajoshi1967
in reply to: ajoshi1967

Thanks a Lot Mr. Augusta for your kind help.

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

 

Ajit Joshi

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