Jump to content

Switch letters inside the attributes text with autocad lisp


Recommended Posts

Posted

Hi,

 

Can someone help me with a lisp to change the position of letters in the text of attributes such as XX/YY to YY/XX?

 

Thx

Posted

@Liviu Petreus Give this a try:

 

(defun c:foo (/ i s str)
  (if (setq s (ssget ":L" '((0 . "INSERT") (66 . 1))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (foreach att (vlax-invoke (vlax-ename->vla-object e) 'getattributes)
	(if (setq i (vl-string-search "/" (setq str (vla-get-textstring att))))
	  (vla-put-textstring att (strcat (substr str (+ 2 i)) "/" (substr str 1 i)))
	)
      )
    )
  )
  (princ)
)

 

Posted
8 hours ago, ronjonp said:

@Liviu Petreus Give this a try:

 

(defun c:foo (/ i s str)
  (if (setq s (ssget ":L" '((0 . "INSERT") (66 . 1))))
    (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
      (foreach att (vlax-invoke (vlax-ename->vla-object e) 'getattributes)
	(if (setq i (vl-string-search "/" (setq str (vla-get-textstring att))))
	  (vla-put-textstring att (strcat (substr str (+ 2 i)) "/" (substr str 1 i)))
	)
      )
    )
  )
  (princ)
)

 

Many thanks

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