How to Determine if a Line Entity is from a Dimension

Discuss and ask questions about CAD .NET library.

Moderators: SDS, support, admin

Post Reply
rockmover
Posts: 2
Joined: 20 Jan 2023, 08:54

How to Determine if a Line Entity is from a Dimension

Post by rockmover » 20 Jan 2023, 09:01

I am looping though all my Entities and storing them as line elements (it is what I need to do for my application).

image.Converter.Iterate(new CADImport.CADEntityProc(ReadCADEntities), null, cadParams);

However, if the line is from a dimension I want to ignore it. How can I determine if the line is real, or was created from a dimension?

Or do I somehow need to "delete" dimension objects after I load in my dwg file?

Thanks in advance!

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: How to Determine if a Line Entity is from a Dimension

Post by support » 23 Jan 2023, 11:34

rockmover wrote:
20 Jan 2023, 09:01
I am looping though all my Entities and storing them as line elements (it is what I need to do for my application).

image.Converter.Iterate(new CADImport.CADEntityProc(ReadCADEntities), null, cadParams);

However, if the line is from a dimension I want to ignore it. How can I determine if the line is real, or was created from a dimension?

Or do I somehow need to "delete" dimension objects after I load in my dwg file?

Thanks in advance!
Hi,

You could check if the entity is a dimension by following:

Code: Select all

if(entity.EntType == EntityType.Dimension)
or

Code: Select all

if(entity is CADDimension).

Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

rockmover
Posts: 2
Joined: 20 Jan 2023, 08:54

Re: How to Determine if a Line Entity is from a Dimension

Post by rockmover » 26 Jan 2023, 06:27

Unfortunately, this doesn't seem to work.

I can indeed ignore dimension types if I am looping though each layer with say a foreach loop

foreach (CADImport.CADEntity entity in image.Converter.Entities)


However, I need to load all objects and more importantly blocks. So instead of looping though everything am using the Converter.Iterate as in the example files:

image.Converter.Iterate(new CADImport.CADEntityProc(ReadCADEntities), null, cadParams);

If I check for a "Dimension" entity type inside of the ReadCADEntities method, there are none ever found. I suspect that the dimensions are being converted to lines/points somehow before the switch (entity.EntType) statement in the ReadCADEntites method?

Would it maybe work if I looped through all the drawing objects, deleted any dimension entites, and then used the Convert.Iterate method?

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: How to Determine if a Line Entity is from a Dimension

Post by support » 27 Jan 2023, 11:11

rockmover wrote:
26 Jan 2023, 06:27
Unfortunately, this doesn't seem to work.

I can indeed ignore dimension types if I am looping though each layer with say a foreach loop

foreach (CADImport.CADEntity entity in image.Converter.Entities)


However, I need to load all objects and more importantly blocks. So instead of looping though everything am using the Converter.Iterate as in the example files:

image.Converter.Iterate(new CADImport.CADEntityProc(ReadCADEntities), null, cadParams);

If I check for a "Dimension" entity type inside of the ReadCADEntities method, there are none ever found. I suspect that the dimensions are being converted to lines/points somehow before the switch (entity.EntType) statement in the ReadCADEntites method?

Would it maybe work if I looped through all the drawing objects, deleted any dimension entites, and then used the Convert.Iterate method?
Hi,
CADDimension has its own entities (lines, points, etc.) stored in a block. Most likeky, you're iterating in a wrong way (iterating through a block and can't find dimensions).
Please, have a look at the code example below (checking dimensions in a current layout):

Code: Select all

var dimensionCollection = new List<CADDimension>();

   foreach(CADEntity ent in cadImage.CurrentLayout.Entities)
   {
    if (ent.EntType == EntityType.Dimension)
                {
     dimensionCollection.Add(ent as CADDimension);
                }
            }
Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

MichealStanton
Posts: 3
Joined: 09 Mar 2023, 12:41

Re: How to Determine if a Line Entity is from a Dimension

Post by MichealStanton » 17 Mar 2023, 14:17

I tried this code but not working for me.

FrancesWatkins
Posts: 1
Joined: 17 Mar 2023, 14:18

Re: How to Determine if a Line Entity is from a Dimension

Post by FrancesWatkins » 17 Mar 2023, 14:20

support wrote:
27 Jan 2023, 11:11
rockmover wrote:
26 Jan 2023, 06:27
Unfortunately, this doesn't seem to work.

I can indeed ignore dimension types if I am looping though each layer with say a foreach loop

foreach (CADImport.CADEntity entity in image.Converter.Entities)


However, I need to load all objects and more importantly blocks. So instead of looping though everything am using the Converter.Iterate as in the example files:

image.Converter.Iterate(new CADImport.CADEntityProc(ReadCADEntities), null, cadParams);

If I check for a "Dimension" entity type inside of the ReadCADEntities method, there are none ever found. I suspect that the dimensions are being converted to lines/points somehow before the switch (entity.EntType) statement in the ReadCADEntites method?

Would it maybe work if I looped through all the drawing objects, deleted any dimension entites, and then used the Convert.Iterate method?
Hi,
CADDimension has its own entities (lines, points, etc.) stored in a block. Most likeky, you're iterating in a wrong way (iterating through a block and can't find dimensions).
Please, have a look at the code example below (checking dimensions in a current layout):

Code: Select all

var dimensionCollection = new List<CADDimension>();

   foreach(CADEntity ent in cadImage.CurrentLayout.Entities)
   {
    if (ent.EntType == EntityType.Dimension)
                {
     dimensionCollection.Add(ent as CADDimension);
                }
            }
Catherine.
Ok, I will try it and if I still face any issue, I will message you.

support
Posts: 3271
Joined: 30 Mar 2005, 11:36
Contact:

Re: How to Determine if a Line Entity is from a Dimension

Post by support » 20 Mar 2023, 08:37

MichealStanton wrote:
17 Mar 2023, 14:17
I tried this code but not working for me.
Hi,
Do I get it right and you don't want to show dimensions on the CADImage? If so, could you elaborate what is not working? Does any message error appear?

Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support

MichealStanton
Posts: 3
Joined: 09 Mar 2023, 12:41

Re: How to Determine if a Line Entity is from a Dimension

Post by MichealStanton » 02 May 2023, 17:33

It is working fine now. I am sorry for the late reply.

CameronReeves
Posts: 1
Joined: 12 Apr 2024, 10:03

Re: How to Determine if a Line Entity is from a Dimension

Post by CameronReeves » 12 Apr 2024, 15:45

Working fine for me also, thank you.

Post Reply