Jump to content

Generate table with some data from excel


jhonnying

Recommended Posts

Hello to everyone! I'm from Romania and i'm new in this forum. I have found very interesting this .lsp programs and i wonder if you can help with this kind of problem.

For example, if i have in excel 2 columns containing values for altitude of points in a column and distance beetween those points in the other column, i want to generate a table and a drawing like in the attachment, that contains automatic counting of points, the altitude, the partial distance and the cumulative distance. It will be great if the automatic counting of points starts with a value entered from the keyboard. Excuse my english please!

Thanks, i home you understand what i mean!

Good luck!

PROFILE.jpg

Link to comment
Share on other sites

  • Replies 25
  • Created
  • Last Reply

Top Posters In This Topic

  • jhonnying

    9

  • FELIXJM

    6

  • fixo

    5

  • jvillarreal

    3

Top Posters In This Topic

Posted Images

hello! what kind of detail would you like?? perhaps i've confuzed you with the automatic counting of points. The automatic counting of points i can generated myself in excel. I attached an excel data file to be more specific. Sinceraly, it takes a lot of days to complete this kind of drawing (table) if i have for example 200 points, that's why i started searching the internet for some help. I hope you understand my issue! thanks a lot for posting me back and for showing interesting for my problem!

excel data.xls

Link to comment
Share on other sites

  • 2 weeks later...

jhonnying,

 

It's definitely possible to generate your table/profile drawing through lisp but, in my opinion, someone would have to be pretty generous with their time to provide the routine (for free) as it would be tailored to your needs and likely nothing more than an example/learning reference to anyone else.

 

Maybe you can go to lee-mac.com and hire him to write it for you?

If your current process typically takes days to complete as you say, I'm sure the program will pay itself off with its first use.

Edited by jvillarreal
Link to comment
Share on other sites

The following prototype program for the file posted.

 

;;;
(vl-load-com)
(setq #arq      (getfiled "Selecione o arquivo" "" "xls" 2))
(setq celulas nil)
(setq excel-app (vlax-create-object "excel.application"))
(setq wb-collection (vlax-get excel-app "workbooks"))
(setq arq       (vlax-invoke-method wb-collection  "Open"  #arq))
(setq pastas    (vlax-get arq    "sheets"))
(setq pasta1    (vlax-get-property pastas "item" 1))
(setq celulas   (vlax-get pasta1 "cells"))
(COMMAND "_PLINE")
(SETQ NL 1)
(REPEAT 7
;Pega os dados armazenados na planila atual na linha NL e coluna 1=A,2=B,3=C,4=D,5=E
(setq  V-A  (vlax-variant-value (vlax-variant-change-type (vlax-get-property celulas "item"  NL  1) vlax-vbstring)))
(setq  V-B  (vlax-variant-value (vlax-variant-change-type (vlax-get-property celulas "item"  NL  2) vlax-vbstring)))
(setq  V-C  (vlax-variant-value (vlax-variant-change-type (vlax-get-property celulas "item"  NL  3) vlax-vbstring)))
(setq  V-D  (vlax-variant-value (vlax-variant-change-type (vlax-get-property celulas "item"  NL  4) vlax-vbstring)))
(setq  V-E  (vlax-variant-value (vlax-variant-change-type (vlax-get-property celulas "item"  NL  5) vlax-vbstring)))
(PRINT (STRCAT "A=" V-A "  B=" V-B "  C=" V-C "  D=" V-D "  E=" V-E))
(SETQ PX (ATOF (VL-STRING-SUBST "." "," V-E)))
(SETQ PY (ATOF (VL-STRING-SUBST "." "," V-B)))
(IF (AND (> PX 0) (> PY 0))
    (COMMAND (LIST PX PY))
)
(SETQ NL (+ NL 1))
)
(COMMAND "")
(COMMAND "_ZOOM" "_E")
(vlax-invoke-method wb-collection "Close")
(vlax-invoke-method excel-app     "Quit" )
(PRINC)
;;;

 

OK.

Link to comment
Share on other sites

Save the program in a file with the LSP

In AutoCAD go to the top menu TOOL -> AutoLISP -> LOAD APLICATION and select the file, then click LOAD.

 

You do not need help, but of a consulting service.

 

 

 

 

OK?

Link to comment
Share on other sites

I know this procedure, but i don't know the command from the keyboard, usually i use the 'name' from the sintagm: defun c:'name', but in the program above i don't see that. What is the command i'll entry from the keyboard? Thanks a lot for your promptitude!

Link to comment
Share on other sites

I know this procedure, but i don't know the command from the keyboard, usually i use the 'name' from the sintagm: defun c:'name', but in the program above i don't see that. What is the command i'll entry from the keyboard? Thanks a lot for your promptitude!

 

Save the file as something.lsp using Notepad (not the .txt default extension)

 

Load it in AutoCad, Tools => AutoLisp => Load Application

 

When you load it, the script will run and ask you to select the Excel file.

Link to comment
Share on other sites

The program that was posted a small example of how to use Excel to access the Autolisp, if not program or do not have time for this should then pay for the service ready for a specific program.

 

OK.

Link to comment
Share on other sites

I'm sorry guys but the program doesn't work properly. It only draws a polyline...i attached a dwg file and a new excel sheet with other values to give a more concludent example. It is written in romanian. Thanks! Good luck!

 

I can commence working on the programming task, that you have described, immediately.

Upon completion of the program, may I ask that if you are satisfied with the final product,

that you donate $5 to the forum in order to offset its running costs so other people

around the world can continue to benefit from it.

 

~'J'~

Link to comment
Share on other sites

Oleg (FIXED) complicated because you both the selection of the spreadsheet and not simply asked the User to select the XLS file?

OK?

Agreed, it's just to show using Excel methods in Autolisp,

perhaps it will be reasonable for other forum members :)

Regards,

 

~'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...