Author Topic: Scaling a dynamic block using values in Excel  (Read 6923 times)

0 Members and 1 Guest are viewing this topic.

MustardTiger1989

  • Guest
Scaling a dynamic block using values in Excel
« 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!

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Scaling a dynamic block using values in Excel
« Reply #1 on: March 16, 2018, 03:46:47 AM »
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.
A man who never made a mistake never made anything

MustardTiger1989

  • Guest
Re: Scaling a dynamic block using values in Excel
« Reply #2 on: March 16, 2018, 03:05:17 PM »
Hey,

Thanks for the reply. I was unable to locate the shaft.dwg file. Would you happen to have it?

Yosso

  • Newt
  • Posts: 36
Re: Scaling a dynamic block using values in Excel
« Reply #3 on: April 04, 2018, 11:07:29 AM »

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Scaling a dynamic block using values in Excel
« Reply #4 on: April 04, 2018, 10:49:47 PM »
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.
A man who never made a mistake never made anything

MustardTiger1989

  • Guest
Re: Scaling a dynamic block using values in Excel
« Reply #5 on: April 11, 2018, 10:17:12 AM »
Okay, thanks for all your help!

BIGAL

  • Swamp Rat
  • Posts: 1396
  • 40 + years of using Autocad
Re: Scaling a dynamic block using values in Excel
« Reply #6 on: May 02, 2018, 06:21:38 AM »
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.

Code: [Select]
;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)
A man who never made a mistake never made anything