Jump to content

drawing rectangle for text


blueshake

Recommended Posts

hi,all

the following codes are used to draw a rectangle for text.but it failed.

after some debug, I found that box is always nil.can somebody help me

thanks.

(defun c:drawing_retangle_for_text(/)
(setq dd 0.5)
(print "\nplease choose the texts.")
(setq ss (ssget))
(setq i 0)
(repeat (sslength ss)
	(setq ssn (ssname ss i))
	(setq ssdata (entget ssn))
	(setq key (cdr (assoc 0 ssdata)))
	(if (= key "MTEXT")
	;then
		(progn
			(setq box (textbox ssdata))
			(setq p1 (car box))
			(setq p3 (cadr box))
			(command "_.rectangle" p1 p3 "")
		)
	)
)
(princ)
)

Link to comment
Share on other sites

Why not use TCIRCLE from Express Tools?

 

sorry.I don't catch your idea.can you do more explanation?thanks.

 

and here are the worked codes.

(defun c:drawing_retangle_for_text(/)
vl-load-com
(setq dd 0.5)
(print "\nplease choose the texts.")
;(setvar "osmode" 0)
(setq ss (ssget))
(setq i 0)
(repeat (sslength ss)
	(setq ssn (ssname ss i))
	(setq ssdata (entget ssn))
	(setq key (cdr (assoc 0 ssdata)))
	(if (= key "MTEXT")
	;then
		(progn
			(vla-GetBoundingBox (vlax-ename->vla-object ssn) 'obj1 'obj2)
			;(setq p1 (vlax-safearray->list (vlax-variant-value obj1)))
			;(setq p3 (vlax-safearray->list (vlax-variant-value obj2)))
			(setq p1 (safearray-value obj1))
			(setq p3 (safearray-value obj2))
			;(print "hi")
			(command "_.rectangle" p1 p3 "")
			;(print "hi")
			(setq ee (entlast))
			(command "_.offset" dd (list ee p1) (polar p3 (/ pi 2) dd) "")
			(entdel ee)
		)
	)
)
;(command "ucs" "")
(princ)
)

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