Jump to content

Recommended Posts

Posted

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.

 

 

 

Posted (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 by Lee Mac
  • Like 2
Posted

Lee has you covered, but do you have a reason to not use vla-put-textstring .. it's quite a bit simpler :).

Posted

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.

Posted

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 :thumbsup:

  • Like 1

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