Author Topic: How to UnDynamic a Block  (Read 1895 times)

0 Members and 1 Guest are viewing this topic.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
How to UnDynamic a Block
« 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.                             }

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2122
  • class keyThumper<T>:ILazy<T>
Re: How to UnDynamic a Block
« Reply #1 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.



Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How to UnDynamic a Block
« Reply #2 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.

kdub_nz

  • Mesozoic keyThumper
  • SuperMod
  • Water Moccasin
  • Posts: 2122
  • class keyThumper<T>:ILazy<T>
Re: How to UnDynamic a Block
« Reply #3 on: April 29, 2016, 04:07:33 AM »

I look forward to your dissertation regarding the process.

Called Kerry in my other life
Retired; but they dragged me back in !

I live at UTC + 13.00

---
some people complain about loading the dishwasher.
Sometimes the question is more important than the answer.

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How to UnDynamic a Block
« Reply #4 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.

Panzee

  • Mosquito
  • Posts: 2
Re: How to UnDynamic a Block
« Reply #5 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

nobody

  • Swamp Rat
  • Posts: 861
  • .net stuff
Re: How to UnDynamic a Block
« Reply #6 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
« Last Edit: April 29, 2016, 08:41:10 PM by Alien »