Code Red > .NET
Creating Static Block of iinstance of dynamic block
(1/1)
cmwade77:
I am trying to work around some issues in CAD, so I am trying to create a static block of an instance of dynamic blocks. I have code that mostly works with this jig until I click to finish the the rotateresize jig as attached, then it throws a system exception error because it tries to copy the block again. I am using the attached block as well. I am close, just not sure what I am missing.
gile:
Hi,
What about using BlockReference.ConvertToStaticBlock?
gile:
Your CreateBlock method could be something like this:
--- Code - C#: --- private static void CreateStaticBlock(BlockReference originalBlockRef) { var db = originalBlockRef.Database; using (var tr = db.TransactionManager.StartTransaction()) { var blockTable = (BlockTable)tr.GetObject(db.BlockTableId, OpenMode.ForRead); int i = 1; string newName; do { newName = $"Nested_{i++}"; } while (blockTable.Has(newName)); originalBlockRef.ConvertToStaticBlock(newName); tr.Commit(); } }And this method should not be called in the Update method of the RotateResizeBlockJig. It should be called in the InsertBlock method instead.
cmwade77:
Ah, my bad for not more clearly explaining what I am trying to do, I am trying to work around some issues in how jigs work with dynamic blocks. Basically, I am dynamically updating the properties of the block, creating a new block that contains that block as an entity, then erasing it as the mouse moves. It works smoothly this way, until I finish the command. I know I have seen this approach before on a website (it's what gave me the idea for this approach), but I can't find it now and so I am trying to recreate it from scratch.
cmwade77:
I actually have figured out a better way around the issues by making the original block not visible, setting the properties, then making it visible again seems to work.
Navigation
[0] Message Index
Go to full version