Page 1 of 1

How to Determine if a Line Entity is from a Dimension

Posted: 20 Jan 2023, 09:01
by rockmover
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!

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

Posted: 23 Jan 2023, 11:34
by support
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.

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

Posted: 26 Jan 2023, 06:27
by rockmover
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?

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

Posted: 27 Jan 2023, 11:11
by support
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.

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

Posted: 17 Mar 2023, 14:17
by MichealStanton
I tried this code but not working for me.

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

Posted: 17 Mar 2023, 14:20
by FrancesWatkins
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.

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

Posted: 20 Mar 2023, 08:37
by support
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.

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

Posted: 02 May 2023, 17:33
by MichealStanton
It is working fine now. I am sorry for the late reply.

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

Posted: 12 Apr 2024, 15:45
by CameronReeves
Working fine for me also, thank you.