Anuncios

The Autodesk Community Forums has a new look. Read more about what's changed on the Community Announcements board.

Strange Block Behavior

Anonymous

Strange Block Behavior

Anonymous
No aplicable

Been working on a pretty large project and just noticed that this critical block that I use in my base drawing is behaving very strangely. Essentially I can no longer edit the block. It just keeps asking for a name to edit. The name, as you can see from the screen shot is random and this block name is also not one that I can insert.

 

Any Ideas? Thanks

 

Capture (1).JPG

john.vellek has embedded your image(s) for clarity

 

 

0 Me gusta
Responder
1.256 Vistas
15 Respuestas
Respuestas (15)

ennujozlagam
Mentor
Mentor

hello, in your command prompt just type BLOCK > give name > select objects > ok and it will be fine. thanks

 

123.jpg





Remember : without the difficult times in your LIFE, you wouldn't be who you are today. Be grateful for the good and the bad. ANGER doesn't solve anything. It builds nothing, but it can destroy everything...
Please mark this response as "Accept as Solution" if it answers your question. Kudos gladly accepted.
0 Me gusta

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

..... Essentially I can no longer edit the block. It just keeps asking for a name to edit. The name, as you can see from the screen shot is random and this block name is also not one that I can insert.

.... 


 

That's an anonymous Block, involving something variable such as Parameters.  To find out the underlying Block name, so you can choose it in BEDIT or INSERT, put this in at the command line:

 

(vla-get-EffectiveName (vlax-ename->vla-object (car (entsel))))

 

and pick on the Block.

Kent Cooper, AIA
0 Me gusta

Anonymous
No aplicable

I found a lisp routine (by Fenton Webb) with an internet search that seems to work, I was able to use it to rename the block to "TESTBLOCK" Now it will open in block editor. Replace "TESTBLOCK" with whatever name you want. Suggest you try renaming your original name for that block with "old" at the end, then you should be able to use this to rename the offending block to whatever you called it before it "broke". Hope it helps. "Fixed" block attached.

 


(defun c:any_blk ()
 (vl-load-com)
 (setq a_app  (VLAX-GET-ACAD-OBJECT)
    a_doc  (vla-get-ActiveDocument a_app)
    a_blks (vla-get-blocks a_doc)
    blk    (vla-add a_blks (vlax-3d-point '(0 0 0)) "*T")
 )
 (vla-addcircle blk (vlax-3d-point '(0 0 0)) 3)
)

(defun c:ren_blk ()
 (vl-load-com)
 (setq a_app  (VLAX-GET-ACAD-OBJECT)
    a_doc  (vla-get-ActiveDocument a_app)
    a_blks (vla-get-blocks a_doc)
    blk    (vla-item a_blks "*U0")
)
 (vla-put-name blk "TESTBLOCK")
)

0 Me gusta

Anonymous
No aplicable

Kent,

Thanks for the reply. I tried that and it returns "*UO" but I am still unable to edit or insert the block. I did run a purge on my blocks before I realized that this had happened and did purge what was the original block . Could that be the issue?

 

I have 13,452 of these blocks in my base drawing. They were originally all just the same block but now each of the 13,452 blocks are apparently "anonymous", as you mention, and each is it's own unique anonymous block. 

 

Thanks for any help

0 Me gusta

Anonymous
No aplicable

Thanks for the reply. What if I have 13,452 of these blocks in one drawing and they all need to be the same block? Each one appears to be anonymous, as another reply has called them, and each one appears to be unique.

 

I opened what you provided and there are a dynamic block features that are missing. I'm guessing I wont be getting these back...

0 Me gusta

Anonymous
No aplicable

13,452...Ouch...sorry it didn't work. Maybe there is a lisp or AutoCAD VBA expert out there who could create something that would work, sadly, that isn't me. Maybe a for-each-next loop, using a file copy that has only the offending blocks in it, using something like

 

for each block in thisdrawing

if block.name <> "your desired name" then

with block

.name = "your desired name"

end with

end if

next block

 

At least this is the way I would set up a sub in Excel VBA to loop thru a sequence of objects and perform a change on each one, no idea how to do it in AutoCAD VBA, or even if it can be done....no idea if any of your dynamic functionality would be there or not even if the renaming works....good luck.

 

0 Me gusta

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

.... 

I have 13,452 of these blocks in my base drawing. They were originally all just the same block ....


 

If you either still have the original "same" Block definition [other Messages sound like you don't] or can make a new definition of it by Exploding a copy of one of the 13,452 set at 0 rotation and a scale of 1, and using its pieces for a redefinition, then you should be able to use BlockReplace.lsp -- available >here< -- to change them all to the new same Block definition.  Use its BRS command, give it the new Block name, and select all the 13,452 [or do it in several passes with fewer at a time].  There are other routines out there you can Search for, to replace existing Block references with other Blocks.

Kent Cooper, AIA
0 Me gusta

Anonymous
No aplicable

When I try this lisp it causes the block that I select to disappear. I also tried using BLOCKREPLACE and when I select the block to be replaced it says invalid characters in block name. 

 

edit: I should add that while these were dynamic blocks the properties and settings of the dynamic features were exactly the same for all of them

0 Me gusta

cadffm
Consultant
Consultant

@Anonymous please read&test the whole answer of @Kent1Cooper answer:

 

".. or can make a new definition of it by Exploding a copy of one of the 13,452 set at 0 rotation and a scale of 1, and using its pieces for a redefinition, then you should be able to use BlockReplace.lsp.."

 

Means: Copy one of them from<using osnap basepoint of this new blockreference>

to 0,0,0

>Optional> Zoom to the blockreference (use command Zoom, option Objects, objectselection LAST)

Explode them (if you didn't zoom to the object, use object-selection LAST)

Start command BLOCK, use insertion point 0,0  (if you didn't zoom to the object, use object-selection PREVIOUS)

 

>> But you can also use the ren_blk from the other answer above.. <<

 

NOW you can use the BRS command (with the new "named" Blockdefinition).

 

 

Sebastian

0 Me gusta

beyoungjr
Advisor
Advisor

Hi,

Anonymous block handling has been a topic in these forums for many years.

Ideas already offered may help but you should read up on how to deal with them since you are experiencing such a huge load of them.

 

Maybe start with these two...

https://forums.autodesk.com/t5/dynamic-blocks/u-anonymous-block-handles/td-p/3142278

and

https://forums.autodesk.com/t5/autocad-forum/block-name/td-p/4781187

 

Cheers,

Blaine

 


Blaine Young
Senior Engineering Technician, US Army

0 Me gusta

Kent1Cooper
Consultant
Consultant

Quickie thoughts....

 

Are you using the BRS command, not the BRA command?  BRA asks you to pick one instance of a Block, and it replaces all those with the same name, which wouldn't apply in your case.

 

I haven't played with that in dynamic Blocks, nor looked closely at the code recently, so there may be something about it that's not right for those.

Kent Cooper, AIA
0 Me gusta

Anonymous
No aplicable

Okay, it's sorta working.  I did the following:

1. Copied one of the anonymous blocks to 0,0,0

2. Exploded

3. Re-create the block with new name and basepoint of 0,0

When I run the BRS command it does replace all of the selected anonymous blocks with the newly created block, but it puts them all exactly on top of one another. 

 

Care to try? 

 

 

0 Me gusta

cadffm
Consultant
Consultant

 

Excuse my late reply, but it is already here 01:30 AM, lol.


Sorry, but this is another situation, your statement sounded as only the name changed, but it wasn't.
"I have 13,452 of these blocks in my base drawing. They were originally all just the same block"

 

For each block the objects are the same (i didn't check this, but it looks like that),
but for every block the objects are on different positions..so each block is different to the others.


In this case you can have to go another (tool) way:
Explode all, erase all objects except the same one of each block - for example the LINE.
Replace the Line with a Blockreference.


If you searching for a tool in the forum you will find a lot.
"convert circle to block" or "point to block" or similar topics.

A sample attached.
baseplanX= replaced with your new non-dynamic block (hint: In your arrays in the right, you are using the "*_old" dynamic block)
baseplanY= replaced with your "*_old" dynamic block.

Sebastian

0 Me gusta

Kent1Cooper
Consultant
Consultant

@Anonymous wrote:

....

1. Copied one of the anonymous blocks to 0,0,0

2. Exploded

3. Re-create the block with new name and basepoint of 0,0

... it does replace all of the selected anonymous blocks with the newly created block, but it puts them all exactly on top of one another. 

....


 

[By the way, there's no need to move one to 0,0 and then use 0,0 as the insertion base point in defining a new Block.  You can specify an insertion base point for a Block at any  location [presumably a logical place in relation to the drawn elements], regardless of where it is in relation to the drawing origin.]

 

Since, as pointed out, those are not just differently-named versions of the same Block definition, but rather each has its insertion base point in a different relationship to its drawn content, and all have their insertion points at the same place, then yes, replacing them with BRS will put the new Blocks all at the same place.

 

Here's a way to do it, particular to your situation:  Copy one of the Blocks somewhere, Explode it, and define it as a new Block [here with the name "TEST" but edit for whatever name suits you], with its insertion base point defined at the Mid-of-2 point between the extreme corners [i.e. in the middle of the extents of the pieces].  Then use this:

 

(defun C:TEST (/ ss n blk) ; edit command name
  (setq ss (ssget '((0 . "INSERT") (2 . "`**")))); only anonymous Blocks
  (repeat (setq n (sslength ss))
    (setq blk (ssname ss (setq n (1- n))))
    (vla-getboundingbox (vlax-ename->vla-object blk) 'minpt 'maxpt)
    (command "_.insert" "test" "_none" ; EDIT name
      (mapcar '/ ; find midpoint between corners of its bounding box
        (mapcar '+ (vlax-safearray->list minpt) (vlax-safearray->list maxpt))
        '(2 2 2)
      ); mapcar
      "" "" ""
      "_.erase" blk ""
    ); command
  ); repeat
); defun
(vl-load-com)

That's in simplest terms, without all the usual enhancements, but those can be added easily enough.

 

 

I tried it successfully in a limited area  of your sample drawing.

Kent Cooper, AIA
0 Me gusta

Anonymous
No aplicable

In the interest of time I went ahead and just rebuilt the layout. I actually found 6 errors with the original drawing so it was actually beneficial to do it that way anyway. Thanks for the help everyone. 

0 Me gusta