How to Determine if a Line Entity is from a Dimension
Moderators: SDS, support, admin
How to Determine if a Line Entity is from a Dimension
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!
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
Hi,rockmover wrote: ↑20 Jan 2023, 09:01I 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!
You could check if the entity is a dimension by following:
Code: Select all
if(entity.EntType == EntityType.Dimension)
Code: Select all
if(entity is CADDimension).
Catherine.
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
Re: How to Determine if a Line Entity is from a Dimension
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?
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
Hi,rockmover wrote: ↑26 Jan 2023, 06:27Unfortunately, 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?
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);
}
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 3
- Joined: 09 Mar 2023, 12:41
Re: How to Determine if a Line Entity is from a Dimension
I tried this code but not working for me.
-
- Posts: 1
- Joined: 17 Mar 2023, 14:18
Re: How to Determine if a Line Entity is from a Dimension
Ok, I will try it and if I still face any issue, I will message you.support wrote: ↑27 Jan 2023, 11:11Hi,rockmover wrote: ↑26 Jan 2023, 06:27Unfortunately, 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?
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):Catherine.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); } }
Re: How to Determine if a Line Entity is from a Dimension
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
Chat support on Skype: cadsofttools.support
-
- Posts: 3
- Joined: 09 Mar 2023, 12:41
Re: How to Determine if a Line Entity is from a Dimension
It is working fine now. I am sorry for the late reply.
-
- Posts: 1
- Joined: 12 Apr 2024, 10:03
Re: How to Determine if a Line Entity is from a Dimension
Working fine for me also, thank you.