Avatar of Colelspg
Colelspg

asked on 

MS Access to display AutoCAD file

I'm trying to embed an Auto CAD drawing into an MS Access form and/or report.  The Auto CAD files exists and was created in AutoCAD 2007 and opens just fine on its own.  In Access 2003, I've opened a form and tried to insert object and choose Auto CAD drawing.  It comes up blank and I can't seem to link it to the drawing I want to display.  I thought maybe I could change the "Source Doc" property, but it doesn't seem to have any affect.  Is there some way to display the Auto CAD file?  Ultimately, it will need to be able to display any one of several files, but I would like to see it display even just one.

Thanks
CAD/Architecture SoftwareMicrosoft Access

Avatar of undefined
Last Comment
Colelspg
ASKER CERTIFIED SOLUTION
Avatar of Jeffrey Coachman
Jeffrey Coachman
Flag of United States of America image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of Colelspg
Colelspg

ASKER

Hi Jeffrey,

I have Archibus-FM DWG that is acting as my default "AutoCAD Viewer"; whenever I activate the AutoCAD drawing from within Access, it is launching this program.  Unfortunately, I'm struggling to get this viewer to do even the most basic of things, like move the drawing to the center of the window.  The Class variable is "ARCHIBUS-FM DWG.Drawing.17" and I was hoping that there might be one for just AutoCAD without having to use the above-mentioned viewer.  From what your previous posting explains, there doesn't seem to be one.  

I did follow your suggestion to link the drawing, and it is displaying the file as I wanted.  The piece that I need now is, the file that it is linked to needs to be changed via the VBA code.  The tests that I've done so far haven't produced the desired result.  (I can give a more detailed explanation if necessary.) Can you offer any suggestions on how this can be done, assumming that the AutoCAD viewer part is working and that the drawing can not be converted into a .bmp, .jpg, etc?

Thanks
Colelspg,

Let me see if I fully understand.

Do you want to open up your form and "See" the drawing?
Do you need to also "Make Changes" to this drawing?
If you link the file, then click the link, does the drawing open?
What do you mean by "the file that it is linked to needs to be changed via the VBA code"?

Is Archibus-FM DWG an Active-x control that should allow you to view AutoCad Drawings in Access?
If it is not centering the drawing, then you need to contact them for instructions.

Jeff Coachman
Avatar of Colelspg
Colelspg

ASKER

Jeff,

Let me try to explain the situation a little more clearly.  This access database is being used with another program to hatch floor plans of buildings.  You provide some input parameters via access, and the hatching program runs, creating your desired hatchings.  There are currently 4 drawings that are being hatched, but that number could potentially increase to dozens.

So to answer your questions, yes when the form opens I want to see the drawing.
I dont' need to make any changes to the drawing directly, only through the hatching program.  After the hatching program runs, though, the drawing displayed in access needs to be refreshed.
As far as the linking to the drawing goes, let me explain what I did, what it looks like and then what I need it to do: What I did was to "insert object" and chose the "create from file", browsed to the file and checked the "link" option.  What this did was to create an Unbounded Object Frame control in the form with some of the properties that I mentioned earlier (OLE class, type, etc.)

This part of it works fine. The drawing only "opens" through Archibus-FM DWG when the form is in design view, which is what I want.  By playing around with some of the properties of the drawing I'm getting it to look reasonable, so ignore my earlier venting about the drawing not centering and such.

Since there are 4 drawings that are being hatched, I now need a way to display any of the four drawings.  I was imagining a combo box with the names of the drawings, and which ever drawing is selected in the list would appear on the form.  I thought I could do this by changing the "Source Doc" property of the Unbound Object Frame followed by a requery. The requery seems to be doing something, but setting the source doc to the path of the specified drawing isn't changing the drawing as it appears in the form.

Hope that's more clear.  As far as the Archibus-FM DWG being an Active-X control or not, I'm not really sure.  When the drawing is double-clicked (and the form is in design mode) then a new window opens with the Archibus-FM DWG as the title, and a whole set of menus and buttons, so I kinda think it's it's own application.

Thanks
Colelspg,

OK,

So...
<You provide some input parameters via access, and the hatching program runs, creating your desired hatchings.>
Has this ever worked?
Meaning, it works ok, but now you want to "Hatch" multiple drawings?

<This access database is being used with another program to hatch floor plans of buildings.>
Is this "Other Program" Archibus-FM DWG, or is this another separate program?

Jeffc
Avatar of Colelspg
Colelspg

ASKER

Jeff,

Yes, the hatching works fine.  It is configured to hatch multiple buildings and run them sequentially.  Calling this third program (called EZ-Hatch) from Access is no problem.

As an example, lets say there are 4 buildings named B1, B2, B3 and B4.  You can run EZ-Hatch to create 4 drawings with names of, say, HatchB1, HatchB2, HatchB3 and HatchB4.  It's these drawings that I want to display in Access.  

So let's say that the user is working with the drawing HatchB2.  The drawing is displayed in the form. The user then changes some parameters that requires the program to run EZ-Hatch.  They click on a button and EZ-Hatch runs and updates (overwrites) HatchB2.  I now need to tell Access to requery the drawing.  What's more, let's say that the user is finished with HatchB2 and wants to look at HatchB3.  I need the program to be able to view any of a list of drawings.  What I've been able to do is to "hard-code" the Unbound Object Frame to a specific drawing that is displaying the specified drawing.  But I don't want to have to do that for each drawing, as there could be a very large number of drawings involved.

So what I need is code that does the following:
1) requery the Unbound Frame Object (me.name.requery doesn't work)
2) assign a different drawing to the control in the form (me.name.sourcedoc doesn't work)
Hmmm.

OK things are a little more complicated now.

Can you post a copy of your current database to:
ee-stuff.com
(Remove any sensitive data if you like)

Jeffc
Avatar of Colelspg
Colelspg

ASKER

https://filedb.experts-exchange.com/incoming/ee-stuff/2670-Demo-Autocad-Link.zip
and
https://filedb.experts-exchange.com/incoming/ee-stuff/2671-Hatch.zip

The first is the database (very generic, contains only the form we are discussing) and the second contains the drawings (again very generic).  The database is looking for the drawings in "C:\Documents and Settings\Test" so you'll need to extract the drawings there.
Avatar of Colelspg
Colelspg

ASKER

Hi Jeffrey,

How's it going?  Were you able to extract all the files? Do you need me to provide any more backgound info?  This problem isn't critical at this point, but I would like to understand what my problem is. It's very possible that I'll need to make a decision on whether to attempt to add the drawing into a form and/or report next week, so I need to know what the pros vs cons of attempting to do what I want to do are.  

I honestly didn't expect this problem to turn out to be so difficult, but I guess that's sometimes how it goes, right?

All the best :)
Oops!
I overlooked you post.
I'll review them tonight.

Thanks for the reminder
Avatar of Colelspg
Colelspg

ASKER

OK Jeff, I guess we both must have gotten busy working on other things.  I'm going to chalk this one up to a problem with the Archibus viewer.  At any rate, the start date of this project keeps getting pushed back and put on the back burner, so it's not very critical anyway.  Besides, putting those drawings into Access is only a small part of the bigger picture.

Thanks for your work on this question.  Sorry I kept changing the question on you, but I appreciate you sticking with it as long as you did.  

:-)
Microsoft Access
Microsoft Access

Microsoft Access is a rapid application development (RAD) relational database tool. Access can be used for both desktop and web-based applications, and uses VBA (Visual Basic for Applications) as its coding language.

226K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo