Steven P Posted February 2, 2021 Posted February 2, 2021 Good evening, I accept that this has probably been covered before but I couldn't see anything. How would you delete an entity DXF group code from the entity definition (I think that's how I should describe it). For example in a long MTEXT, more than 255 characters the text is contained in code groups 1, and 3. Suppose I want to only have the left over characters (the reminder of the length of text / 255,) I could delete all the DXF group 3's to leave just the 1, Hope that makes sense so far. I am stuck how to delete the whole group though I have tried treating it like a list, looping through it, copy if it is not what I want to discard and then try to update the entity, which didn't work I tried making a new entity using what I want to keep but that wasn't working quite as I wanted all the time, and a few other things, so am womdering if there is a way to just delete a group Any help would be great, thanks. Quote
Lee Mac Posted February 3, 2021 Posted February 3, 2021 (edited) If you supply a partial DXF list to the entmod function, only those groups included in the list will be modified (provided that there are sufficient groups present to identify the entity in the drawing database), as such, I believe you would need to delete & recreate the entity with the relevant groups removed, e.g.: (defun c:test ( / ent enx ) (if (and (setq ent (car (entsel))) (= "MTEXT" (cdr (assoc 0 (setq enx (entget ent))))) ) (if (entmake (vl-remove-if '(lambda ( x ) (= 3 (car x))) enx)) (entdel ent) (princ "\nUnable to create modified entity.") ) (princ "\nNothing selected or object wasn't MText.") ) (princ) ) Edited February 3, 2021 by Lee Mac 2 Quote
ronjonp Posted February 3, 2021 Posted February 3, 2021 Lee has you covered, but do you have a reason to not use vla-put-textstring .. it's quite a bit simpler :). Quote
Steven P Posted February 4, 2021 Author Posted February 4, 2021 Thanks Lee, I'll try that this morning. I think I know what you are doing and how it works and is something I hadn't thought about. RonJon,, thanks, I know what you are saying. I have quite a few LISPs for text, some use vla- and some use entmod, and some other things entirely. I am trying to rationalise them all, make up some common sub-routines and have them all run with similar methods. I just decided to use entmod as a common method since this can update the other text properties - layer, font, position etc... If it works for the text lisps I might try to do the same with the other routines I have (for lines and so on). It might not be the best method to use in all cases of course and am open to suggestions. Quote
Lee Mac Posted February 4, 2021 Posted February 4, 2021 I wouldn't artificially restrict yourself to using the same method for every program - it's all about selecting the appropriate tool for the job 1 Quote
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.