Jump to content
dbroada

.Import equivalent?

Recommended Posts

dbroada

I am slowly going through my VBA routines looking for an easy one to convert to .NET and I thought I had found one....

 

Public Sub DxfImport(myFile As String)
Dim P1(0 To 2) As Double
Dim myScale As Double
Dim myTest
If Right$(myFile, 4) <> ".dxf" Then myFile = myFile & ".dxf"
myTest = Dir$(myFile)
If myTest <> "" Then
   P1(0) = 0: P1(1) = 0: P1(2) = 0
   myScale = 1

   ThisDrawing.Import myFile, P1, myScale

   End If

End Sub

 

however I can't get past the ThisDrawing.Import line.

 

I have tried

[font=Consolas][size=2]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Public[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Sub[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] aNewBit([/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]ByVal[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] myFile)[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Dim[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] acDoc [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]As[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Document[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] = [/size][/font][/size][/font][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af][font=Consolas][size=2][color=#2b91af]Application[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2].DocumentManager.MdiActiveDocument[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Dim[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] p1(0 [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]To[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] 2) [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]As[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Double[/color][/size][/font]
[/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Dim[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] myScale [/size][/font][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]As[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Double[/color][/size][/font]
[/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Dim[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] myTest[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] Right(myFile, 4) <> [/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]".DXF"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Then[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] myFile = myFile & [/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]".DXF"[/color][/size][/font]
[/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]myTest = Dir(myFile)[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2] myTest <> [/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]""[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Then[/color][/size][/font]
[/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]p1(0) = 0 : p1(1) = 0 : p1(2) = 0[/size][/font]
[size=2][font=Consolas]myScale = 1[/font][/size]
[size=2][font=Consolas]acDoc.IMPORT(myFile, p1, myScale)[/font][/size]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Else[/color][/size][/font]
[/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2]MsgBox([/size][/font][/size][/font][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515][font=Consolas][size=2][color=#a31515]"File doesn't exist"[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][font=Consolas][size=2])[/size][/font]
[/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]End[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]If[/color][/size][/font]
[/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]End[/color][/size][/font][/color][/size][/font][/color][/size][/font][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff][font=Consolas][size=2][color=#0000ff]Sub[/color][/size][/font]
[/color][/size][/font][/color][/size][/font]

 

but as you can see, Import hasn't been found in the acDoc object.

 

Any ideas?

Share this post


Link to post
Share on other sites
Tyke

Dave, have you seen this :

"DevTV: AutoCAD VBA to VB.NET Migration Basics.

To assist in migrating your AutoCAD VBA code to VB.NET, the Autodesk Developer Network team has created a simple migration assistance utility and accompanying video: "

at:

http://usa.autodesk.com/adsk/servlet/index?siteID=123112&id=770215

 

It would appear with Visual Studio 2010 (and the Express Edition) you can no longer import VB6 projects. But I need to research that a little further.

 

Jerry Winters also has a book "VB.NET Programming for AutoCAD Customization" which also deals with migrating VBA code to VB.Net.

Share this post


Link to post
Share on other sites
dbroada

thanks Tyke, I will have a look at that link when this weeks tasks are complete!

 

have you seen that book? I might be able to get my boss to buy it for me but I would like to hear from somebody who has used it.

 

and on a totally different note, did you get my pm?

Share this post


Link to post
Share on other sites
Tyke

Yup, I bought the book and its a good one, complete with CD with samples and also as a PDF-File, which is very useful.

 

If you want I can also dig out a few other references for you.

 

I did get the pm and will get down to answering it over the weekend.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...