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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Refresh Autocad Drawing

Status
Not open for further replies.

CHTHOMAS

Programmer
Jun 16, 1999
106
0
0
AE
Visit site
Am very new to Autocad. I need help on how to refresh or reload an Autocad Drawing. The Autocad drawing displays or gets data from an Access database. I run a Macro once the drawing is opened whcih asks for a sheet number using a form. When the sheet number is provided the corresponding values are picked from Access database and displayed correctly. If i run the macro again, after providing a different sheet number the new data is not loaded or the Autocad drawing is not refreshed. Any help or suggestion will be highly appreciated.

Regards,

Charley

I use the following code on the form command button to get the sheet number
ThisDrawing.Input_mas_tag (txtMas_tag.Value)


Then i use the following function to retrieve the appropriate record from the database.

Public Sub Input_mas_tag(tmas_tag As String)
Dim acad_txt_ent As Object
Dim rec As Recordset
Dim st As String
Dim col As Integer, row As Integer, count As Integer
Dim main_values As Variant
UserForm1.Hide
st = "select * from TAG_MASTER where LPSN = " + Chr(34) + tmas_tag + Chr(34) + ";"
Set rec = db.OpenRecordset(st)
If rec.BOF = False Then
main_values = rec.GetRows(rec.RecordCount)
For Each acad_txt_ent In ThisDrawing.ModelSpace
If acad_txt_ent.EntityName = "AcDbText" Then
For count = 0 To UBound(main_values, 1) Step 1
If acad_txt_ent.TextString = rec.Fields(count).SourceField Then
If IsNull(main_values(count, 0)) = False Then
acad_txt_ent.TextString = main_values(count, 0)
Else
acad_txt_ent.TextString = "-"
End If
acad_txt_ent.Update
Exit For
End If
Next count
End If
Next
Else
MsgBox "no record found", vbOKOnly
End If
End Sub

The above codes are working correctly except that when i give the sheet number for the second time, the drawing is not refreshed.
 
Charley,
I am an expert in AutoCAD and an intermediate programmer of Access but I am not sure what you are trying to accomplish. What do you mean by refresh an AutoCAD drawing? What changes in the drawing? What is a sheet number in AutoCAD? Do you mean a drawing name or a page setup? I am very interested in what you are doing because I have all the background to help you, but I have never put Access and AutoCAD together this way. If I can help you, I stand to learn something. Please elaborate on your set up and I will try to help from there.
Jonathan
 
O.K I will tell you what i understand and know. Refreshing the drawing means loading the same drawing with new data or values from an Access database. The drawing itself don't change, instead there are some values/data displayed in the drawing (as number figures) and these changes. The sheet number is a table field(in Access). When the macro is run in Autocad,the data from Access is filtered based on the sheet number provided.

I will try to simplify. What am trying to do is open an Autocad drawing, then display some data from an Access database in the drawing whcih works fine now. Am running a Macro after loading the drawing whcih aks for the sheet number and then filters the appropriate record from Access database. Data to load from the Access database in the drawing is determined with the help of the Sheet filter whcih filters the record from the Access database. My problem is when i run the macro the first time, the filter works correctly and the drawing displays the data/values from Access correctly. But when i want to display another data/value in the same drawing, i again run the macro whcih asks the sheet number filter, after providing doesn't display the new data in the drawing. I hope am clear.
 
I am intrigued and am hoping someone else joins this discussion. I must have fallen to sleep the last year or two. I just came to the realization that users are getting away from attributes, autolisp and OLE in AutoCAD. I guess they are turning towards VB. What threw me for a loop is that you said you are very new to AutoCAD, yet your question is so advanced that I (with 15 yrs AutoCAD experience) can't even verify if you are asking the question correctly. This is no fault of yours, but I am shocked. I want to learn more about this so I will be watching this thread closely. Sorry I could not be more helpful.
Jonathan
 
Am very new to Autocad. The request came from autocad users and i did the retreiving of record from Access database. But as i said, don't know how to load the drawing with new data. A gap is there between autocad users who don't know much about vb and myself who don't know about autocad.

Regards,

Charley
 
Charley,

Can you break down the code for me. I am trying to follow but am getting confused by the nested if statements. (you are obviously a more experienced programmer then me)

Plus, please describe your drawing to me. What data is AutoCad getting from your recordset? How is it being displayed and stored. For example, your code looks like it is testing each text entity in model space for something and then assigning a value to it. The value comes from a recordset “rec” that is created by a query string “st” (Am I correct?) I am not sure how your code tells AutoCAD which field value from the recordset to apply to which text entity in the drawing. What are the values of the text entities in the drawing before you run your macro? To help me understand in basic terms, if you were doing this manually on paper with a pencil, and you had a spread sheet in front of you, what would you erase and change on the drawing and why? What is the relationship between the drawing and the spreadsheet?

I want to work with you to solve this problem as I spend all day using Access and AutoCAD. There is a good chance with my background and yours the solution is near. As I said before, I am learning from this and I hope that I am able to help you out as well. If nothing else, someone else reading this may be more able to help you after reading our dialogue.

Thanks
Jonathan
 
This may be very elementary, but would redraw or regen be what you are looking for

Use the REDRAW command to

refresh the display
remove all graphics remnants such as blips, stray pixels, and so on.
Note: This only affects the current viewport.

Use the REGEN command to

regenerate entire drawing data
recompute the screen coordinates
reindex the drawing database for maximum performance (recreates the display list).
Note: This only affects the current viewport.

The REDRAW command works significantly faster than the REGEN command.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top