ksperopoulos Posted November 16, 2013 Share Posted November 16, 2013 I am trying to remove a hyphen from mtext. The hyphen will not always be in the same location. This is an example of what I am trying to do: 12-1/4" to 12 1/4" Could someone point me in the right direction of how to achieve this please? Thank you. Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted November 16, 2013 Share Posted November 16, 2013 Prompt user to select MText (entsel) Retrieve the MText DXF data (entget) Retrieve the MText content (DXF group 1: cdr / assoc) Retrieve the position of the hyphen in the string if present (vl-string-search / vl-string-position) Remove the hyphen from the string (substr)* Update the DXF data with the new content (subst) Modify the MText entity (entmod) *There are several alternative methods to approach this step: Substitute the hyphen for an empty string (vl-string-subst) Or: Convert the string to a list of ASCII characters (vl-string->list) Remove the hyphen character (vl-remove) Convert the list of ASCII characters back to a string (vl-list->string) Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted November 16, 2013 Author Share Posted November 16, 2013 Thank you Lee Mac. I will give these a shot and post an update later. Quote Link to comment Share on other sites More sharing options...
ksperopoulos Posted November 16, 2013 Author Share Posted November 16, 2013 Lee Mac - This seems to work. Thank you for the help! (defun c:testsize ( / obj lay sz1 sz2) (vl-load-com) (setq obj (entget (car (entsel "\nSelect Object")))) (setq lay (cdr (assoc 8 obj))) (setq sz1 (cdr (nth 9 obj))) (setq sz2 (vl-string-subst " " "-" sz1)) (command "clayer" (strcat lay "-SIZE")) (command "mleader" pause pause (strcat sz2 "\"")) (princ) ) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.