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

VB.NET Sample Code from .NET Developers' Guide Not Working for Me

5 REPLIES 5
Reply
Message 1 of 6
btillman
2747 Views, 5 Replies

VB.NET Sample Code from .NET Developers' Guide Not Working for Me

I hate to keep being the complainer in the group but I'm really trying to understand how to become a better programmer in .NET. My mission today was to write some code which would open an existing drawing. I worked on a machine with 2009 first and only limited success, so I then went to another computer running AC 2013 and accessed the 2013 .NET Developers' Guide at this link:

 

http://docs.autodesk.com/ACD/2013/ENU/index.html?url=files/GUID-4E1AAFA9-740E-4097-800C-CAED09CDFF12...

 

About 1/2 way down the page I found information on how to open an existing drawing. As usual the text is missing what references need to be added in order to make the code work. So thinking it would be as the first couple of chapters in the guide outlined I would need the following:

 

    AcMgd.dll       AcDbMgd.dll     AcCoreMdg.dll

 

When I inserted the code I got the error

 

'Open is not a member of Autodesk.AutoCAD.ApplicationServices.DocumentCollection'

 

Now trying to be student who learns why this is happening I do a quick search and find in another Autodesk forum that DocumentCollection should be replaced with DocmentCollectionExtension and that I should read more in the .NET migration part of the .NET Developers' Guide for 2013. I further see mention that the statement should actually be DocumentCollectionExtension.Open but I cannot get the .Open to enter into the IDE. I guess I'm missing another refernence but since I've tried just about all of them I cannot imagine which one it could be.

 

I have poured over the migration page and found only limited information on how I could resolve this. Perhaps I am missing it right in front of me.

 

 

5 REPLIES 5
Message 2 of 6
arcticad
in reply to: btillman

You have probably already seen this.

 

http://forums.autodesk.com/t5/NET/Open-is-not-a-member-of-ApplicationServices-DocumentCollection/td-...

---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 3 of 6
fieldguy
in reply to: btillman

Hello btillman.  I wanted to try this since I installed Map 3D 2013 last week.  This works, but for some reason it is not the "active" drawing - drawing 1 is on top (active) after I run this.

 

Option Strict On
Option Explicit On

Imports acapp = Autodesk.AutoCAD.ApplicationServices
Imports Autodesk.AutoCAD.Runtime

Public Class Acad2013Class1

    <CommandMethod("opendwg")> _
    Sub openmain()
        Dim fname As String = "d:\acad\drawings\ne.dwg"
        Dim acdocmgr As acapp.DocumentCollection = Nothing
        Dim acdoc As acapp.Document = Autodesk.AutoCAD.ApplicationServices.DocumentCollectionExtension.Open(acdocmgr, fname, False)
        acdocmgr.MdiActiveDocument = acdoc
    End Sub

End Class

 I am also attaching a screen shot of the references.  I do not do this as a rule.  I feel it is an important part of learning app. development in the .NET environment.  APIs and Namespaces contain all of the secrets - the coding part is easy. 

 

Good luck!

Message 4 of 6
btillman
in reply to: arcticad

Thanks for all the replies. And yes, arcticad, that was the exact post I was referring to. And in that post the moderator is showing something which looks like he's correcting the OP with DocumentCollectionExtension.Open. However, I cannot seem to get the .Open part to enter into the IDE of VB 2010 Express.

 

I examined the other reply that included a screen shot of all the references and mine match his exactly. I willi try the code he indicates works for Map 3D but he also mentions that the drawing he opens does not end up as the Active drawing. I think I can tweak that part. But the first thing is to just try and get a drawing to open.

Message 5 of 6
chiefbraincloud
in reply to: btillman

I think the reason fieldguy's code is not activating the new drawing is because he does not have the Session flag on the CommandMethod.

Dave O.                                                                  Sig-Logos32.png
Message 6 of 6

From what I've been told, VB.NET 2010 does not recognize some extension methods and its logged as a bug on Microsoft Connect.

 

The fact is that Open() and other methods of the DocumentCollectionExtension class are extension methods that allow them to be used as if they were methods of the DocumentCollection, which (in c# at least) means the same source code that calls them in earlier releases will still work in AutoCAD 2013.

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