TheSwamp

Code Red => .NET => Topic started by: nobody on April 29, 2016, 03:37:55 AM

Title: How to UnDynamic a Block
Post by: nobody on April 29, 2016, 03:37:55 AM
Trying to make dynamic blocks undynamic...can anyone help me finish this off?

Code - C#: [Select]
  1.  BlockTable bt = db.BlockTableId.GetObject(OpenMode.ForRead) as BlockTable;
  2.                         foreach (ObjectId objId in bt)
  3.                         {
  4.                             BlockTableRecord btr = (BlockTableRecord)objId.GetObject(OpenMode.ForRead);
  5.  
  6.                             if (btr.IsDynamicBlock)
  7.                             {
  8.                                
  9.                             }
Title: Re: How to UnDynamic a Block
Post by: kdub_nz on April 29, 2016, 03:58:04 AM
Do they have text attributes  ?

Wild assed guess without seeing if there is a pre-built solution.

No attributes.
determine the last entity in the  database. Get it's handle
Explode the block
collect the entities after the previous last
make a new block with those entities.

If there are attributes, you'll need to remember the tag:value pairs and reset them into the new block.

There MAY be a simpler solution.



Title: Re: How to UnDynamic a Block
Post by: nobody on April 29, 2016, 04:03:26 AM
Found this: http://through-the-interface.typepad.com/through_the_interface/2014/09/exploding-nested-autocad-blocks-using-net.html
going to give it a shot

Do they have text attributes  ?

Wild assed guess without seeing if there is a pre-built solution.

No attributes.
determine the last entity in the  database. Get it's handle
Explode the block
collect the entities after the previous last
make a new block with those entities.

If there are attributes, you'll need to remember the tag:value pairs and reset them into the new block.

There MAY be a simpler solution.
Title: Re: How to UnDynamic a Block
Post by: kdub_nz on April 29, 2016, 04:07:33 AM

I look forward to your dissertation regarding the process.

Title: Re: How to UnDynamic a Block
Post by: nobody on April 29, 2016, 04:18:25 AM

I look forward to your dissertation regarding the process.

Oy...thought it said dynamic block...not nested.... I should read things more closely lol...going to bed.
Title: Re: How to UnDynamic a Block
Post by: Panzee on April 29, 2016, 06:35:27 AM
If editing the blockreferences fits your process perhaps the function
ConvertToStaticBlock(string newBlockName) does what you need.
Its a member of Autodesk.AutoCAD.DatabaseServices.BlockReference
Title: Re: How to UnDynamic a Block
Post by: nobody on April 29, 2016, 07:00:43 PM
Worked perfect. Thanks

If editing the blockreferences fits your process perhaps the function
ConvertToStaticBlock(string newBlockName) does what you need.
Its a member of Autodesk.AutoCAD.DatabaseServices.BlockReference