Jump to content

Very very fast lisp for catch multiple attributes value and then paste in word or excel


itacad

Recommended Posts

Hello, I don't remember where, however long ago I found the following lisp to "capture" the value of a series of attributes to form a string, save it in the windows clipboard and paste it out of autocad

 

(defun c:catchattcum (/ att html result)
 (vl-load-com)
 (setq stringa  "")
 (while (setq att(car(nentsel "\nSeleziona attributo: ")))
  (setq stringa(strcat stringa (cdr(assoc 1 (entget att))) " "))
 )
 (setq stringa (substr stringa 1 (- (strlen stringa) 1)))
 (setq html   (vlax-create-object "htmlfile")
       result (vlax-invoke
	       (vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData)
	       'setData
	       "Text"
	       stringa
	      )
 )
 (vlax-release-object html)
)

Later thanks to some help, I modified it to be able to paste the set of attributes specifically in excel, pasting each attribute on a cell of the same column

 

(defun c:catchattcumex (/ att html result)
 (vl-load-com)
 (setq stringa  "")
 (while (setq att(car(nentsel "\nSeleziona attributo: ")))
  (setq stringa(strcat stringa (cdr(assoc 1 (entget att))) "\n"))
 )
 (setq stringa (substr stringa 1 (- (strlen stringa) 1)))
 (setq html   (vlax-create-object "htmlfile")
       result (vlax-invoke
	       (vlax-get (vlax-get html 'ParentWindow) 'ClipBoardData)
	       'setData
	       "Text"
	       stringa
	      )
 )
 (vlax-release-object html)
)

the difference between the two lisp is in the fifth line, where "\ n" is used as a separator...

If I understand correctly "\ n" = newline and this allows to distribute vertically as I described the attributes on an excel sheet.

I ask you if there is an expression for "tab" that in my opinion should allow to paste the string generated horizontally on the excel sheet, one cell after another in the same row.

 

Thank you in advance

 

Link to comment
Share on other sites

You can get attributes and send direct to excel as cells if you want. Start with Getexcel.lsp, removes the need to do a paste. It has a Putcell function.

 

I have written my own version of getexcel but it is a work in progress and is normally customised to suit a particular client export needs. Think beer money.

 

 

 

 

Link to comment
Share on other sites

Hi Steve P, it seems to me that \ t was what I was missing to get me to the solution of the problem!

For Bigal: I do not know the lisp that you have reported to me and I will look for it in the discussions of the forum, I will see what it is, thanks for the report

 

  • Like 1
Link to comment
Share on other sites

I will read what you have proposed to me! In the meantime, I ask you one more thing with an excel argument!
Given the excellent solutions I received on this forum, I would like to try to subscribe to an excel forum in English (excel and VBA), can you tell me someone you think is valid and calm as a cadtutor?
Thank you

Link to comment
Share on other sites

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