Page 1 of 1

access all cadpicturebox entities

Posted: 05 Mar 2023, 16:55
by Masoud
Hello
How can I access all cadpicturebox entities?

I want to delete all the text entities created by the cadpicturebox environment

tnx for your help

Re: access all cadpicturebox entities

Posted: 06 Mar 2023, 16:41
by support
Masoud wrote:
05 Mar 2023, 16:55
Hello
How can I access all cadpicturebox entities?

I want to delete all the text entities created by the cadpicturebox environment

tnx for your help
Hello,
To delete entities from the current layout (cadImage.CurrentLayout) you should iterate all the entities on the layout, compare their types and delete cadImage.RemoveEntity(ent);

Code: Select all

private void button1_Click(object sender, EventArgs e)
        {
   if (cadImage == null) return;
   var collection = cadImage.CurrentLayout.Entities;
   int cnt = cadImage.CurrentLayout.Entities.Count;
   while (cnt > 0)
            {
    CADEntity ent = cadImage.CurrentLayout.Entities[cnt-1];
    if (ent is CADText || ent is CADMText)
                {     
     cadImage.RemoveEntity(ent);
                }
    cnt--;
            }   
   
   cadPictBox.Invalidate();}
Regards,
Catherine

Re: access all cadpicturebox entities

Posted: 07 Mar 2023, 18:26
by Masoud
thank you Catherine

Re: access all cadpicturebox entities

Posted: 15 Mar 2023, 12:53
by WilliamVance
support wrote:
06 Mar 2023, 16:41
Masoud wrote:
05 Mar 2023, 16:55
Hello
How can I access all cadpicturebox entities?

I want to delete all the text entities created by the cadpicturebox environment

tnx for your help
Hello,
To delete entities from the current layout (cadImage.CurrentLayout) you should iterate all the entities on the layout, compare their types and delete cadImage.RemoveEntity(ent);

Code: Select all

private void button1_Click(object sender, EventArgs e)
        {
   if (cadImage == null) return;
   var collection = cadImage.CurrentLayout.Entities;
   int cnt = cadImage.CurrentLayout.Entities.Count;
   while (cnt > 0)
            {
    CADEntity ent = cadImage.CurrentLayout.Entities[cnt-1];
    if (ent is CADText || ent is CADMText)
                {     
     cadImage.RemoveEntity(ent);
                }
    cnt--;
            }   
   
   cadPictBox.Invalidate();}
Regards,
Catherine
Ok, I will do it as you said and if I face any problem, I will message you.