Block is not part of the DxfEntityCollection
![]() 9/13/2023 11:22 AM
|
---|
So far whenever I have read a dwg file into a DxfModel using 'CadReader.Read', all the blocks would have a corresponding entry in the DxfEntityCollection as a type DxfInsert.
But there are few dwgs, which when I import will only have entries in DxfEntityCollection for few of the blocks and not all of them. I am not quite sure what may have caused this. Any hint is appreciated!
Thanks in advance!
|
![]() 9/13/2023 11:27 AM
|
---|
This assumption is incorrect:
all the blocks would have a corresponding entry in the DxfEntityCollection as a type DxfInsert
A block does not have to be inserted into the drawing.
- Wout |
![]() 9/13/2023 11:33 AM
|
---|
Yes, I just found that in the drawing it was not inserted. Unfortunately two blocks had similar drawing and I assumed it was the other one.
Thanks for your response!
|
![]() 9/14/2023 5:19 AM
|
---|
But, what if there are certain blocks that are part of the drawing but not inserted. In this case how will I pick certain uninserted blocks?
I tried taking it from the DxfBlockCollection and creating a DxfInsert with that block name.
Currently I am trying to add the attributes from the block(not inserted in the source drawing). Unfortunately the attribute values(Text) are not shown when i open it in Autocad.
Below is the code I am using:
C# Code: private void InsertSourceBlockInTargetModel( |
![]() 9/14/2023 5:32 AM
|
---|
Well cloning the attribute made it work :)
C# Code: private void InsertSourceBlockInTargetModel( |
![]() 9/14/2023 6:33 AM
|
---|
Ignore this reply
|
![]() 9/14/2023 7:22 AM
|
---|
You should get the attribute definitions from the cloned block instead of the source block, because the way you're doing it you're cloning the attribute definitions twice. You don't need to clone them again inside your for loop.
- Wout
|
![]() 9/14/2023 7:35 AM
|
---|
I tried what you suggested but unfortunately I do not see the attribute values when I open it in Autocad.
C# Code: private void InsertSourceBlockInTargetModel( |
![]() 9/14/2023 7:39 AM
|
---|
Hard to tell what's happening without data/further information. Either way your first version is incorrect because the double cloning, and you don't even add the cloned attribute definition to anything (it should normally be added to the cloned block, but it would contain double the attribute definitions and it makes no sense).
I would use ReferenceResolutionType.CloneMissing instead of ReferenceResolutionType.IgnoreMissing though.
- Wout
|
![]() 9/14/2023 8:11 AM
|
---|
Tried using CloneMissing as well. When I debugged I see the clonedBlock.GetAttributeDefinitions() yield no attribute definitions. Not sure why though. I have mailed the dwg file to you.
Ideally yes, when we clone a block, it should generally retrieve all the attribute definitions what source block had.
C# Code: private void InsertSourceBlockInTargetModel( |