Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access output to Autocad 1

Status
Not open for further replies.

HanKleppe

Programmer
Mar 17, 2005
50
0
0
NL
Dear Forummembers,

After Todd, helped me great with im/exporting Attributes to Access I'm in the next step of my little program.

I have a button in Access. When I click it, it opens Autocad and opens the primary key, what is a pathname.

Code:
Dim X, Y
Y = "C:\Program Files\AutoCAD 2004\acad.exe " & [Forms]![Formulier1]![Tekst31]
X = Shell(Y, 1)
End Sub

Now I want Access to print. /p is usually by office programs but doesn't work in autocad.

I have also a field in the table containing the number of printing files. I want Autocad use this number to his printnumber.

Who can give me a kick in the good way?

Thanks!
 
Hi Todd,

Hopefully this time I'm smart :eek:)

Code:
Dim X, Y
Y = Chr(34) & "C:\Program Files\AutoCAD 2004\acad.exe" & Chr(34) & " /b " & Chr(34) & "import" & Chr(34) & [Forms]![AutoCAD Updater]![Tekst31]
X = Shell(Y, 1)

End Function

I tried it like this way but it gives the same error:
"importC:\AutoCAD\Tekeningen\250000.dwg"
Invalid file name


TIF
Han
 
Ok,

Try it this way:

Code:
Dim X, Y
Y = Chr(34) & "C:\Program Files\AutoCAD 2004\acad.exe" & Chr(34) & " /b " & Chr(34) & " import " & Chr(34) & [Forms]![AutoCAD Updater]![Tekst31]
X = Shell(Y, 1)
 
Hi Todd,

That was what we called a 'doublepost' :eek:)

Does it work by you? It gives by me still the same error.

TIF
Han
 
Hi Todd,

And just another doublepost :eek:)

we make steps further, it gives now the following error:
(exactly)

-
" import C:\AutoCAD\Tekeningen\250000.dwg"
-

What is chr(34)?

TIF
Han
 
Hmmm...

Just for grins, how about this:

Code:
Y = "'C:\Program Files\AutoCAD 2004\acad.exe' /b 'import'" & [Forms]![AutoCAD Updater]![Tekst31]

Todd
 
Hi Todd,

This is so weird, I try it several times with several quotes but it haven't the good effect...

I have a better solution. How can I run the script automatically on startup? (so no switches)
Then I load the original script:

Y = "C:\Program Files\AutoCAD 2004\acad.exe" & [Forms]![AutoCAD Updater]![Tekst31]

On the desktop I'll make a shortcut with the parameter who disable the script and runs AutoCAD normal.

What's your though about it?

Han
 
Hi Han,

Are you still setting a reference to AcadApp and AcadDoc or have those fallen by the wayside?

If you are still using these, just use this to run your macro:

Code:
AcadApp.RunMacro ("acad.dvb!import")

HTH
Todd
 
Hay Todd,

I made it working:

Code:
Y = "C:\Program Files\AutoCAD 2004\acad.exe /b Import " & [Forms]![AutoCAD Updater]![Tekst31]

Just the space between the /b and Import

It works great!!!!

Thanks!!!!!

Han
 
Hi Todd,

That's really cool (My dad is a couple of years older, I mean 43 but he never say cool :eek:) so helping 19year old students keeps you young :-D)

It works amazing fast, I think the whole proces, opening AutoCAD, the good drawing, checking how much prints he must make, saving and closing is around the 5 seconds, so my boss is really happy :-D

My workingday is almost over, let you tommorow know what the exact details are

Have a good working day!

Bye
Han
 
Hi Todd,

How are you doing?
Hope this is the right thread to post this question. Do you know how to export automatically a JPG/WMF file from AutoCAD.

I tried this code, but it gives an failure and on internet/google we're no good examples

Code:
AutoCAD.AcadApplication.ActiveDocument.Export ("c:\", "WMF", "all")

In AutoCAD I see two tabs, Model and Layout1, when i run the command jpgout and I write all, it select only the blocks in layout, not the drawing. And when I go to Model the're only a painting without blocks.

Have you a solution?

Bye
Han
 
Hi Han,

Sorry for the late reply. This ones tough, and I use the send command for this:

Code:
AcadDoc.SendCommand "WMFOUT" & vbCr & _
                    WMFFileName & vbCr & _
                    "GROUP" & vbCr & _
                    wmfGroup.Name & vbCr & vbCr

You'll notice the group option in the syntax, you can create a selection set prior to calling WMFOUT and then in the command line instead of "GROUP", you would use "P" for previous.

HTH
Todd
 
Todd, I saw your post in another thread about pushing block attribute values to MSAccess. Great Info! Can you post the Access code to push data that has been revised in Access back into the drawing (prefer the drawing not required to be opened first)?

I hope I haven't messed up your thread here, but you seem to be "The Man" to pose this question to. Many thanks in advance!
 
Hi ShipEngineer,

Thanks for the kudos, if you've had a chance to look at the FAQ, going the other way is pretty much the same, the difference being in this section of code (or more specifically, the line in red:

Code:
  ' Walk the array, comparing tag strings to field names,
  ' and populating or updating accordingly.
  '
  For intAttribCnt = LBound(varAttribs) To UBound(varAttribs)
    For Each fldAttribs In rstAttribs.Fields
      ' Does the tag string value match the field name?
      '
      If UCase(fldAttribs.Name) = UCase(varAttribs(intAttribCnt).TagString) Then
        ' Must have the corresponding tag string and field name.
        '
        [red][b]varAttribs(intAttribCnt).TextString = fldAttribs.Value[/b][/red]
        Exit For
      End If
    Next fldAttribs
  Next intAttribCnt

You'll also notice you can delete the if statement checking the length of the attribute, since you're updating it anyway, you don't need it. I'm not quite sure what you mean by:
(prefer the drawing not required to be opened first)?

You can do all of your editing you want in Access but to update the attributes, you will have to open the drawing. If you're dead set against opening the drawing, you can try the openDWG ActiveX control (DLL?) to talk to AutoCAD drawings without running AutoCAD - it's been a while but I'm sure they're still around.

HTH
Todd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top