When choose text ,put text into a table.

When choose text ,put text into a table.

ramoneramone
Enthusiast Enthusiast
1,206 Views
15 Replies
Message 1 of 16

When choose text ,put text into a table.

ramoneramone
Enthusiast
Enthusiast

I would like to choose text, then put text into a table by lisp.

 

 

att.jpg

0 Likes
Accepted solutions (1)
1,207 Views
15 Replies
Replies (15)
Message 2 of 16

komondormrex
Mentor
Mentor
Accepted solution

give this a try.

 

 

 

 

;*********************************************************************************************************************************************************

;	komondormrex, may 2023

;*********************************************************************************************************************************************************

(defun put_cell_value (string / cell_picked table_selected_object row_number column_number checking_vector table_sset)
	(setq checking_vector (vlax-3d-point (getvar 'viewdir)))
	(while (null cell_picked)
		(setq picked_point (vl-catch-all-apply 'getpoint (list (strcat "\nPick a cell of a table to put \"" string "\" into: "))))
		(cond
			(
				(vl-catch-all-error-p picked_point)
					(setq cell_picked t)
			)
			(
				(null picked_point)
			)
			(
				t
					(setq table_sset (ssget "_f" (list
									  					picked_point
									  					(list (car picked_point) (+ (cadr (getvar 'viewctr)) (/ (getvar 'viewsize) 2.0)))
								 				 )
								 				'((0 . "ACAD_TABLE"))
									 )
					)
					(cond
						(
							(null table_sset)
						)
						(
							(and
								(= :vlax-true (vla-hittest (setq table_selected_object (vlax-ename->vla-object (ssname table_sset 0)))
														   (vlax-3d-point picked_point) checking_vector 'row_number 'column_number
											  )
								)
								(or
									(= :vlax-true (vla-get-titlesuppressed table_selected_object))
									(and
										 (= :vlax-false (vla-get-titlesuppressed table_selected_object))
										 (not (zerop row_number))
									)
								)
							)
								(setq cell_picked t)
								(vla-setcellvalue table_selected_object row_number column_number string)
						)
						(
							t
						)
					)
			)
		)
	)
)

;*********************************************************************************************************************************************************

(defun c:put_text_to_table_cell nil
	(put_cell_value (cdr (assoc 1 (entget (car (entsel "\nPick text entity to copy text string: "))))))
	(princ)
)

;*********************************************************************************************************************************************************

 

 

 

Message 3 of 16

ramoneramone
Enthusiast
Enthusiast

Thank you for your cooperation. I did.

Is it possible for this program to function on the Autocad LT version?

 

If possible, I would like to run this program on the Autocad LT version.

 

 

0 Likes
Message 4 of 16

Sea-Haven
Mentor
Mentor

Did you test it ? If it did not work post screen captures etc of the error messages.

0 Likes
Message 5 of 16

komondormrex
Mentor
Mentor

unfortunately it would not work in autocad lt, even in autocad 2024 lt, since it has no support for visual lisp vl* functionality.

0 Likes
Message 6 of 16

ramoneramone
Enthusiast
Enthusiast

Thank you to everyone who replied. I am currently using the LT version.

 

0 Likes
Message 7 of 16

Sea-Haven
Mentor
Mentor

Do you have LT 2024, cut and paste sections of code to test and what does not work which bit of the code ? It may be possible to do a work around. 

 

I am guessing Hit-test.

 

If it is this then remove it. Hopefully no errors will occur.

vl-catch-all-apply

 

0 Likes
Message 8 of 16

ramoneramone
Enthusiast
Enthusiast
I don't have Autocad 24 LT.
Simple processing is available in menu macros and command line input on LT version.
Since it has no support for visual lisp vl* functionality.
0 Likes
Message 9 of 16

Sea-Haven
Mentor
Mentor

What I said was a possible work around may be needed, need to know which bit of code is failing VL* is just to broad a statement. There is support for a lot of VL in LT 2024, check out comments about what does not work.

 

Because LT 24 does not have VLIDE you need to copy and paste to command line the code in small sections and test.

 

test 1 if this line works then catch-all is probably ok.

(setq picked_point (vl-catch-all-apply 'getpoint (list (strcat "\nPick a cell of a table to put \"" string "\" into: "))))
		

Thinking about hit-test check.

 

 

0 Likes
Message 10 of 16

ramoneramone
Enthusiast
Enthusiast
I understand what you said.
I pasted the code into the command line.

Autocad LT version 2013.

The following message appeared.
"; エラー: 引数の型が違います: stringp nil"
0 Likes
Message 11 of 16

ramoneramone
Enthusiast
Enthusiast

I tried to run your program on trial full version(Not Lt version), then it did work well.

Your program is no problrem.

 

 

0 Likes
Message 12 of 16

ramoneramone
Enthusiast
Enthusiast

att.gif

0 Likes
Message 13 of 16

komondormrex
Mentor
Mentor

well, i was wrong stating that autocad 2024 lt does not support visual lisp vl* functionality. it does with some limitations(. but every vanilla version of autocad lt prior to 2024 lt as far as i know does not support autolisp in any form. yours 2013 lt too.

 

komondormrex_0-1685519237166.png

 

Message 14 of 16

ramoneramone
Enthusiast
Enthusiast
Thank you for your reply.
It appears that Autolisp is not supported on any LT version.
If possible, I would like to run this program on the Autocad LT version.
0 Likes
Message 15 of 16

Sea-Haven
Mentor
Mentor

As stated lisp has only been added to LT 2024 any earlier version and it will not work. 

 

I would suggest try select text then Ctrl+C, select cell then Ctrl+V. 

 

0 Likes
Message 16 of 16

ramoneramone
Enthusiast
Enthusiast

I  always pasted the code to the command line on LT VERSION.

For example, the command to copy the following text is pasted.

If VL is included, an error has occurred.

 

0 Likes