Jump to content

Recommended Posts

Posted

Hello please and kindly, I need a lisp that explodes the block, put it temporarily on the layers so as to obscure the others (type refedit) I make my changes,

then I think with another routine, I save it with the same name.
Thanks a lot in advance for your time.

Posted

If you explode a block you can't use refedit.

 

This is what I have made a few years ago. Allows you to select multiple blocks you want to edit at one time. zoom to first block and open it into refedit. once done editing that block type command again will refclose with save and zoom to next block with refedit. repeat until all blocks are edited. it doesn't check for duplicate blocks. so if you pick 8 of one block it will cycle though all 8.

 

blkedit-clear clears the list of the remain blocks left to edit.

 

;;----------------------------------------------------------------------------;;
;; CYCLE THROUGH MULTIPLE BLOCK EDITS
(defun C:BLKEDIT (/ SS)
  (CHECK)
  (if (/= (getvar 'refeditname) "")
    (vl-cmdf "_.Refclose" "S")
  )
  (if (or (= SSBE nil) (= (sslength SSBE) 0))
    (progn
      (setq blklst nil)
      (prompt "\nSelect Block")
      (setq SSBE (ssget '((0 . "INSERT"))))
    )
  )
  (if (and (/= SSBE nil) (> (sslength SSBE) 0))
    (progn
      (setq SS (ssadd (ssname SSBE 0)))
      (command "_.Zoom" "OB" SS "")
      (sssetfirst nil SS)
      (vl-cmdf "-REFEDIT" "O" "A" "N")
      (ssdel (ssname SSBE 0) SSBE)
    )
  )
  (ENDCHECK)
)
;;----------------------------------------------------------------------------;;
;; CLEARS BLKEDIT LIST
(defun C:BLKEDIT-CLEAR ()
  (if (/= (getvar 'refeditname) "")
    (vl-cmdf "_.Refclose" "S")
  )
  (setq SSBE nil)
  (princ)
)

 

Posted

Thanks but i meant that refedit is a limited command...i don't know lisp but my idea was explode block

Edit or add elements than with another command redefine the same block .

Posted (edited)

You can add/remove items from a block when in refedit with the command refset. I recommend not exploding blocks because its easier add items or edit it. first you have to retain the block name somehow so you can recall it when making the new block. then you either have to purge the old definition if its a single block or redefine it if their are multiple blocks. and with redefining the block comes a whole new set of problems. does it have the same rotation angle? the one you exploded was at 33.5 degrees but when your redefining it the angle will be 0. this means all the other blocks will rotate -33.5 degrees. Where was the insertion point? If you don't pick the same spot all the other blocks in the drawing will move.

 

 

Edited by mhupp
  • Like 1
Posted

I am with Mhupp here, sounds like it will be a lot simpler to edit the block rather than explode and remake it. What kind of editing to the blocks would you be doing? might help for clarity

  • Like 1
Posted

i make and edit nested blocks, i think is more simple work with the method i described, however if is hard to reproduce with lisp no problem.thanks

Posted

So if you had a LISP, user selects an object in the block to edit, then open that block / nested block in the block editor will that work?

 

Might be a useful little routine, I often edit a block only to find that what I want is a nested block in it, so have to then go and edit the other block - could be a time saver to just click once and not go through blocks to get to the one I want

 

Posted

don't ask why please, I just want to explode the block, edit it and then recreate it. is that possible? thanks

Posted
53 minutes ago, jim78b said:

don't ask why please, I just want to explode the block, edit it and then recreate it. is that possible? thanks

No it's not but if you would attach an small drawing with a before and after example and explain in detail what you need to accomplish we might be able to help you.

There's no way to edit or refedit an exploded block insertion because it wouldn't be a block insertion anymore. Even if you could where would the insertion point be should you need another inserted?

 

If you want to edit or refedit an existing block just use bedit or refedit. To create and modify a new block from an existing one I'd wblock the block out to it's own drawing, edit and rename that drawing, then insert it as a new block in the original drawing.

  • Like 1
Posted (edited)

So your process is:

- Select Block

- Get rotation, insert point, block name

- Explode Block

- Edit 'Block' Entities

- Purge Existing Block

- Make block with old and edited entities

- Rename Block to old block name

 

That is all possible but trying to work out if there is a more efficient way. if you can make a list of the process then an internet search is your friend, you just need to plug it all together:

 

First LISP

- Get the ID of the last entity to be edited (for later)

- Select Block (use entsel and a check that it is a block the was selected)

- Get block insertion data

- Explode Block (use command 'explode'). End this LISP here

 

- Edit Block Entities

 

New Lisp Here

- Purge Existing Block (search for purge, or (command "Purge....) )

- Make block with old and edited entities (loop backwards with 'entlast' or similar to the last edited object from step 1 till you have done all the block objects added to a selection set)

- Create block (internet search is your friend)

- Rename Block to old block name  (internet search is your friend as well)

- Paste the block back in again using the data taken from above

 

This will work if there is only 1 instance of the block in the drawing of course. Multiple instances you would have to ssget by block name to make a list of all the insertion points and rotations for insertion in the last stage, then delete all the existing blocks before the purge.

 

 

Not a simple one but possible... however I think edit the block instead of remaking it will be a lot simpler if that is possible. Full of problems and potential for errors though.

 

 

Should get your nearly there.

Edited by Steven P
  • Like 1
  • Agree 1
Posted

THANKS I understand the difficulty, it was to see if it was possible. I wanted to do this because it seemed like a more flexible way to edit blocks.understand the diff

Posted
2 hours ago, Steven P said:

So your process is:

- Select Block

- Get rotation, insert point, block name

- Explode Block

- Edit 'Block' Entities

- Purge Existing Block

- Make block with old and edited entities

- Rename Block to old block name

Wouldn't the easiest way to start and end with the same block name while editing the entities and preserving the insertion point, scale, layer and other properties be to simply use BEDIT (Command)?  If there's more than one insertion of that block exploding only one would not allow you to purge the name or use the same name for the new block.

  • Thanks 1
Posted
1 minute ago, tombu said:

Wouldn't the easiest way to start and end with the same block name while editing the entities and preserving the insertion point, scale, layer and other properties be to simply use BEDIT (Command)?  If there's more than one insertion of that block exploding only one would not allow you to purge the name or use the same name for the new block.

 

Yes but the OP has a reason that he doesn't want to go that way I think

  • Thanks 1
Posted

Sorry if I'm muddying the waters but what @jim78b is asking seems a bit counter intuitive to me. What is the benefit of not using the block editor?

  • Like 2
Posted

some commands in the blocks do not work, such as axis of symmetry and center of the circles, create nested blocks, command series etc etc

Posted
34 minutes ago, jim78b said:

some commands in the blocks do not work, such as axis of symmetry and center of the circles, create nested blocks, command series etc etc

Wblocking it out to a separate drawing like I proposed in my first reply would give you full access to all commands!

  • Thanks 1
Posted

Shall i create a macro or lisp i suppose?

Posted
9 minutes ago, jim78b said:

Shall i create a macro or lisp i suppose?

Enter WB on the command line will start the wblock command but you should already have a macro. Click the A (AutoCAD) icon in the upper-left and enter wblock in the search bar that appears to the right to see a list of options to start commands. 

 

It should be on the Insert drop-down on the Block panel on the Insert tab of the Ribbon.

  • Thanks 1
Posted

I will study a macro for my idea thanks

Posted (edited)
1 hour ago, jim78b said:

some commands in the blocks do not work, such as axis of symmetry and center of the circles, create nested blocks, command series etc etc

 

Maybe a better solution is to copy the block to a new location explode it. make your changes copy all those entity's go back to the original block and enter refedit.

then replace everything in the block with what you have copied.

 

-edit

keeping it all in the same drawing

Edited by mhupp

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...