Jump to content

Add text to string by 'TextString (adding functionality in existing short lisp)


dszlapka

Recommended Posts

Hi
I have short lisp, writed by someone.

It read clicked polyline lenght and put result to clicked attribute in block.

I would like to add on end string a sign "m".

I tried "strcat", but it not worked.

Someone help me ?

(defun c:KT_dlugosc ( / poly att)
  (while
    (and
      (setq poly (ssget "_+.:S:E" '((0 . "*LINE"))))
      (setq att (car (nentsel "\nSelect Attribute")))
      (eq "AcDbAttribute"
	  (vla-get-objectname (setq att (vlax-ename->vla-object att)))
      )
    )
     (vlax-put att
	       'TextString
	       (rtos (vlax-curve-getDistAtParam
		       (setq poly (ssname poly 0))
		       (vlax-curve-getEndParam poly)
		     )
		     2 0
	       )
     )
  )(princ)
)

 

Link to comment
Share on other sites

Hello Dszlapka, welcome in the forum!

I am in vacation right now, I can't test it, but the "strcat" method should work.

(defun c:KT_dlugosc ( / poly att)
  (while
    (and
      (setq poly (ssget "_+.:S:E" '((0 . "*LINE"))))
      (setq att (car (nentsel "\nSelect Attribute")))
      (eq "AcDbAttribute"
	  (vla-get-objectname (setq att (vlax-ename->vla-object att)))
      )
    )
     (vlax-put att
	       'TextString
	       (strcat (rtos (vlax-curve-getDistAtParam
		       (setq poly (ssname poly 0))
		       (vlax-curve-getEndParam poly)
		     )
		     2 0
	       ) "m")
     )
  )(princ)
)

 Please try this code and post a feed-back. Post the error message you get, for sure someone will be able to fix it!

  • Like 1
  • Thanks 1
Link to comment
Share on other sites

Thanks a lot. It works as I wanted.
I see it was very simple, but not for me :) I used "strcat" incorrectly.

Have a nice holiday.

  • Like 1
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...