Author Topic: vlax-get-or-create-object  (Read 330 times)

0 Members and 1 Guest are viewing this topic.

kasmo

  • Newt
  • Posts: 28
vlax-get-or-create-object
« on: March 26, 2024, 11:27:26 AM »
Hi, I'm trying to export some data to an excel file and it seems that this function is not available in acad lt 2024.
Is there a workaround for this?

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: vlax-get-or-create-object
« Reply #1 on: March 26, 2024, 06:49:05 PM »
The LISP API in AutoCAD LT cannot interface with objects outside of the AutoCAD Object Model; an alternative might be to write the data to a CSV file or a tab-delimited text file using the standard plain text I/O functions - both of which may be opened in Excel.

kasmo

  • Newt
  • Posts: 28
Re: vlax-get-or-create-object
« Reply #2 on: March 27, 2024, 07:17:12 AM »
Unfortunately it needs to be an excel file with multiple sheets.
I found a workaround on cadforum.cz for windows clipboard without using vlax-create-object, but I have no idea if that would work for excel and how to change it:
(setq cltext "Hello world!")
(startapp (strcat "mshta.exe vbscript:close(CreateObject(\"WScript.Shell\").Exec(\"clip\").stdIn.WriteLine(\"" cltext "\"))"))
Is anyone familiar with this kind of code?

kozmos

  • Newt
  • Posts: 114
Re: vlax-get-or-create-object
« Reply #3 on: March 28, 2024, 11:00:40 AM »
Hi, I'm trying to export some data to an excel file and it seems that this function is not available in acad lt 2024.
Is there a workaround for this?
You can try using Powershell to create and operate Excel COM objects and save the code in a .PS1 file, it is plain text format, then use Wscript.Shell to run the .PS1
KozMos Inc.

BIGAL

  • Swamp Rat
  • Posts: 1417
  • 40 + years of using Autocad
Re: vlax-get-or-create-object
« Reply #4 on: March 28, 2024, 08:27:33 PM »
"multiple sheets" You could make a csv that is multiple sheets by having the sheet name as a 1st line Seperator, I use a Lee-mac function to split the csv line to a list so if the list has say a certain name as the only entry on a line then its a new work sheet. Ok so how good are your VBA skills ? Use a Excel macro to write the csv rather than "Save as csv". I am sure if you Google that is your home work there will be a macro to make CSV.

hint https://www.excel-easy.com/vba/examples/write-data-to-text-file.html
A man who never made a mistake never made anything