how can i export date from autocad (dwg) to excel...help me out guys
how can i export date from autocad (dwg) to excel...help me out guys
Moved so you will get more AutoCAD oriented help.
Is the date mult-line text? Give a few more details please. Also what version of Cad and Excel are you using?
Steve
"Nearly all men can stand adversity, but if you want to test a man's character, give him power."
-Abraham Lincoln
i want to export data like dimensions,layername,text to excel..we are using acutocad 2004 and above and excel 2003 and above.
Originally Posted by lucas
Hi shamsam1,
Are you in Autocad or are you in Excel?
I would prefer Autocad myself, it is easier to manipulate Excel from other apps than it is to manipulate Autocad. IMHO
Is the text MText? do you want both the text and mtext? I assume the dimension text is. How do you determine what to export to Excel? Do you export all of it or ....
After you aquire all of this text, layers, and dimensions where do you want to put them and in what type of format?
What are you trying to do?
The more information you can give the better the information you recieve.
i would like to code from vb.6.then open autocad drawing then export all data to excel.
i need a simple program which export all data of dwg to excel.
regards
sam
Originally Posted by Tommy
at last i am able to export block attributed details from dwg to excel using vb.6 and autocad2000
if intresed i can share vb.6 code.
No where in any of your posts have you requested attributes. Just all data.
This is a VBA site not a VB6 site.
But yes I would love to see the code.
well in 2 to 3 day i wll be posting the required code.
Originally Posted by Tommy
is kind of a contradiction.
If you are looking for the very basic properties, which are common to *every* entity, you can use the AcadEntity object.. but short of that, you have to write code specific for every type of entity. Not 'simple' code.
wel i am able to read all block attributes in drawring.using vb.6
but i am more intrested in reading all dimesions value. just got stuck here..
Look for mtext if the dimensions are not associative. Hopefully the dimension text is at least on a "dimension" layer, otherwise the search will be long and hard. Are the drawings in metric or imperial? The Imperial dimensions will be easier to find, otherwise hopefully there will be a designation as in cm/mm. Are you suing a selection set to find the information? Are you just opening the drawing and searching?
dimensison are mtext in my project. also there is seperate layer for dimension .drawminsg are in metric
how to extact all mtext values from dwg.
some sample od vb or vba code will help
Originally Posted by Tommy
Here is a knowledge base I wrote for dimensions
http://vbaexpress.com/kb/getarticle.php?kb_id=862
HTH
I am using volo view express in my vb6 application. Can any one give me code for zoom window using volo view express in vb6.I have code for zoom extends. Please help me.Its urgent
From this point on you will need to post some code to prove to me you are actually know what you are trying to do. You have gone from acad to voloview. from all things in acad to zoom window in volo view. I think you are just ..............
Otherwise search the net.
here is code to extract block attributes to actocad using vb.6..
but i need to code to extract the dimesions value or mtext without opening outocad..
add reference for autocad and excel
[vba]
Sub Extract()
Row = 2
col = 1
'Form1.Cls
Dim sheet As Object
Dim shapes As Object
Dim elem As Object
Dim excel As Object
Dim Max As Integer
Dim Min As Integer
Dim NoOfIndices As Integer
Dim excelSheet As Object
Dim RowNum As Integer
Dim Array1 As Variant
Dim Count As Integer
Dim Teller As Integer
Dim Teller1 As Integer
Dim str() As String
Screen.MousePointer = vbHourglass
For i = 0 To List2.ListCount - 1
Text6.Text = i
Text7.Text = List2.List(i)
procOpenDrawing
Set Doc = acad.ActiveDocument
Set mspace = Doc.ModelSpace
RowNum = 1
Dim Header As Boolean
Header = False
Teller = 0
Teller1 = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
'Text5.Text = ""
List1.Clear
For Each elem In mspace
With elem
If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
If .HasAttributes Then
Teller = Teller + 1
Array1 = .GetAttributes
' Text1.Text = Text1.Text & vbNewLine & " ****** Read the TAGS ***** " & vbNewLine
' For Count = LBound(Array1) To UBound(Array1)
' If Header = False Then
' If StrComp(Array1(Count).EntityName, "AcDbBlockReference", 1) = 0 Then
' Text1.Text = Text1.Text & Array1(Count).TagString & vbNewLine
' End If
' End If
' Debug.Print
' Next Count
RowNum = RowNum + 1
' Text1.Text = Text1.Text & vbNewLine & " ****** Read the VALUE ***** " & vbNewLine
str1 = ""
For Count = LBound(Array1) To UBound(Array1)
Teller1 = Teller1 + 1
str1 = Array1(Count).tagstring
If str1 = "Materiale" Or str1 = UCase("Materiale") Then
Text2.Text = Text2.Text & Array1(Count).textstring
ElseIf str1 = "BesKrivelse1" Or str1 = UCase("BesKrivelse1") Or _
str1 = "BesKrivelse2" Or str1 = UCase("BesKrivelse2") Or _
str1 = "BesKrivelse3" Or str1 = UCase("BesKrivelse3") Then
Text3.Text = Array1(Count).textstring
If Val(Text3.Text) Then
str = Split(Text3.Text, "x")
For intLoop1 = LBound(str) To UBound(str)
List1.AddItem (Val(str(intLoop1)))
Next intLoop1
End If
ElseIf str1 = "Tegningsnr" Or str1 = UCase("Tegningsnr") Then
Text4.Text = Array1(Count).textstring
ElseIf str1 = "Varenr" Or str1 = UCase("Varenr") Then
Text1.Text = Array1(Count).textstring
End If
Next Count
Debug.Print
Header = True
End If
End If
End With
Next elem
' myexcel.ActiveSheet.Cells(row, col).HorizontalAlignment = xlCenter
'myexcel.ActiveSheet.Cells(row, col).Font.Bold = True
'myexcel.Visible = True
myexcel.ActiveSheet.Cells(Row, col) = Text1.Text
myexcel.ActiveSheet.Cells(Row, col + 1) = Text2.Text
myexcel.ActiveSheet.Cells(Row, col + 3) = List1.List(0)
myexcel.ActiveSheet.Cells(Row, col + 4) = List1.List(1)
myexcel.ActiveSheet.Cells(Row, col + 5) = List1.List(2)
myexcel.ActiveSheet.Cells(Row, col + 6) = Text4.Text
Row = Row + 1
col = 1
Next i
NumberOfAttributes = RowNum - 1
If NumberOfAttributes > 0 Then
Else
MsgBox "No attributes found in the current drawing"
End If
Set acad = Nothing
' Me.SetFocus
Screen.MousePointer = vbNormal
End Sub
[/vba]
EDIT : Added VBA tags Tommy
here is code to extract block attributes to actocad using vb.6..
but i need to code to extract the dimesions value or mtext without opening outocad..
add reference for autocad and excel
[vba]
Sub Extract()
Row = 2
col = 1
'Form1.Cls
Dim sheet As Object
Dim shapes As Object
Dim elem As Object
Dim excel As Object
Dim Max As Integer
Dim Min As Integer
Dim NoOfIndices As Integer
Dim excelSheet As Object
Dim RowNum As Integer
Dim Array1 As Variant
Dim Count As Integer
Dim Teller As Integer
Dim Teller1 As Integer
Dim str() As String
Screen.MousePointer = vbHourglass
For i = 0 To List2.ListCount - 1
Text6.Text = i
Text7.Text = List2.List(i)
procOpenDrawing
Set Doc = acad.ActiveDocument
Set mspace = Doc.ModelSpace
RowNum = 1
Dim Header As Boolean
Header = False
Teller = 0
Teller1 = 0
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text4.Text = ""
'Text5.Text = ""
List1.Clear
For Each elem In mspace
With elem
If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
If .HasAttributes Then
Teller = Teller + 1
Array1 = .GetAttributes
' Text1.Text = Text1.Text & vbNewLine & " ****** Read the TAGS ***** " & vbNewLine
' For Count = LBound(Array1) To UBound(Array1)
' If Header = False Then
' If StrComp(Array1(Count).EntityName, "AcDbBlockReference", 1) = 0 Then
' Text1.Text = Text1.Text & Array1(Count).TagString & vbNewLine
' End If
' End If
' Debug.Print
' Next Count
RowNum = RowNum + 1
' Text1.Text = Text1.Text & vbNewLine & " ****** Read the VALUE ***** " & vbNewLine
str1 = ""
For Count = LBound(Array1) To UBound(Array1)
Teller1 = Teller1 + 1
str1 = Array1(Count).tagstring
If str1 = "Materiale" Or str1 = UCase("Materiale") Then
Text2.Text = Text2.Text & Array1(Count).textstring
ElseIf str1 = "BesKrivelse1" Or str1 = UCase("BesKrivelse1") Or _
str1 = "BesKrivelse2" Or str1 = UCase("BesKrivelse2") Or _
str1 = "BesKrivelse3" Or _
str1 = UCase("BesKrivelse3") Then
Text3.Text = Array1(Count).textstring
If Val(Text3.Text) Then
str = Split(Text3.Text, "x")
For intLoop1 = LBound(str) To UBound(str)
List1.AddItem (Val(str(intLoop1)))
Next intLoop1
End If
ElseIf str1 = "Tegningsnr" Or str1 = UCase("Tegningsnr") Then
Text4.Text = Array1(Count).textstring
ElseIf str1 = "Varenr" Or str1 = UCase("Varenr") Then
Text1.Text = Array1(Count).textstring
End If
Next Count
Debug.Print
Header = True
End If
End If
End With
Next elem
' myexcel.ActiveSheet.Cells(row, col).HorizontalAlignment = xlCenter
'myexcel.ActiveSheet.Cells(row, col).Font.Bold = True
'myexcel.Visible = True
myexcel.ActiveSheet.Cells(Row, col) = Text1.Text
myexcel.ActiveSheet.Cells(Row, col + 1) = Text2.Text
myexcel.ActiveSheet.Cells(Row, col + 3) = List1.List(0)
myexcel.ActiveSheet.Cells(Row, col + 4) = List1.List(1)
myexcel.ActiveSheet.Cells(Row, col + 5) = List1.List(2)
myexcel.ActiveSheet.Cells(Row, col + 6) = Text4.Text
Row = Row + 1
col = 1
Next i
NumberOfAttributes = RowNum - 1
If NumberOfAttributes > 0 Then
Else
MsgBox "No attributes found in the current drawing"
End If
Set acad = Nothing
' Me.SetFocus
Screen.MousePointer = vbNormal
End Sub
[/vba]
EDIT: Added VBA tags Tommy
in my second project i am opening dwg drawing without using autocad.
1)i am using volvo viewer
in this i adotn have code or zoom extent
or
2) with using ddvue.ocx
http://www.opendwg.org/home
This is the only thing that I know of to do what you are wanting to do without autocad. Now if you are wanting to do something with a dxf file I can help on that, somewhat.
thanks for the assistance..
i have already finished my second project with using ddvue.ocx
i still dotnt have code to extract only dimesnions values from dwg drawings.and export to excel.
i want to extract dimesnions without opening autocad drawings.i have around 5000 dwg drawings.
please help me with a goood vb.6 or macro.my knowlede with lisp is nill...