Hello everybody
It is with pleasure that I post this special request in this forum, and I hope that you can help in this matter that surely has already come up to someone.
Copying values from Excel to a Lookup table in AUTOCAD, in a single movement, is something I've been looking for for a long time. I recently discovered two almost perfect LISP routines that allow you to copy Excel to Lookup and vice versa in a single move. The problem is that it only works with Excel 2003 (no longer supported by Microsoft) and Autocad 2010.
I share with you the routines (comments in Russian) and ask if anyone can rewrite them so that they work in the latest versions of Excel and Autocad 2021 and above. I've tested it in Autocad 2021 and I guarantee it doesn't work.
If anyone manages to successfully rewrite the LISP routines, please share, they will surely be a lifeline for many CAD users.
Thank you very much and I pray that someone succeeds.
Good morning to all
To close this subject, my advice to all, is to install a virtual machine in your PC with Autocad 2007. The routines that I shared work just fine with 2007 version. It saves tones of time building the tables in EXCEL and then run EXCEL-LOOKUP.LSP to copy it to LOOKUP parameter in Autocad in a single step.
Nevertheless lets make some pressure so that Autodesk includes this feature in the next versions of Autocad.
It was a pleasure to share with you my not so good experience with this Autodesk problem.
@nuno.ramos5SJR2 wrote:Hi Sea-Haven
We also link Excel tables to dynamic properties of the block, using link tools of Autocad.
Please share how you do this.
Also, I am following this thread with interest.
The Excel has to have the macros / formulas set up so when you put a value into say a excel cell it is checked within Excel, an example is a length and width must be say a min size else Excel puts a No in a cell , Acad reads the cell and looks at it is it Yes or No. Its no fancy lookups or anything all the work is done in Excel.
I asked chatgtp to automate it for me. for me this solution worked.
If you need help to implement it feel free to ask!
Answer from ChatGPT:
Certainly! Below is a Python script that accomplishes the task you've described. This script listens for the Ctrl + D hotkey, retrieves the copied Excel table from the clipboard, and types it into AutoCAD's "Property Lookup Table" using simulated keyboard inputs. It also allows you to interrupt the typing process by pressing the Esc key.
Prerequisites
Python Installation: Ensure you have Python 3.x installed on your system. You can download it from python.org.
Required Python Libraries: You'll need to install the following Python libraries:
You can install these libraries using pip. Open your command prompt or terminal and run:
Note: On some systems, especially Windows, you might need to run the command prompt as an administrator to install these packages.
Running the Script with Administrator Privileges: For the keyboard library to function correctly (especially on Windows), you might need to run the script with administrator rights.
The Python Script
How It Works
Hotkey Registration:
Clipboard Parsing:
Typing Mechanism:
Interruption Handling:
Usage Instructions
Prepare Your Excel Table:
Run the Script:
Save the provided script to a file, e.g., autocad_paste.py.
Open a command prompt or terminal with administrator privileges.
Navigate to the directory containing the script.
Paste into AutoCAD:
Interrupt if Needed:
Additional Notes
Adjusting Typing Speed: If the typing is too fast or too slow for AutoCAD to handle, you can adjust the delay parameter in the keyboard.write function and the time.sleep duration between rows.
Error Handling: The script includes basic error handling to notify you if the clipboard is empty or if there's an issue parsing the clipboard data.
Compatibility: This script is primarily designed for Windows due to the nature of the keyboard library. If you're using a different operating system, you might need to use alternative libraries or methods.
Safety: Be cautious when running scripts that control keyboard input. Ensure that the target application (AutoCAD) is in focus and that you don't have any unintended active inputs that could be disrupted.
Troubleshooting
Script Not Responding to Hotkeys:
Clipboard Parsing Issues:
Typing Interruptions:
Conclusion
This script should help bridge the gap between Excel and AutoCAD by automating the process of transferring data from a clipboard to a "Property Lookup Table" in AutoCAD. Customize and adjust the script as needed to better fit your specific workflow and requirements.
If you encounter any issues or have further questions, feel free to ask!
No need for copy and paste type method if you can read a Excel cell then you can take that value and apply it to a dynamic block property, that includes visibility states.
I would suggest you look at Lee-mac.com dynamic block properties lisp, it has several functions that allow for the manipulation of dynamic block properties. Big hint python version, definitely no paste.
I am not sure that maybe the words "Look up table" is correct maybe I am just reading the last couple of post all wrong.
Can't find what you're looking for? Ask the community or share your knowledge.