Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




AutoCAD And Excel


Hello,

I am trying to develop an application that allows users to manipulate tables in AutoCAD. These changes should dynamically update an Excel spreadsheet with the same information and vice-versa (Excel to AutoCAD). If anyone knows where I should begin, maybe a tutorial or something of that nature, it would be greatly appreciated. I am new to both VBA and AutoCAD.

Thanks!




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Autocad, VB, And Excel
Hi:

I am new to hardcore Visual Basic Programming. Normally I'm a hardware person. Anyway, I am designing a fullsize aircraft and have Autocad 2000, MS Office 2000, and Visual Basic 6 Learning Edition, and AutoCad 2002 (15-day license) to help me make it happen.

I have encountered problems and the answers lie in using the powerful tools of the combined programs above.

1. The first problem is my that airfoil data is in Excel cells. As you can imagine with a main wing of various diminsions, and tail feathers of various lengths and airfoil selections, it is not an easy job trying to calculate all of the plots for each station and then enter them into an AutoCad 3D plot. I'll be an old man, too old to fly by the time I get all of the data entered.

2. Since my aircraft is still in the design stages, I still have to make the final weight and balance calculations, load bearing structure adjustments, etc. So if I have to move something, Murphy's Law states my problem grows exponentially.

3. Since the main wing has an 8 Degree Dihedral, I need to show the ribs leaning at, well 8 degrees.

4. The fuselage diminsions fall into the same problem with #1.

I saw a thread from a user requesting assistance for Visual Basic, Excel and Autocad and tried to run the program. I guess I wasn't holding my head the proper way since it didn't work.

I even stood on my head and made burnt offering to the computer Gods and it still wouldn't work. So I guess I'm still a Beginner/Novice.

So I am in need of a little hand holding and friendly help.

Thanks in advance for your time.

Tony

P.S.

Oh yes, I can fly and build airplanes a lot better than I can program.

VBA, AutoCad To Excel
Hello,

I am trying to write some data from MSFlexGrid in AutoCad to Excel file.

Problem:
I have CommonDialog with name "AskToSave" in Form1, and set filter: Excel files (*.xls)|*.xls|All Files (*.*)|*.*

When I press some button program should ask me for the path and file name for excel file I want to create and save. I don't need to open the Excel or write something to it at the moment.
Excel file with chosen name and selected path should be just created.

Next step will be to open that file, write some date in it and just save it with the same name. I don't need help with this part.

Please help to solve the Problem:


Code:
Private sub SomeButton_Click()

Dim NameOfFile As String
AskToSave.ShowSave
NameOfFile = AskToSave.FileName
If NameOfFile = "" Then
mess = MsgBox("You must enter file name.", vbOKOnly, "Error")
Exit Sub
End If

End Sub

Autocad (dwg) To Excel)
how to export dwg file data like dimesions,text,layernames to excel using vb.6
its urgent

Using Excel To Draw In AUTOCAD
Is it possible that by using some kind of routine in excel spread sheet we can make diagram of the object if we place x, y,z coordinate in AUTOCAD.
Like if i place X , Y , Z axes coordinates of an object in excel spread sheet can excel draw that object or lets say that the values from excel are picked up by AUTOCAD to make that object.

Data From Excel To Autocad
Hello
how i take data from excel to be drawn in autocad (2 dimention), X_Y
thanks alot for advice

Egyptian Man

Help With Classes - For Use With Excel And AutoCAD
I'm making an application extracting data from excel, and outputting into AutoCAD. The problems I'm having are listed below, if you can help with any of them, I would greatly appreciate it.

1. I guess you can't pass multidimensional arrays to functions/subs? Is this assumption correct? Because I wanted to store Polylines as a class using a two dimensional integer array (an array of integers as the vertex, and an array of those vertices as the polyline). I want to be able to pass the information all at once into the newly created object, but it's a multidimensional array. (I also need to output the polyline as a 2d array, haven't gotten that far yet)

2. I want to pass more than one parameter into a method that is a part of the Polyline class. When I'm doing this,

ie. pline.newvertex(VertexPoint, Position)
VB says "expected ="

Why do I need an equals sign? nothing is being returned... it doesn't prompt me for an = sign when I'm only passing 1 parameter.

3. I can declare an empty array, A() as integer... but can I declare an empty 2d array, I haven't gotten it to work... A(,) as integer.


Here's the class I'm having trouble with... I've rewritten it so many times that I don't know what to do with it, so don't expect it to be anything resembling functional

Dim Vertices(4, 3) As Integer

Public Property Get Coords() As Integer

Coords = Vertices

End Property

Public Sub AddPoint(Value() As Integer, Position As Integer)

If Position <= 3 And Position >= 0 Then
Vertices(Position) = Value
End If

End Sub

You would think that this would be simple, but I've tried everything I can think of. I haven't used classes or in VB before, only C++, so I'm wondering if thats part of the problem. I appreciate any help with this, and once I get some of these small problems worked out, I'll be able to work out more of the code to show.

Thanks

AutoCAD-Excel Drawing Link
How to write code for drawing simple rectangle using data from Excel cells

Moving Text From Autocad To Excel
hello!!
first time user.

I am trying to move text from autocad to excel by using the following Sub.
Result: all text in one column.
What I need, is for all text to be in several columns like the tables in acad.
Public Sub DoIt()

  Dim oEntity As AcadEntity
  Dim oLayout As AcadLayout
  
  Dim sFile As String
  
  Dim lFile As Long
  
  
    For Each oLayout In ThisDrawing.Layouts
        For Each oEntity In oLayout.Block
            If TypeOf oEntity Is AcadText Or TypeOf oEntity Is AcadMText Then
            sFile = sFile & oEntity.TextString & vbCrLf
        End If
        Next
   Next
  
  If VBA.Len(sFile) > 0 Then
    lFile = VBA.FreeFile
    Open "c:Test.XLS" For Output As #lFile
    Print #lFile, sFile
    Close #lFile
  End If

End Sub

Thanks for you help.

Accessing Info In Excel From Autocad
Hello!
I know probably only a few of you use autocad. But a similar problem might exist if you try to retrieve data from Excel from another program like Access or SQL? Any help will be really appreciated!

I get an error message when my program (running out of autocad) tries to read information from a workbook when excel is already open. it runs fine when excel is completely closed, but throws an error: 1004 - "Application-defined or object-defined error" when excel is open the second it tries to read something from the workbook. I don't know what I'm doing wrong. Maybe I'm referencing something wrong. I'm pretty much stuck.

Here is my code. You would need autocad and excel to run it. If you can run it, all you have to do is make an excel workbook and put some data in the 1st worksheet in column A. And insert the path and file name into the program where you see: XL_file = "XL_file = "C:macro1.xls"...... It will open the excel file and put a message box that says the content of the last cell occupied in column A. Unless excel is open. Then it'll throw the 1004 error like I said.

Code:
Sub cantsetupexcel()

    '**********************
    'declare excel objects
    Dim excelApp As Excel.Application
    
    Dim wbkobj As Workbook
    Dim wbkobjs As Workbooks
    Dim shtobj As Worksheet
    Dim shtobjs As Worksheets
    
        
    Dim ACAD_folder As String
    Dim XL_file As String
    XL_file = "C:macro1.xls"

    On Error Resume Next
    Err.Clear
    Set excelApp = GetObject(, "Excel.Application")
    If Err <> 0 Then
        Err.Clear
        Set excelApp = CreateObject("Excel.Application")
        If Err <> 0 Then
            MsgBox "Cannot start Excel", vbExclamation
            End
        End If
    End If
    excelApp.Visible = True
    
    'On Error GoTo Errhand
    On Error GoTo 0
    
    ' See if particular workbook is open...
    Dim CheckOpen As Boolean
    Dim OpenCnt As Long
    Dim XL_file_Name As String
    For OpenCnt = 1 To excelApp.Workbooks.Count
        If excelApp.Workbooks(OpenCnt).FullName = XL_file Then
            CheckOpen = True
            XL_file_Name = excelApp.Workbooks(OpenCnt).Name
        ElseIf CheckOpen = True Then
            CheckOpen = True
        Else
            CheckOpen = False
        End If
    Next
    ' Set workbook objects to desired workbook object
    If CheckOpen Then 'if open, don't re-open
        Set wbkobj = excelApp.Workbooks(XL_file_Name)
        Set shtobj = wbkobj.Worksheets(1)
    Else ' if not open, open from scratch
        Set wbkobj = excelApp.Workbooks.Open(XL_file)
        Set shtobj = wbkobj.Worksheets(1)
    End If
    
    ' Place data into array.
    
    ' Define initial variables
    Dim Bottom_loc As Long
    'MsgBox (Err.Number)
    Bottom_loc = Range("A" & Range("A:A").Rows.Count).End(xlUp).Row 'error occurs here
    ' Range("A65536").End(xlUp).Row
    Dim farright_Loc As Integer
    farright_Loc = Range("A1").End(xlToRight).Column
    
    Dim Search_Criteria As Variant
    Set Search_Criteria = Worksheets(1).Range(Cells(2, 1), _
    Cells(Bottom_loc, 1))
    Dim SC_Val2() As String
    Dim SCidx As Long
    SCidx = 1
    For Each cell In Search_Criteria
        'MsgBox (cell.Value)
        ReDim Preserve SC_Val2(1 To SCidx)
        SC_Val2(SCidx) = cell.Value
        SCidx = SCidx + 1
    Next
    MsgBox (SC_Val2(1))
    
Errhand:
    Dim errcode As Variant
    errcode = Err.Description
    MsgBox (errcode & " " & Err.Number)

    Set excelApp = Nothing
    Set wbkobj = Nothing
    Set wbkobjs = Nothing
    Set shtobj = Nothing
    Set shtobjs = Nothing

End Sub


Many thanks to those that have suggestions!



Edited by - AgentH on 9/15/2006 8:44:00 AM

AutoCAD With VB(A) Without Opening AutoCAD
Hi everybody.

Do you know a way to use AutoCAD with vb or vba without opening AutoCAD. I would like to draw files or to use AutoCAD possibilities without opening AutoCAD. Is there an .OCX or something like that ? Any other idea ?

How To Use Autocad, Without Installing Autocad
i program vb6 sp5 applications that use the autocad drawing engine, this works fine for most all applications as autocad is installed on the target machine, but now have run into a problem where the target machine won't have autocad installed. how do you create an instance of autocad without having autocad installed on the target machine???


thanks.




vegetarian is indian word for lousy hunter.....

AutoCAD VBA...please Help
I want to write a macro or a LISP routine that will draw points for me. I have dxf files and I want to start at the end of the polyline, draw a point there, and then draw a point at every nearest endpoint there after until I hit the end of the polyline.

In the long run I would also like to open a number of dxf files that are saved in the same folder, and complete the macro for each of them. I would like a pop-up window where I would specify the folder, then another that I would specify the bottle number (these are dxf's of bottle geometries), and it would know what files to open. Thanks in advance.

AutoCad AND VB
Ok I have asked this question and I have not been clear. I also left out some important info.

I am trying to get VB to open up AUTOCAD LT and paste some data in a specific Drawing.

AUTOCAD LT does not have a VB editor like some have thought.

I am completely stuck.

Thank you

Dan

AutoCAd And VB
I want to write a script so I can open AutoCad and paste something into a Autocad Drawing.

How do you active a program that isn't Vb or a Vb application?

Thank you

D

Autocad And Vb
Hi all
I'm just trying to open a file in autocad .. I just can't see the file update in acad .. or autocad don't open the drawing
can you tell me why or how can i open the drawing if there's a better way.
On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
MsgBox "Now running " & acadApp.Name & " version " & acadApp.Version

Set acadDocs = acadApp.Documents
Set acadDoc = acadDocs.Add("c:lah.dwg")

AutoCad && VBA?
Anyone has experience with AutoCad & VBA? I have some issues with Xrefs. Let me know. Thanks

AutoCAD And VB
Folks,

I want to manipulate drawings in AutoCAD r2000. I can't find dir boxes or filelist boxes in VBA for AutoCAD.

Does anyone have the syntax to do the following in VB6;

Open a drawing
Close a drawing
Insert a block.

I can get AutoCAD started but having problems from there.

AutoCAD VBA
How can I make program in AutoCAD VBA to calculate demission of all line in current layer?

Autocad
How do i draw a center line in AutoCad using microsoft visual basic ?

Hakim

Autocad
anyone know autocad here?

plz if anyone know
then if he can help me to read a table from autocad
or how can i read anything from a saved autocad file
and thankx alot for helping
goodbye

AutoCAD
Sorry to hog this forum with two questions on one day, but does anyone know if I can find specific elements within an AutoCAD DXF file using VB or VBA?

I was thinking of changing AutoCAD drawings by accessing the DXF file, searching for the handle and changing some values.

Any better ways?

P.S. can't find an AutoCAD forum so posted it here....

AutoCad
Has anyone heard of a control for autocad? This is for VB of course
SeaHag

VBA With Autocad
i need information about vba so that my vb application can communicate with autocad application.

AutoCAD
Firstly what references do I want to use to open AutoCAD as an object? (AutoCAD 2000 LT)

Secondly, what code do I use also?

I am trying to create automated drawing with a few blocks, but am unable even to open the application from code.

rather frustrating.

If anybody could help me out here, I would be very greatful.

Autocad && Jpg
Is it possible to save (convert) autocad drawings to jpg files ???

Thanks , Moyalt.

VB AutoCad
Hi,



I'd like to collect data from AutoCad drawings by using Visual Basic.

What I want is to work out the data from AutoCAD while the drawing(s) itself
must be invisible.

But the following code doesn't work properly: AutoCAD drawings are still
visible

Here is a fragment of my code

Can anyone show me the fout in my code?

Help! Please!





On Error Resume Next

Set acApp = GetObject(, "Autocad.Application")

If Err.Number <> 0 Then

Err.Clear

Set acApp = CreateObject("AutoCad.Application")

End If



If acApp Is Nothing Then

frmDialogBox.NewDataOK = False

MsgBox "The applicatiion 'DialogBox' couldn't start up AutoCAD on
this work station." & vbCrLf & _

"Please contact the ICT HelpDesk (9100) OR try it again.",
vbCritical, frmDialogBox.strTitle & _

", Function CadDataFromFile"

frmDialogBox.CadDoorgaan = False

Exit Function

End If

Err.Clear

acApp.Visible = False





On Error GoTo Err_Control

Set acDrawing = acApp.ActiveDocument.Open(FullFileName)









Help!

Thanks in advance

AutoCad VB
What is an easy way to which your dimstyle. The thing I am trying to do is auto dimenion a part after the user fills out some infomration.

Thanks.

VBA Autocad Help
Hi everyone,
I have recently started to delve into VBA along with Autocad  He is my beginner code that should count blocks in an autocad drawing. However, only the block names are placed in ListBox1 and a 0 count for all of them in ListBox2.
Can anyone see a reason?

Sub CommandButton1_Click()
    Dim i, j, btot As Integer
    Dim bnam As String
    Dim ent As Object
    btot = ThisDrawing.Blocks.Count
    
  For i = 0 To btot - 1
    bnam = ThisDrawing.Blocks.Item(i).Name
    If Not Mid$(bnam, 1, 1) = "*" Then ListBox1.AddItem bnam
    Next i
    
   For i = 0 To ListBox1.ListCount - 1
    bnam = ListBox1.List(i): btot = 0
    For j = 0 To ThisDrawing.ModelSpace.Count - 1
    Set ent = ThisDrawing.ModelSpace.Item(j)
    If ent.EntityType = acBlockReference And ent.Name = banam Then btot = btot + 1
        Next j
        ListBox2.AddItem btot
    Next i
End Sub

Autocad Help
wasted too much time looking for and reading documentation. can someone please help or point me in the right direction? i'm trying to write a simple vb application that will open an autocad drawing and read a spec/dimension off the drawing, but i can't figure it out. thank you in advance.

AutoCad Lin
Hello All Members
can i make a link between the data of the msflexgrid to Autocad to draw it!!
Thanks alot for advice



Egyptian Man

Autocad
how can i take a drawing from autocad to my VB Application

Autocad +vb
Hi,

I want to open a drawing file from a commandbutton click in visual basic.. how to do this..

any source???


P.V.Velan

VBA Autocad
Hi,

I have a developed an appln with ado control, in autocad vba. But i m not sure that the user may contian the ado control.. If not available, what I have to do.. Or how to create setup......



any solution.....


P.V.Velan

AutoCad
Hello
how can i make a link that take the output numbers from my visual basic application to autocad program to draw these data and then make OlE to the drawing data from the autocad to VB application again.i hope u can understand my question!!!!!
thanks for advice


Egyptian Man

AutoCAD Using VBA
I am using customization of AutoCAD using VBA IDE. I want to display a list box for the user to enter text information in it when I click on a specific region on the this drawing model space , then store this text information in the database. The facility to enter the text information should be region specific, for eg if I have a circle and a rectangle on the drawing space , I would want to enter different text information when I click on the drawings separately . That is to say that, i would want to store more data in case of a rectangle then in case of a circle. So I might have different tables to store informations relating to the rectangle and circle. So when I click on the circle, i need a list box where I could enter text information for the circle and store it in the database table for the circle, and likewise for the rectangle.

AutoCad Anyone
Any one out there a VBA for ACAD guru. I am trying to use the command prompt to display informatio from The vba app I am running. I can get the data to the command line prompt, but I cannot get the command line to scroll up when I add the new (I want next Line) data.

It just keeps overwriting the existing line.

I already tried adding "& chr(13)" to the prompt line.

If anyone know a good VBA for ACAD site I would settle for that.

Thanks
LJ

VBA And Autocad Menus
Hi there,
I appologize to all If my thread is in the wrong section.
I'm wondering if there is a way to control menus build in any application running under windows through the use of VBA?
Thanks.

AutoCAD Blocks
Maybe I'm losing my mind but I can't remember how to simply insert a block into an autocad dwg using vba.
A push in the right direction would be greatly appreciated.
Thanks

Using AUTOCAD LT 98 FromVB
Hi All,

I'm trying to run an AutoCAD LT98 application from VB, but all I can do is start it up! using the following:



Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private appval

Private Sub StartCommandPrompt()
Dim r As Long, hWindow&
appval = Shell("C:program filesautocad 2000iacad.exe", vbNormalFocus)
End Sub


I've previous had Auotcad 2000 running from VB by referencing it in VB but cannot reference the AutoCAD LT98 DLL's.

I was think that possibly there was a way of sending messages to the AutoCAD LT98 command line? Any suggestions?

Thanks

Gwyn

AutoCAD Preview
Hello programmers,

Question : Does anybody knows how to show the preview of an AutoCAD drawing with VBA ?

Thanks,
fojek

Autocad VBA && Xrefs
Company uses Autodesk Architectural. I am attempting to write a macro that will update xrefs in a set of drawings after they've been moved (we will be doing massive server/drive reorganization, automating this process would save a ton'o'time). Am VBA person, not Autocad person (opposite of everyone else here), have algorithm for process but unable to figure out xref commands without help files. Found some xref items in object browser but they appear to all be booleans and read onlys, nothing that lets me actually read/change the actual xref pathname. is there an object/property for this in VBA and if so how do I access it?

Thanks anyone who can help!

Autocad And Access
I'm trying to make a database of drawings that were created in Autocad. I have a form setup with a browse button that can be used to navigate to the location of the drawing that is to be added to the database. I then have a button to open autocad, and retrieve the data that I need from autocad. The problem is, I want to return this data back to the form so that the user can edit it, I don't want to just pop it into a Table. Is there any way to reference the currently open form and it's objects?

AutoCAD Blocks With VB6 - Help!!!
I am looking to make a Title Block editor in VB6 (not VBA). I am using AutoCAD Mechanical 2004DX. My dwg files all have a block called "TBLK-D". This block has a various number of attributes associated with it that I wish to edit one at a time.

I am able to open a single drawing. The problem I am having is extracting the information from my autocad block.


Code:
Public AcadApp As AutoCAD.AcadApplication

Private Sub Form_Load()
'Open autocad with specified file.
Dim CurDoc As AcadDocument
Set AcadApp = GetObject(, "AutoCAD.Application")
Set AcadApp = New AutoCAD.AcadApplication
If AcadApp.Visible = False Then AcadApp.Visible = True
Set CurDoc = AcadApp.Documents.Open("C:0_Working999999_01_A")

'Get attributes of a specified block.
Dim OldBlock As AcadBlockReference
Dim AttArray As Variant

Set OldBlock = CurDoc.Blocks.Item("TBLK-D")

End Sub
Everything works wonderful until I get to that last line of code (before End Sub). When I run the program, I get a type mismatch. If I define OldBlock as an AcadBlock, the code works fine. The problem then becomes how can I extract the attributes from my title block without the GetAttributes method? Furthermore, when I open the drawing and look at the properties for TBLK-D in autocad, it is called a Block Reference. So why do I get a type mismatch?

Interface Autocad With VB6
Hi guys,
Is it possible to pass the parameter to Autocad thru VB6 and generate drawing. Or
already developed design in Autocad and is it possible to modify thru VB6.
If you have any information abt it. Plz suggest me.
Regards
kishor Mungelwar

Is AutoCAD Running??
Hi;
I need to find out if AutoCAD is open before iI execute my code, and then the code will open it, if it was not and close it when finished. OR NOT close it if it was already open. I have been trying to get this from the help files but so far this is all I've come up with is
{Set ObjYourAcad = GetObject(, "Autocad.Application")
If Err.Number <> 0 Then AcadWasNotRunning = True
Err.Clear]
and it doesn't work.
Can some one poiint me in the right direction?
Please keep it simple as I do not write programming 24/7.
Or even 8/5
THANKS guys.

Dave. K

Open AutoCAD From VB
I'm having trouble opening AutoCAD from Visual Basic.


Code:
Dim acadApp As AcadApplication
Dim acadDoc As AcadDocument

On Error Resume Next
Set acadApp = GetObject(, "AutoCAD.Application")
If Err Then
Set acadApp = CreateObject("AutoCAD.Application")
If Err Then
MsgBox Err.Description
Exit Sub
End If
End If
MsgBox "Now running " & acadApp.Name & " version " & acadApp.Version

Set acadDoc = acadApp.ActiveDocument
The above code was taken directly out of the AutoCAD ActiveX and VBA Developers guide. It seems it opens AutoCAD in the background but then I receive the following message: This action cannot be completed because the other application is busy.

I've referenced the AutoCAD2000 Type Library in the project.
What am I missing?

Thanks for the help!

Insert Dwg In AutoCAD Using VB
Hallo Friends,

I am new here today...searching a code in internet for following problem.

I have a drawing in AutoCAD2005.

I have written a VisualBasic program finding an Appropriate dwg files in Particular folders coz you people know how our Explorer works..in tree form...clicking clicking and so on till we need our particular folder..so inorder to minimize the time program works using command buttons and lists all the dwgs in Listview.

now i choose a dwg file in Listview ( i mean its a small drawing which should be inserted in opened drawing ). and click the Button INSERT.
now task is this dwg file which is been selected in Listview shold be inserted in opened autocad drawing.

Please can anybody help me how to write this code for this Button Insert..

Private sub insert_click()
.
.
.
.
.
End Sub

it would be very helpfull for me my friends..

i think i have expressed my task in detail..

Thanks - Singoi

Option Same As Autocad
can i create an option same as autocad in vb-application?

Link With Autocad
Hai
My friend working with autocad.he needs some fn,those are not available in autocad.That is he may pass a number of values,we have to do some operation and return the result to auto cad.Is it possible to do those caculation in vb project and return the value back to auto cad.Guide me pls.

Copyright 2005-08 www.BigResource.com, All rights reserved