Jump to content

Dimension values to Excel


Butch

Recommended Posts

  • Replies 127
  • Created
  • Last Reply

Top Posters In This Topic

  • fixo

    59

  • Butch

    13

  • flyingjunkie

    11

  • Fordy

    9

Top Posters In This Topic

Posted Images

I tried changing dimesion style (decimal separator) from comma to point, but it doesnt work also :-(

 

How about this:

   (vlax-put-property xcel  "NumberFormat"
     (vlax-make-variant "0,00" ;<-- change on comma here
     )

 

~'J'~

Link to comment
Share on other sites

Fixo, its working! :shock:

I think the problem was that we had different options in Excel for decimal commas and periods.

Look at the pictures!

This are youur settings, right?

I made them like that and it works fine now :-)

All this time my settings in Excel where other way around!

Its ok now :-)

 

Thanx a lot! :D

 

Now we must have a lisp for measuring area of an closed polyline. Thats a must!

a1.jpg

Link to comment
Share on other sites

Fixo, its working! :shock:

I think the problem was that we had different options in Excel for decimal commas and periods.

Look at the pictures!

This are youur settings, right?

I made them like that and it works fine now :-)

All this time my settings in Excel where other way around!

Its ok now :-)

 

Thanx a lot! :D

 

Now we must have a lisp for measuring area of an closed polyline. Thats a must!

 

Main Got!

 

It's so easy

 

Shame on my head :)

 

Cheers :)

 

~'J'~

Link to comment
Share on other sites

Oleg it is working but rounding to 1/4 instead of 1/16. Where I can change this option?

 

Hi Marek

 

Not sure about imperials, you know we use

just metric in my village :)

Guess you need to change this line:

(rtos (cdr row_data) 4 2)

on

(rtos (cdr row_data) 4 3)'

or maybe on this one:

(rtos (cdr row_data) 3 3)'

 

play around yourself :)

 

~'J'~

Link to comment
Share on other sites

  • 4 weeks later...

Any body can help me to get the area of any object directl to excel sheet? It means, How to get the Object area directly to excel sheet? Is there any Lisp program for this? If any body has,please help me. Thank you.

Link to comment
Share on other sites

  • 4 months later...

Sorry to bring this thread back from the dead but I had a few questions that are still unanswered after the 4 pages of detailed posts here which I am very thankful for.

 

My knowledge in lisp > Next to nothing. I can load it and run it. I am fluent in vba but lisp is just a total doozy for some reason.

 

Is there a way I can run fixo's program but instead of it exporting to it's own excel file(Importdims.xls) , can it ask me for the excel file to export to. I need it to export to Cell B2, C2 always in the file that I need which is already existing and I have some forumlas and template like thing setup. The reason is that I have an autocad file with a simple L shaped (always) object (side view, thickness of .25") and I want to export the L and W into my choice of Excel file. Then I will have that Excel file perform pre-written formulas upon those extracted dimensions and create a few more numbers which will be thrown back into the autocad file as an OLE object.

 

So my autocad file should have an OLE data table from Excel like this:

 

Var L W

001 10 5

002 10.25 5.25 ]

003 10.50 5.50 ]

004 10.75 5.75 ]

Link to comment
Share on other sites

Sorry to bring this thread back from the dead but I had a few questions that are still unanswered after the 4 pages of detailed posts here which I am very thankful for.

 

My knowledge in lisp > Next to nothing. I can load it and run it. I am fluent in vba but lisp is just a total doozy for some reason.

 

Is there a way I can run fixo's program but instead of it exporting to it's own excel file(Importdims.xls) , can it ask me for the excel file to export to. I need it to export to Cell B2, C2 always in the file that I need which is already existing and I have some forumlas and template like thing setup. The reason is that I have an autocad file with a simple L shaped (always) object (side view, thickness of .25") and I want to export the L and W into my choice of Excel file. Then I will have that Excel file perform pre-written formulas upon those extracted dimensions and create a few more numbers which will be thrown back into the autocad file as an OLE object.

 

So my autocad file should have an OLE data table from Excel like this:

 

Var L W

001 10 5

002 10.25 5.25 ]

003 10.50 5.50 ]

004 10.75 5.75 ]

 

 

Sorry, not clearly enough for my

Confirm, please:

- you need VBA code only

- you need to run it from AutoCAD

- you want select in AutoCAD 2 dimensions and

then always send them into B2, C2 cells in the tab "Sheet1"

- all of the cell values need to be cleaned before

- cell A2 values is still always equal to 001

- you want select .xls file from FileDialog window

instead of using the default file name

- then you will recalculte other cells in Excel file manually

and will reexport Excel table back (manually too)

 

 

Think would be better yet to post an example of Excel file

and sample drawing and I could be start working something out

And also right now I'm kinda busy a little, so I can't to help

you quickly

 

I use MS Office 2007/ Acad 2008 only (both english version)

 

~'J'~

Link to comment
Share on other sites

-It can be VBA or LISP, I can run either one. I have run quite a few lisps today and yesterday trying to figure this problem out so I'm familiar with the process atleast.

-Yes, I think it has to be run from AutoCAD.....maybe it's better run from Excel...not too sure .....the sample will clarify everything.

-Yes, directly to Cell B2 and C2....B3, C3, B4,C4 have formulas that work based on B2 and C2.

-Cell A2 is always equal to 001....have a look at the sample and the OLE Excel object table I have inserted in there.

-I would like to select the excel file from the dialog window but I would basically like it to go into the excel file that is giving the OLE table in the Sample file.

 

Please take your time, I don't want to rush you or anyone. It's just that there are hundreds of these files and by making these templates, I can really make my designs a lot faster where I only have to change the dimension and everything else happens automatically.

 

Thanks again.

Sample.dwg

Link to comment
Share on other sites

-It can be VBA or LISP, I can run either one. I have run quite a few lisps today and yesterday trying to figure this problem out so I'm familiar with the process atleast.

-Yes, I think it has to be run from AutoCAD.....maybe it's better run from Excel...not too sure .....the sample will clarify everything.

-Yes, directly to Cell B2 and C2....B3, C3, B4,C4 have formulas that work based on B2 and C2.

-Cell A2 is always equal to 001....have a look at the sample and the OLE Excel object table I have inserted in there.

-I would like to select the excel file from the dialog window but I would basically like it to go into the excel file that is giving the OLE table in the Sample file.

 

Please take your time, I don't want to rush you or anyone. It's just that there are hundreds of these files and by making these templates, I can really make my designs a lot faster where I only have to change the dimension and everything else happens automatically.

 

Thanks again.

 

Grabbed from other authors

Change sheet name to suit

'' require reference to Microsoft Excel XX.X Object Library
Option Explicit
Public Declare Function GetOpenFileName Lib "comdlg32.dll" _
Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Long
Public Type OPENFILENAME
 lStructSize As Long
 hwndOwner As Long
 hInstance As Long
 lpstrFilter As String
 lpstrCustomFilter As String
 nMaxCustFilter As Long
 nFilterIndex As Long
 lpstrFile As String
 nMaxFile As Long
 lpstrFileTitle As String
 nMaxFileTitle As Long
 lpstrInitialDir As String
 lpstrTitle As String
 flags As Long
 nFileOffset As Integer
 nFileExtension As Integer
 lpstrDefExt As String
 lCustData As Long
 lpfnHook As Long
 lpTemplateName As String
End Type
'@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@
' Display and use the File open dialog
'@~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~@
Public Function ShowOpen() As String
 Dim strTemp As String
 Dim VertName As OPENFILENAME
 VertName.lStructSize = Len(VertName)
 VertName.hwndOwner = ThisDrawing.HWND
 VertName.lpstrFilter = "All Excel Files (*.xls)" + Chr$(0) + _
                        "*.xls" + Chr$(0) + " | " + "Excel Files (*.xlsx)" + Chr$(0) + _
                        "*.xlsx"
 VertName.lpstrFile = Space$(254)
 VertName.nMaxFile = 255
 VertName.lpstrFileTitle = Space$(254)
 VertName.nMaxFileTitle = 255
 VertName.lpstrInitialDir = CurDir
 VertName.lpstrTitle = "Select Excel File"
 VertName.flags = 0
 If GetOpenFileName(VertName) Then
   strTemp = (Trim(VertName.lpstrFile))
   ShowOpen = Mid(strTemp, 1, Len(strTemp) - 1)
 End If
End Function
'' Modified 10/8/03 to remove early binding and
'' include late binding. Now should work with
'' any version Excel

Function IsExcelRunning() As Boolean
   Dim objXL As Object
   On Error Resume Next
   Set objXL = GetObject(, "Excel.Application")
   IsExcelRunning = (Err.Number = 0)
   Set objXL = Nothing
   Err.Clear
End Function
'' based on macros written by Jeff Mishler
'Changed the way Excel is loaded per suggestion by
'Randall Rath - [url]http://www.vbdesign.net/[/url]
'which also added the "Function IsExcelRunning"
Public Sub ExportDims()
Dim oEnt As AcadEntity
Dim oDim As AcadDimRotated
Dim oOle As AcadOle
Dim mea1 As Double
Dim mea2 As Double
Dim pickPt As Variant

ThisDrawing.Utility.GetEntity oEnt, pickPt, vbCrLf & "Select length dimension >> "
   If Not TypeOf oEnt Is AcadDimension Then Exit Sub
   Set oDim = oEnt
   mea1 = oDim.Measurement

    ThisDrawing.Utility.GetEntity oEnt, pickPt, vbCrLf & "Select width dimension >> "
   If Not TypeOf oEnt Is AcadDimension Then Exit Sub
   Set oDim = oEnt
   mea2 = oDim.Measurement

   ThisDrawing.Utility.GetEntity oEnt, pickPt, vbCrLf & "Select embedded table >> "
   If Not TypeOf oEnt Is AcadOle Then Exit Sub
   Set oOle = oEnt

   Dim xlFileName As String

   '***Begin code from Randall Rath******
   Dim oXL As Object
   Dim blnXLRunning As Boolean
   blnXLRunning = IsExcelRunning()
   If blnXLRunning Then
       Set oXL = GetObject(, "Excel.Application")
   Else
       Set oXL = CreateObject("Excel.Application")
       oXL.Visible = False
       oXL.UserControl = False
       oXL.DisplayAlerts = False
   End If
   '***End code from Randall Rath******

   Dim oWb As Object
   Dim oWs As Object
   xlFileName = ShowOpen()
   Set oWb = oXL.Workbooks.Open(xlFileName)
   If oWb Is Nothing Then
       MsgBox "The Excel file " & xlFileName & " not found" & _
              "Try again."
       GoTo Exit_Here
   End If
   Set oWs = oWb.Worksheets("Sheet1")
   oWs.Activate

   ' write data to Excel

   oWs.Columns(1).NumberFormat = "@"
   oWs.Columns(2).NumberFormat = "0.00"
   oWs.Columns(3).NumberFormat = "0.00"
   oWs.Cells(2, 1) = "-001"
   oWs.Cells(2, 2) = mea1
   oWs.Cells(2, 3) = mea2

   oWs.Columns.AutoFit
Exit_Here:
   Set oWs = Nothing
   oWb.Save: oWb.Close
   Set oWb = Nothing
   oXL.Quit
   Set oXL = Nothing
DoEvents
   MsgBox "Done"

End Sub

 

~'J'~

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...