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

VB.NET Equivalent of VBA object ThisDrawing missing FullName

6 REPLIES 6
Reply
Message 1 of 7
howard.barker
2651 Views, 6 Replies

VB.NET Equivalent of VBA object ThisDrawing missing FullName

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

 

6 REPLIES 6
Message 2 of 7
norman.yuan
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.

Message 3 of 7
fenton.webb
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
AutoCAD Engineering
Autodesk

Message 4 of 7
howard.barker
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

Message 5 of 7
arcticad
in reply to: howard.barker

http://forums.autodesk.com/t5/NET/Watch-Save-SaveAs-Event/td-p/2512425
---------------------------



(defun botsbuildbots() (botsbuildbots))
Message 6 of 7
howard.barker
in reply to: arcticad

Many thanks,
I will tackle this when I get back from vacation!
Regards
Message 7 of 7

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

 

Thanks!

 

Regards,



Augusto Goncalves
Twitter @augustomaia
Autodesk Developer Network

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