How do I get blocks name?
Moderators: SDS, support, admin
-
- Posts: 13
- Joined: 19 Jun 2019, 07:30
How do I get blocks name?
How do I know whether blocks are exist or not. also I would like to know how to get their name.
Re: How do I get blocks name?
Hello,
You can check whether a block exists or not by a given block name. For example:
If a block with the given name doesn't exist, the BlockByName method returns null. The block name can be read through a CADBlock.Name property.
Mikhail
You can check whether a block exists or not by a given block name. For example:
Code: Select all
CADBlock block = cadImage.Converter.BlockByName("Block1");
Mikhail
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 13
- Joined: 19 Jun 2019, 07:30
Re: How do I get blocks name?
Thanks for your reply.
Could I ask another question?

It is our drawing template as block
we would like to get a data from certain location of text from this blocks origin.
Is it possible to implement this sequence?
1. Find the most largest block(template in drawing) in dwg and get a location(origin)
or select block(template) manually
2. Get a text data from offset(from block's origin). We would like to parse the text data to distinguish what it is.
Could I ask another question?

It is our drawing template as block
we would like to get a data from certain location of text from this blocks origin.
Is it possible to implement this sequence?
1. Find the most largest block(template in drawing) in dwg and get a location(origin)
or select block(template) manually
2. Get a text data from offset(from block's origin). We would like to parse the text data to distinguish what it is.
Re: How do I get blocks name?
Hello,
It is possible to find the largest block by its bounding rectangle (CADBlock.Box) and read the text data from the CADBlock through a CADBlock.Entities collection. For example:
Mikhail
It is possible to find the largest block by its bounding rectangle (CADBlock.Box) and read the text data from the CADBlock through a CADBlock.Entities collection. For example:
Code: Select all
public static List<string> GetTextDataFromBlock(CADBlock block)
{
List<string> textData = new List<string>();
List<CADEntity> cadTexts = block.Entities.FindAll(ent => ent.EntType == EntityType.Text);
cadTexts.ForEach(entity => textData.Add((entity as CADText).Text));
return textData;
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support
-
- Posts: 13
- Joined: 19 Jun 2019, 07:30
Re: How do I get blocks name?
Thanks for your support.
Sorry to bothering you.
Could you give me any example how to use this function?
You gave me how to find texts of block. However I'm hard to find a way to use this function.
Input parameter is the CADBlock block. Then
Should I get a handle of blocks?
For example, There is a block "A". I want to know that texts in this block by this function.
I don't know how to use "A"block as input parameter in this function.
Thanks
Jaeseo
Sorry to bothering you.
Could you give me any example how to use this function?
You gave me how to find texts of block. However I'm hard to find a way to use this function.
Input parameter is the CADBlock block. Then
Should I get a handle of blocks?
For example, There is a block "A". I want to know that texts in this block by this function.
I don't know how to use "A"block as input parameter in this function.
Thanks
Jaeseo
Re: How do I get blocks name?
Hello Jaeseo,
You are welcome.
CAD .NET allows to find a CADBlock object in a given CAD image by a given block name (see my first reply), so you can rewrite the GetTextDataFromBlock method as follows:
Mikhail
You are welcome.
CAD .NET allows to find a CADBlock object in a given CAD image by a given block name (see my first reply), so you can rewrite the GetTextDataFromBlock method as follows:
Code: Select all
public static List<string> GetTextDataFromBlock(CADImage cadImage, string blockName)
{
List<string> textData = new List<string>();
CADBlock block = cadImage.Converter.BlockByName(blockName);
if (block != null)
{
List<CADEntity> cadTexts = block.Entities.FindAll(ent => ent.EntType == EntityType.Text);
cadTexts.ForEach(entity => textData.Add((entity as CADText).Text));
}
return textData;
}
Technical Support E-mail: support@cadsofttools.com
Chat support on Skype: cadsofttools.support
Chat support on Skype: cadsofttools.support