Jump to content

Recommended Posts

Posted
On 11/26/2009 at 10:30 AM, fixo said:

 

Thanks,

Here is the first one from two routines

This will allow you import all title blocks

on all layouts entire the selected folder

You can change Excel file name inside the code

as you need it

 

~'J'~

btex.lsp 7.36 kB · 84 downloads

Hi fixo, I would like to know if you can change your "btex.lsp" file to open LibreOffice Calc instead of Microsoft Office Excel as I don't have that program.
Or at least have it export the information to a .csv file so that it can be opened with any application other than Excel.

Thank you very much

Posted
On 11/27/2009 at 9:10 PM, fixo said:

 

Here is the second one

I tested it many times on my A2008

Working good too

Keep in mind you can fill Excel file before

with help of btex.lsp I sent above

 

~'J'~

btim.LSP 4.87 kB · 104 downloads

Could you do the same with this file "btim.lsp" to import it from LibreOffice Calc?

Thank you very much

Posted

Are you using AutoCAD 2021 LT?

 

Unfortunately, fixo is no longer around.

 

Maybe somebody else can find you a solution, though AFAIK, AutoCAD doesn't work well with LibreOffice.

 

Maybe there are improvements or alternatives.

 

 

Posted
9 minutes ago, SLW210 said:

Are you using AutoCAD 2021 LT?

 

Unfortunately, fixo is no longer around.

 

Maybe somebody else can find you a solution, though AFAIK, AutoCAD doesn't work well with LibreOffice.

 

Maybe there are improvements or alternatives.

 

 

Hi SLW210, sorry to hear that about fixo....

I use AutoCAD LT but I have access to AutoCAD .

That's why I was saying if someone could modify the files to work with .txt or .csv, so you don't rely on Excel exclusively.

I hope someone can do it or if you have another LISP that does not depend on Excel.

Thank you very much

Posted (edited)

Fixo was great with Excel stuff and have a few of his brilliant programs. 

 

Just google "export attributes to csv autocad lisp" you will be swamped with code. 

 

Excel, Word and Access use a Get Application function, (setq myxl (vlax-get-or-create-object "excel.Application")) if libreoffice supported a similar approach then something could be done.

 

Part 2 Excel can talk to CAD using same approach in a Excel macro you open an application.

Set acadApp = GetObject(, "BricsCadApp.AcadApplication")

Set acadApp = GetObject(, "AutoCAD.Application")

 

So if you can find the application name for Libreoffice then maybe can provide multiple functions. have you tried contacting Libreoffice  for help ?

Edited by BIGAL
Posted
7 hours ago, BIGAL said:

Fixo was great with Excel stuff and have a few of his brilliant programs. 

 

Just google "export attributes to csv autocad lisp" you will be swamped with code. 

 

Excel, Word and Access use a Get Application function, (setq myxl (vlax-get-or-create-object "excel.Application")) if libreoffice supported a similar approach then something could be done.

 

Part 2 Excel can talk to CAD using same approach in a Excel macro you open an application.

Set acadApp = GetObject(, "BricsCadApp.AcadApplication")

Set acadApp = GetObject(, "AutoCAD.Application")

 

So if you can find the application name for Libreoffice then maybe can provide multiple functions. have you tried contacting Libreoffice  for help ?

Hi BIGAL, I will do the search you mentioned to see what I find....
I have not looked for help in LibreOffice because I don't know anything about programming.

Thanks for your help

Posted

Hi SLW210, what I want to do is exactly what fixo LISPs do:
1- I have many DWG files with a block with attributes.
2 - I want to export all the attributes of that block to a CSV or TXT file so I can modify their values.
3 - I want to be able to import this CSV or TXT file to change the attributes I have previously modified.

I don't know if I have explained myself well, sorry for my English

Thank you very much

Posted

That's new for me RonJon, I'd usually use MacAttExt - but that is coded to export to and open excel, I can guess how to modify it but not sure I'd get it right.

 

 

 

Truski, how many files are you wanting to extract the title block details from? Will ronjons solution work, slower than a batch LISP but it works, or with a lot of files you'll want something quicker.

Posted

Hi ronjonp, I know those commands but you have to open and close all the DWG one by one, I would like something more automatic that the program would do it by itself.

 

Hi Steven P, it's all the files of a whole project that can be 200 or 300 DWG and doing that process file by file is quite slow...

 

The 2 LISP of fixo (BTEX.LSP and BTIM.LSP), work very well, but opening Excel I don't have it. That's why I was saying if you could modify your LISP to export the data to a CSV or TXT file and then import that modified file to update the attributes in the block, it would help me a lot...

 

Any ideas? 

 

Thank you very much

Posted

So doing the internet search for you....

 

Does this extract all the attributes and print them in the command line? Get it working for 1 file and writing to CSV and as a batch is a lot easier. Link to CADTutor thread is in the code. Slight edit to the code, and you enter the block name where indicated.

 

(defun c:sk (/ dxf ent result header) ;;https://www.cadtutor.net/forum/topic/19285-lisp-for-attribute-extract-from-block/;; Lee Mac
  (defun dxf (code ent) (cdr (assoc code (entget ent))))
  (setq header (list))
  (setq result (list))
  (setq blkname "--Your Block Name Here--")
  (if (ssget "_X" (list (cons 2 blkname)))
    (if (and (setq ent (ssname (ssget "_X" (list (cons 2 blkname))) 0))
        (eq "INSERT" (dxf 0 ent))
        (= 1 (dxf 66 ent))
      ) ; end and
      (while (not (eq "SEQEND" (dxf 0 (setq ent (entnext ent)))))
        (setq header (append header (list (dxf 2 ent))))
        (setq result (append result (list (dxf 1 ent))))
      ) ; end while
    ) ; end if and
    (princ "Block doesn't exist")
  ) ; end if ssget
  result
)

 

 

BigAl had this code last year:

 

(defun c:test ( / ) ;;https://www.cadtutor.net/forum/topic/78679-lisp-for-block-attributes-extraction-to-excel-autocad-lt-2024/
(setq obj (vlax-ename->vla-object (car  (entsel "Pick block obj"))))
(setq atts (vlax-invoke obj 'Getattributes))
(foreach att atts
(setq txt (vlax-get att 'Textstring))
(princ (strcat "\n" txt))
)
(princ)
)

 

(not sure, this one only shows attributes with a value? Might be wrong)

 

I could go on.....

 

 

With luck one of these will show all the attribute values in the command line. Then we can look at putting the data into a CSV file.... again a lot of results online to look at.

 

Maybe you could find out a couple of examples and ask how to combine the 2 LISPs into 1 funbction?

 

Posted (edited)

Your friend with CSV file and multiple dwg's is (open fname "A") the "A" is append to a file.

 

Ok multi dwgs without opening not sure if Acoreconsole supports write to file, but would be very fast. Possibly have not tried will write to excel if supports get.application.

 

OBDBX may the other way similar to Acoreconsole where you look inside another dwg.

 

We could start with Fixo code but like Steven P would use something I already have, Ok a couple of rules are we finding blocks in Model space only  or layouts or both ? Multiple block names ? Names must be known. Do you want names and sorted and counted ? I do up to 5 attributes deep with counts.

 

AGAIN need a dwg and a excel please of desired output. 

 

Also did you try contacting Libreoffice in their interest to support an answer.

 

 

Edited by BIGAL
Posted

Hi BIGAL, you would have to search only in the layouts of all the DWG in the folder and subfolders.

 

It would only be to search for a specific block with attributes.

 

On Monday from the office I will send DWG and XLS as an example.

 

Thank you very much 

Posted

Titulos_Planos.xls

 

Good morning, I am sending a DWG with the block with attributes for the title, plan number and XLS as an example.

 

Thank you very much

Test.dwg

Posted (edited)

Try this 2 parts the lisp and the script. Run the script once you add your dwg names.

Lsp

(defun c:DCAJA3 ( / fo lays lay obj atts att x str)
(setq fo (Open "d:\\acadtemp\\D-CAJ-A3.csv" "A"))
(setq lays (layoutlist))
(foreach lay lays
  (setvar 'ctab lay)
  (command "pspace")
  (setq str (strcat (getvar 'dwgprefix)(getvar 'dwgname)"," lay))
  (setq ss (ssget "X" '((0 . "INSERT")(cons 2  "D-CAJ-A3")(cons 410 lay))))
  (if (= ss nil)
    (princ "no title blocks")
    (progn
    (setq obj (vlax-ename->vla-object (ssname ss 0)))
    (setq atts (vlax-invoke obj 'Getattributes))
    (setq att (nth 0 atts))
    (setq str (strcat str "," (vlax-get att 'textstring) ))
    (setq x 1)
    (repeat (- (length atts) 1)
      (setq att (nth x atts))
      (setq str (strcat str "," (vlax-get att 'textstring)))
      (setq x (1+ x))
    )
    (write-line str fo)
    )
  )
)
(close fo)
(princ)
)
(c:DCAJA3)

Script

filedia 0
(command "open" "d:\\acadtemp\\Test (2).dwg")
(load "d:\\acadtemp\\D-CAJ-A3.lsp")
close n
(command "open" "d:\\acadtemp\\Test (3).dwg")
(load "d:\\acadtemp\\D-CAJ-A3.lsp")
close n
(command "open" "d:\\acadtemp\\Test (4).dwg")
(load "d:\\acadtemp\\D-CAJ-A3.lsp")
close n
filedia 1

CSV

d:\acadtemp\Test (2).dwg,3,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,3
d:\acadtemp\Test (2).dwg,4,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,3
d:\acadtemp\Test (2).dwg,5,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,5
d:\acadtemp\Test (3).dwg,3,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,5
d:\acadtemp\Test (3).dwg,4,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,5
d:\acadtemp\Test (3).dwg,5,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,5
d:\acadtemp\Test (4).dwg,3,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,5
d:\acadtemp\Test (4).dwg,4,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,5
d:\acadtemp\Test (4).dwg,5,DOCUEMNTO E-1. ANEJO DE EXPROPIACIONES,PLANTA Y PERFIL LONGITUDINAL,SALIDAD DE EMERGENCIA - SE-N-1 (II),Test (??,5

 

Edited by BIGAL
Posted

Hi BIGAL, it works great

Thank you very much for your help

Posted

No worries if you can chase up Libreoffice to see about using .Application would be helpful towards a direct link to excel. 

 

This will draw objects in CAD from excel, try it with your libreoffice calc.draw object xl acad.xlsm

 

image.png.3101dc2e2ea60d8b6e2d6a80ac401540.png

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