Jump to content

Automatically add text to a table


Recommended Posts

Posted

Hi every one

I need a lisp that adds the texts I select, to a pre defined table in Autocad.
In the attached file, I need to select texts in the "DRAWING TITLE" part, and add them to the first column of the table.

It would be great if the lisp, itself, can automatically select all of the mentioned texts and add them to the table. But if not, I can manually select the texts, and the lisp adds them to the table. 

Add Text to Table.dwg

Posted (edited)

I think based on something Bigal wrote, link in the code.

 

Command TEST (feel free to rename)

- User selects the table

- User picks the start row.   Fill in 1 for the row of 000,   Fill in 2 for the row of 001, ...

(you can hardcode this (setq row 1) if you will always start with 1

- User selects the title objects, the green text objects "GENERAL NOTES 0" ...  one by one

 

;; https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/user-text-to-existing-table-cells/td-p/12238012
;;You can get tables using ssget.
;;
;;I just posted this, the 0 0 is the title, 1 1 is 1st cell in header
(vl-load-com)

(defun c:test ( / obj rows cols row col value_ cellvalue)
	(setq obj (vlax-ename->vla-object (car  (entsel "\nPick table: "))))
	(setq rows (vlax-get-property obj 'rows))
	(setq cols (vlax-get-property obj 'columns))
	
	;; get value of a cell
	;;(setq col (getint "\nColumn: "))
	;;(setq row (getint "\nRow: "))
	;;(setq cellvalue (vlax-variant-value (vla-GETCELLVALUE OBJ row col)))
	;;(princ "\n")
	;;(princ cellvalue)
	
	;;;;;;;;;;;;
	
	
	(setq col 0)
	(setq row (getint "\nStart Row (row 1 = the row of 000): "))
	(princ "\nNow select texts: ")
	(while (setq title_obj (entsel "\ntitle object: "))
		(setq title (cdr (assoc 1 (entget (car title_obj)))))
		;;So if you know where "REVISION" is row & column can check easy then use next to put values.
		(vla-settext obj row col title)
		(setq row (+ row 1))
	)

)

 

Happy with this?

 

We can quite easily let you select all the all the frames, and read all the Text objects on layer "TEXT-0.3", sort from left to right, ... then auto fill in the table

 

If you want

 

 

 

 

Edited by Emmanuel Delay

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