DesignCAD 3D Max 2027 box
Now available

DesignCAD 2027

Hatches that follow their boundaries, an on-screen dial to turn your model, and a way to find any command by name, in a clean Windows 11 look.

How to delete an entity using an improper entity type definition

Started by prl, December 13, 2014, 02:45:27 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

prl

Juergen had the need to delete 2d text from a selection set.  And he preferred to do it in a single loop. 

Well, I was wondering what would happen if I purposely reassigned the type 13 entity to something that doesn't exist, say a type 60 (undefined).  I was surprised it worked.

Something to add to the programming tips and trick toolbox.

code snippet below

TrashType = 60 'define an entity type number for something that does NOT exist
maxsel = sys(80)

for j = 1 to maxsel
  getselect j, entid
  entity entid
  change Ent_ColorByLayer, 0
  GetAttr entid, type
  if type = 13 then PutAttr entid, TrashType
next j

sys(80)=0

'now select trash entity and delete them all in one step
>EntitySelect
{
<type [TrashType]
}

if sys(80) >0 then
  >erase
  {
  }
endif

Dr PR

prl,

Does this actually cause the entity to be removed from the drawing list (file)?

Or does it leave garbage in the file that just doesn't get displayed?

Phil
DesignCAD user since 1987

prl

Garbage, it creates an improper entity that is still in the database, and as you guessed DesignCAD doesn't know how to display it. In terms of coding what is interesting is the improper invisible entity is selectable with the >EntitySelect command.  So they can be found and deleted in one step, rather than using a second do loop.

Note you can't restore the entities from a type 60 (or any other unassigned number) back to what they came from.  The extra data (in this case text) is lost.

Dr PR

Probably a good idea to delete them if you aren't going to change them back to a valid entity type.

Murphy's law says if you assign an entity type X that doesn't exist now, sometime in the future there will be a legitimate type X entity, and these invalid type X critters will come back to bite you.

But you could use this trick to exempt specific type X entities from a global delete of all type X entities, and then switch the remaining entity back to type X. Sort of like locking an individual entity to protect it from change.

Phil
DesignCAD user since 1987

prl

Quote from: Dr PR on December 14, 2014, 05:37:19 PM
But you could use this trick to exempt specific type X entities from a global delete of all type X entities, and then switch the remaining entity back to type X. Sort of like locking an individual entity to protect it from change.

With the exception of maybe lines and planes, the mapping of a entity type to an improper entity type (undefined) is a one-way trip.  Sending things to an improper entity type means you lose everything except the point data. You'll never be able to restore it (them).

Juergen

Just a short note:

Deleting an entity by using an improper entity type definition works fine.
I haven't detected any irregularities even with large drawings. However,
I'm stuck with the old-fashioned way and still remove the text by a blank.

Alias T_TEXT               &H050A
If  Sys(90) = 13 Then Change T_Text, " "

In terms of speed of execution I found no differences.

Kind regards,

Juergen