TheSwamp
Code Red => VB(A) => Topic started by: MustardTiger1989 on March 13, 2018, 12:15:27 PM
-
Hello,
I would like to set a block's dimensions to read an excel table's cell value and update the dimensions (i.e. change the size of the rectangle) based on values entered in an Excel table?
For example, given a rectangle that has dimensions X (Width) by Y (Height) and a table that has the X and Y values given in cells A1 and B1 linked from an excel spreadsheet.
I'm new to writing custom codes within AutoCAD, so any help/direction would be great!
-
You need two programs say getxcel.lsp and lee-macs dynamic properties lisp. Those two have all the tools required.
Also search for shaft.lsp and shaft.dwg over at Cadtutor its a dwg linked to excel its really brilliant change excel cell, dwg updates its like autocad version 9 maybe 20 years ago, it shipped as a sample dwg. Will try to find.
-
Hey,
Thanks for the reply. I was unable to locate the shaft.dwg file. Would you happen to have it?
-
Found a Shaft.lsp @ http://autocad.xarch.at/code/cadence/95-11/ghindex.html
-
Did find it but it has a c# link that is an exe program and its 32bit not 64 so does not run.
You need to do some home work about using lisp the answers are in those two programs.
If I can find time will add to my to do list as an example of dynamic block link to excel.
-
Okay, thanks for all your help!
-
I need a bit more time for fine tuning but this works. It just a test for cells A1 & B1. It shows method rather than code.
;using excel to update rectang dynamic block.
; By Alan H May 2018
; simple rectang with default variables d1 & d2
(if (not GETEXCEL)(Load "getexcel"))
(if (not LM:getdynpropvalue)(load "Dynamic block get-put.lsp"))
(OPENEXCEL "C:\\alan\\Alan.XLSX" "SHEET1" NIL)
(setq blk (vlax-ename->vla-object (car (entsel "Pick block"))))
(setq len (getcell "a1"))
(LM:setdynpropvalue blk "d1" len)
(setq Ht (getcell "b1"))
(LM:setdynpropvalue blk "d2" Ht)