.NET

Reply
Active Member
howard.barker
Posts: 9
Registered: ‎05-01-2007
Message 1 of 7 (1,187 Views)

VB.NET Equivalent of VBA object ThisDrawing missing FullName

1187 Views, 6 Replies
07-25-2013 04:17 AM

Hi,

 

in AutoCAD VBA the object ThisDrawing had a property FullName which gives the full pathname to the current active drawing, this is missing at VB.NET.

 

I have found some code for AutoCAD2013 which is:

 

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

Return db.Filename

 

My ThisDrawing code is

 

Dim m_AcadDoc As Autodesk.AutoCAD.ApplicationServices.Document m_AcadDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument

Return CType(Autodesk.AutoCAD.ApplicationServices.DocumentExtension.GetAcadDocument(m_AcadDoc), Autodesk.AutoCAD.Interop.AcadDocument)

 

Why is FullName missing from the .Net object, is there anyother way to modify the ThisDrawing object to give the property?

 

Regards

Howard

 

*Expert Elite*
norman.yuan
Posts: 1,001
Registered: ‎04-27-2009
Message 2 of 7 (1,174 Views)

Re: VB.NET Equivalent of VBA object ThisDrawing missing FullName

07-25-2013 06:41 AM in reply to: howard.barker

In .NET API, Autodesk.AutoCAD.ApplicationServices.Document class has a "Name" property, which is eqivalent to COM API's AcadDocument.FullName.

 

So, if you need full path, you can

 

Dim fullName As Strng=Application.DocumentManager.MdiActiveDocument.Name

 

A bit off topic: I see quite some code samples/articles claiming how easy to move from Acad VBA to .NET API and showing code to implement VBA's equivalent of "ThisDrawing" and then go to use COM API with VB.NET. IMO, this is the worst way to learn AutoCAD .NET API, especially for those who have VBA experience, but not very deep into programming as profession. If you find you are trying to create your own "ThsiDrawing" of AcadDocument type with VB.NET/C# without your unique requirement other than doing things like you do in VBA, you are not in a good direction of learning, although you may eventually be there, but with big detour.

ADN Support Specialist
fenton.webb
Posts: 352
Registered: ‎07-24-2007
Message 3 of 7 (1,150 Views)

Re: VB.NET Equivalent of VBA object ThisDrawing missing FullName

07-25-2013 02:48 PM in reply to: norman.yuan

For some people migrating from VBA to VB.NET is a huge leap, learning costs, reimplemetation costs, or both - therefore using the COM Interop libraries gives a very simple solution for those people.

 

Rewriting VBA code to native VBA can cost weeks of work, and what for? Proven, tested VBA code becomes buggy when rewritten in VB.NET and you've just spent 6 months to do it when you could have just ported your VBA to VB.NET and created new modules to do your new features in.

 

I'll say the same for LISP too - if you have a proven app written in LISP that works fine, unless you are running into performance issues - why rewrite it in another language? My advice is, create your *new* stuff with the latest technologies and let the legacy be.

 

In case you haven't seen it, check this out - http://adndevblog.typepad.com/autocad/2012/07/the-right-tools-for-the-job-autocad-part-1.html

 

About the original question - if you are not seeing the same property, then you are doing something wrong with your references - have you included all the *Interop*.dll's into your VS project?

 





Fenton Webb

Developer Technical Services

Autodesk Developer Network


Active Member
howard.barker
Posts: 9
Registered: ‎05-01-2007
Message 4 of 7 (1,096 Views)

Re: VB.NET Equivalent of VBA object ThisDrawing missing FullName

07-31-2013 11:38 AM in reply to: fenton.webb

Hi,

 

Thanks for the info & advice. For a bit of history, we have a small VBA module that creates a High Res Tiff image of the drawing during the SAVE event. We are moving from 2009 to 2013 and so now need to convert our VBA code into VB.NET hence my question.

 

I am fairly new to VB.NET and very new to AutoCAD vb.net so I dont understand most of what you have said.

 

I have seen a lot of VB code that would appear to work at 2009 but no longer works at 2013 so documentation I downloaded from Autodesk does not work in the 2013 environment so I'm not having a whole lot of fun trying to do this.

 

I seem to have my Tiff code working, I just need to somehow run my code whenever the user selects SAVE

 

Howard

*Expert Elite*
arcticad
Posts: 1,285
Registered: ‎06-21-2004
Message 5 of 7 (1,092 Views)

Re: VB.NET Equivalent of VBA object ThisDrawing missing FullName

07-31-2013 12:01 PM in reply to: howard.barker
http://forums.autodesk.com/t5/NET/Watch-Save-SaveAs-Event/td-p/2512425
---------------------------



(defun botsbuildbots() (botsbuildbots))
Active Member
howard.barker
Posts: 9
Registered: ‎05-01-2007
Message 6 of 7 (1,070 Views)

Re: VB.NET Equivalent of VBA object ThisDrawing missing FullName

08-01-2013 09:11 AM in reply to: arcticad
Many thanks,
I will tackle this when I get back from vacation!
Regards
ADN Support Specialist
augusto.goncalves
Posts: 361
Registered: ‎04-30-2009
Message 7 of 7 (1,065 Views)

Re: VB.NET Equivalent of VBA object ThisDrawing missing FullName

08-01-2013 09:35 AM in reply to: howard.barker

Hope the suggestions you got helped you... if so, please go ahead and mark as 'Accept as Solution'

 

Thanks!

 

Regards,



Augusto Goncalves
Autodesk Developer Network
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.