Jump to content

Is it possible to export a table with block symbols (block in a cell) to csv or Excel and make the symbols appear in the csv/excel table?


Recommended Posts

Posted

Hi.

I have a table with one column of block symbols created with "block in cell" for table.

when exporting the table in a regular way (either "export table" command or by copyclip to excel or csv file (CTRL-C CTRL-V) the symbols are (obviously...) lost.

is there a way to export the table with the symbols to CSV file or excel?

 

See the attached dwg file with such a table.

 

thanks,

aridzv.

Table_Preview.dwg

Posted (edited)

Yes is the answer but its a 2 step process, you must make an image of the block, then you can insert an image into a Excell cell. The insertion off an image into Excel does not use the wording image rather Picture, but then its known as a shape. Confusing.

 

If you look for Alan Excel.lsp here and check it has the word "picture" in it. You will get all the Excel code you need. There is different versions here as it keeps getting extra functions added to it.

 

If you get stuck just ask here.

 

 

 

 

Edited by BIGAL
Posted (edited)

@BIGAL

thanks for the reply!!

I got your "Alan Excel library.lsp".

did you ment this function:

(defun putimagecell (cellname val1 / )
 (setq myRange (vlax-get-property  (vlax-get-property myxl "ActiveSheet") "Range" cellname))
 (vlax-put-property myRange 'Picture val1)
)

 

but how do I make an image of the block to use it as "val1" in the function?

EDIT:

I got the images as .png files in a known location,

and the .png files names are the blocks names that they belong to, 

how do I move ahead?

 

thanks,

aridzv.

Edited by aridzv
Posted (edited)

It may not have been in the version you downloaded. Try this, you will need to decide if to match the current cell size so preset width etc. Rearrange the insimage defun if want a match to cell size

 

; Code by MunsteanStefan May 2023
; mor efunctions added AlanH

(defun insimage (imname row col / cursheet cell left top)
(setq cursheet (vlax-get-property myxl "ActiveSheet"))
(setq cell (vlax-variant-value  (vlax-get-property  (vlax-get cursheet 'Cells) 'Item row col)))
(setq left (vlax-get cell "Left")
      top  (vlax-get cell "Top")
)
(setq shapes (vlax-get-property cursheet "Shapes"))
(vlax-invoke shapes
  "AddPicture"
  imname
  :vlax-false
  :vlax-true
  left
  top
  -1
  -1
)
(princ)
)

; get cell width 1st then set width
(setq wid (vlax-get cell 'width))

 ; has a variable cnt so get last shape ?
 ; must run get shapes so count updates
(setq cursheet (vlax-get-property myxl "ActiveSheet"))
(setq shapes (vlax-get-property cursheet "Shapes"))
(setq cnt (vlax-get shapes 'count))
(setq sh (vla-item shapes cnt))
(vlax-put-property sh 'width wid)

 

Edited by BIGAL
Posted

like this ? 

 

Posted
2 hours ago, Danielm103 said:

like this ? 

 

 

YES!!!

quite impressive i must say.

 

now,

how do I run this code (Python, right?)  in autocad\bricscad?......

 

thanks,

Posted

Did you test my code worked for me and I tested in Bricscad.

 

I am sure @Danielm103 will advise on how to load the Python run time needed.

Posted

@BIGAL

Hi.

No,

I was busy with the python code that @Danielm103 posted and also I created other way to do this task with tow VBA code modules, 

one run inside the cad software exporting the images to .png files and the second run from within Excel importing them to the spreadsheet. 

so I was quite busy...

but that other issue of Excel leave a ghost process in the task manager is still there,

The code to unload it you gave in the other place didn't solve it unfortunately...

I'll try to give it a look in the coming days. 

 

Aridzv.

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