Author Topic: rename block with preview  (Read 20936 times)

0 Members and 1 Guest are viewing this topic.

Sam

  • Bull Frog
  • Posts: 201
rename block with preview
« on: July 31, 2012, 03:36:48 AM »
Dear All,

It's Possible rename block with preview
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #1 on: July 31, 2012, 03:51:26 AM »
I'm assuming you mean you'd like a dialog for renaming blocks - where there's a preview of the block. Unfortunately it's not exactly too easy to do in Lisp & DCL. In this case you need to generate a SLD file from the block, then load that onto the DCL dialog's image tile (for each block selected). This might take a while, since you'll first need to insert each block in turn in a blank space, zoom to object, and call the mslide command to generate the SLD file for that block. Only then can you run the dialog.

An alternative would be to install ODCL (it has a built-in tile which previews blocks).
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Sam

  • Bull Frog
  • Posts: 201
Re: rename block with preview
« Reply #2 on: August 01, 2012, 02:06:30 AM »
I'm assuming you mean you'd like a dialog for renaming blocks - where there's a preview of the block. Unfortunately it's not exactly too easy to do in Lisp & DCL. In this case you need to generate a SLD file from the block, then load that onto the DCL dialog's image tile (for each block selected). This might take a while, since you'll first need to insert each block in turn in a blank space, zoom to object, and call the mslide command to generate the SLD file for that block. Only then can you run the dialog.

An alternative would be to install ODCL (it has a built-in tile which previews blocks).
Dear Sir,
thx...
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #3 on: August 01, 2012, 05:36:36 AM »
Glad to help. Attached is a version  which uses ODCL. Note you'll need to install the ODCL Runtime version 6, either that or the Studio if you want to create your own ODCL dialogs. You don't need both as the Studio includes the runtime already.

Save both files into a folder on your support path & have the LSP file loaded. Then the command is RenBlocks. It should open a modeless dialog (i.e. while it's open you can still do other things in the drawing) with a list of block names and a preview. Below the preview is a field to type the new block name and a rename button.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: rename block with preview
« Reply #4 on: August 01, 2012, 05:57:32 AM »
Thanks irneb for the nice App.

It worked in Cad 2010 but didn't in Cad 2013 .

Quote
Command: RENBLOCks
Unknown command "OPENDCL".  Press F1 for help.
; error: no function definition: DCL_PROJECT_LOAD

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #5 on: August 01, 2012, 06:05:31 AM »
I think you need ODCL version 7 for 2013. I've not tested it, but I think you need not upgrade the ODCL file itself - it should still work on newer versions.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Tharwat

  • Swamp Rat
  • Posts: 710
  • Hypersensitive
Re: rename block with preview
« Reply #6 on: August 01, 2012, 06:26:20 AM »
I think you need ODCL version 7 for 2013. I've not tested it, but I think you need not upgrade the ODCL file itself - it should still work on newer versions.

You're right , it works nicely now after downloading the latest version .  :wink:

Thank you .

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #7 on: August 01, 2012, 07:07:42 AM »
Glad it works! Just sorry there needs to be an addon to get a decent UI for acad from lisp  :pissed: . IMO ODCL should form part of base acad, replacing the 20 year old DCL system.

I tried using the Block List instead of a normal listbox, since it shows a preview directly inside the listbox (similar to Design Center). But I couldn't find a way to reset the lisbox after renaming the block - it would still display the old name  :| . Perhaps I've missed something.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: rename block with preview
« Reply #8 on: August 01, 2012, 08:01:34 AM »
Should I instal OpenDCL Or loading *.arx is enough?

kruuger

  • Swamp Rat
  • Posts: 633
Re: rename block with preview
« Reply #9 on: August 01, 2012, 08:07:43 AM »
Should I instal OpenDCL Or loading *.arx is enough?
loading is enough. but you need also Runtime.Res.dll (if i remember correct)
dll needs to be under autocad paths.
kruuger

stevesfr

  • Newt
  • Posts: 54
Re: rename block with preview
« Reply #10 on: August 01, 2012, 09:10:36 AM »
Glad to help. Attached is a version  which uses ODCL. Note you'll need to install the ODCL Runtime version 6, either that or the Studio if you want to create your own ODCL dialogs. You don't need both as the Studio includes the runtime already.

Save both files into a folder on your support path & have the LSP file loaded. Then the command is RenBlocks. It should open a modeless dialog (i.e. while it's open you can still do other things in the drawing) with a list of block names and a preview. Below the preview is a field to type the new block name and a rename button.

Can not get the lisp to work.   Both files are in support path.   OpenDCL is loaded.  Block directory is in support path.   popdown dialog opens, but is blank with no block names or previews available. What am I doing wrong or what have I failed to do.  (RenBlocks.lsp loaded of course ok.)
TIA, Steve
Can't remember what I'm supposed to forget.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #11 on: August 01, 2012, 09:20:11 AM »
This is to rename blocks already in the current drawing, not to rename DWG files in a folder.

My understanding from the OP was that he'd like to see a preview of the block he wants to rename (unlike only showing its name in the normal rename dialog).

Are you looking for something to allow renaming DWG files in your block library? Or rename the blocks contained inside DWG files in your library? The 1st would be reasonably simple, the 2nd would require some ObjectDBX.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

stevesfr

  • Newt
  • Posts: 54
Re: rename block with preview
« Reply #12 on: August 01, 2012, 09:51:10 AM »
This is to rename blocks already in the current drawing, not to rename DWG files in a folder.

My understanding from the OP was that he'd like to see a preview of the block he wants to rename (unlike only showing its name in the normal rename dialog).

Are you looking for something to allow renaming DWG files in your block library? Or rename the blocks contained inside DWG files in your library? The 1st would be reasonably simple, the 2nd would require some ObjectDBX.

I am clear now.... all is OK.  thanks for clarifications.
Steve
Can't remember what I'm supposed to forget.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #13 on: August 01, 2012, 10:20:33 AM »
Glad you to help.

If you want to see something working with ODCL and external block libraries, see Tim's block library manager as an example: http://www.theswamp.org/index.php?topic=32391.30
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: rename block with preview
« Reply #14 on: August 01, 2012, 10:53:28 AM »
Should I instal OpenDCL Or loading *.arx is enough?

You should install, then it will load automatically without changing your AutoCAD configuration.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: rename block with preview
« Reply #15 on: August 01, 2012, 10:57:27 AM »
I tried using the Block List instead of a normal listbox, since it shows a preview directly inside the listbox (similar to Design Center). But I couldn't find a way to reset the lisbox after renaming the block - it would still display the old name  :| . Perhaps I've missed something.

Did you try the (dcl_BlockList_Reset) method?

This would make a nice OpenDCL sample. Do you mind if I steal it? I would change the name to RENAMEBLOCK and make a few small changes. For example, I would put the initialization code inside OnInitialize instead of in the main function after the (dcl_Form_Show) call.

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: rename block with preview
« Reply #16 on: August 01, 2012, 11:09:17 AM »
Should I instal OpenDCL Or loading *.arx is enough?

You should install, then it will load automatically without changing your AutoCAD configuration.

IT do not install 3rd party programs so Is there a way to use ODCL without install 3rd party application?


jbuzbee

  • Swamp Rat
  • Posts: 851
Re: rename block with preview
« Reply #17 on: August 01, 2012, 11:18:03 AM »
Dude, I am so with you - but OpenDCL is soo different. Owen is the the MAN!  He has taken on this free programming to heart and is commited to continuing the developmont of this OPEN DEVOLPMENT PLATFORM.

Go Owen!
James Buzbee
Windows 8

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #18 on: August 01, 2012, 11:57:45 AM »
IT do not install 3rd party programs so Is there a way to use ODCL without install 3rd party application?
It is possible to arxload the OpenDCL runtime instead of letting it load itself after installing. There's still an issue regarding this though: you still need all the required files (ARX/DLL) and the relevant settings like support paths - basically you need to manually change stuff which the install would have done for you.

Also if you manually arxload, you need to figure out which ARX you need to load for your acad version and 32/64 bit. This is done automatically for you by the OPENDCL command. So it makes you programming more complex than it would otherwise be - and it might cause unforeseen errors. That's probably why Owen's advising you against going this route. Also, I'm not sure if licensing would permit you to do this - you'd probably need to ensure you copy all the files from the install MSI (including any licensing stuff).

Did you try the (dcl_BlockList_Reset) method?
I did yes, but it had no effect. I added it as a final call in the c:RenBlocks_frmRenBlocks_btnRen_OnClicked event (i.e. after the rename happened). But the list would still show the old name - and then clicking on the old blockname would not update the preview tile.

As I understand the reset idea (from ODCL's help on the function), it reverts a blocklist from displaying an external DWG's blocks to displaying the current DWG's blocks. And for me it seems that's exactly what it does and no more - i.e. if it's already showing the current DWG's content, it doesn't "reset" to re-read the content.

This would make a nice OpenDCL sample. Do you mind if I steal it?
Sure any time! I don't mind ... especially as I've given the code away on here already  ;)

I would change the name to RENAMEBLOCK and make a few small changes. For example, I would put the initialization code inside OnInitialize instead of in the main function after the (dcl_Form_Show) call.
Good point! That would be a lot better, probably also minimize on errors!  :kewl:
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

owenwengerd

  • Bull Frog
  • Posts: 451
Re: rename block with preview
« Reply #19 on: August 01, 2012, 02:06:34 PM »
Did you try the (dcl_BlockList_Reset) method?
I did yes, but it had no effect. I added it as a final call in the c:RenBlocks_frmRenBlocks_btnRen_OnClicked event (i.e. after the rename happened). But the list would still show the old name - and then clicking on the old blockname would not update the preview tile.

Looking at the code, it should refresh the list from scratch, so I would expect changes to be reflected. There may be a bug somewhere causing it to not complete the reset because of an error. I'll have a look when I get a minute. If you still have the code, you might check the return value of the Reset function to see if it returns T or NIL. I'll bet it returns NIL (indicating an error).

Sam

  • Bull Frog
  • Posts: 201
Re: rename block with preview
« Reply #20 on: August 02, 2012, 03:25:35 AM »
Glad to help. Attached is a version  which uses ODCL. Note you'll need to install the ODCL Runtime version 6, either that or the Studio if you want to create your own ODCL dialogs. You don't need both as the Studio includes the runtime already.

Save both files into a folder on your support path & have the LSP file loaded. Then the command is RenBlocks. It should open a modeless dialog (i.e. while it's open you can still do other things in the drawing) with a list of block names and a preview. Below the preview is a field to type the new block name and a rename button.

Dear sir,

thankssssssssssssss , save my time thxxxxxx
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

Sam

  • Bull Frog
  • Posts: 201
Re: rename block with preview
« Reply #21 on: August 02, 2012, 03:31:17 AM »
dear sir,

thx for u r effort,

one problem i rename same name no alert come ( example : duplicate name or block already exist)

sorry for my bad english
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #22 on: August 03, 2012, 11:02:20 AM »
Sorry, yes - bad of me to not catch that!

Try this 2nd version: Added an alert if the name already exists. It also now incorporates a search field so you can filter blocknames by a few characters inside their name. Followed suit with Owen's suggestion to move intialization into an initialize event (also included defuns inside this so the defuns are only created once the dialog is displayed).

Edit: See next post for further fix.
« Last Edit: August 03, 2012, 11:20:15 AM by irneb »
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #23 on: August 03, 2012, 11:19:46 AM »
And a 3rd version to actually work if you have more than 1 DWG open at a time. It uses the On Document Activated event to reload the block-name list. Also allows for you to add the RenBlocks command to an autoload statement instead of forcing you to have it loaded in all DWG manually.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Sam

  • Bull Frog
  • Posts: 201
Re: rename block with preview
« Reply #24 on: August 04, 2012, 01:40:42 AM »
And a 3rd version to actually work if you have more than 1 DWG open at a time. It uses the On Document Activated event to reload the block-name list. Also allows for you to add the RenBlocks command to an autoload statement instead of forcing you to have it loaded in all DWG manually.
Dear Sir,

Thx.. sorry for inconvenience

one problem i rename same name (duplicate name)
example (already block name is 1st floor & i rename second block same name no alert r comes)

some error are new version
Code: [Select]
Command: RENBLOCKS

OpenDCL Runtime [7.0.0.6] loaded
; error: ADS request error
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

Lee Mac

  • Seagull
  • Posts: 12912
  • London, England
Re: rename block with preview
« Reply #25 on: August 05, 2012, 07:07:12 PM »
This thread inspired me to attempt to create a block preview using standard DCL:-)

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #26 on: August 06, 2012, 04:19:36 AM »
Dear Sir,

Thx.. sorry for inconvenience

one problem i rename same name (duplicate name)
example (already block name is 1st floor & i rename second block same name no alert r comes)

some error are new version
Code: [Select]
Command: RENBLOCKS

OpenDCL Runtime [7.0.0.6] loaded
; error: ADS request error
Could you perhaps attach a sample DWG file with a block causing this? Also which version of ACad are you using?

I can't seem to duplicate the error.
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Sam

  • Bull Frog
  • Posts: 201
Re: rename block with preview
« Reply #27 on: August 06, 2012, 05:45:17 AM »
Dear Sir,

Thx.. sorry for inconvenience

one problem i rename same name (duplicate name)
example (already block name is 1st floor & i rename second block same name no alert r comes)

some error are new version
Code: [Select]
Command: RENBLOCKS

OpenDCL Runtime [7.0.0.6] loaded
; error: ADS request error
Could you perhaps attach a sample DWG file with a block causing this? Also which version of ACad are you using?

I can't seem to duplicate the error.
dear sir,
i am using autocad 2012 & windows 7 32 bit
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #28 on: August 06, 2012, 06:03:40 AM »
That file seem to work perfectly for me (Acad 2012 on Win7-64 bit with ODCL 6.0.2.5)
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

Sam

  • Bull Frog
  • Posts: 201
Re: rename block with preview
« Reply #29 on: August 06, 2012, 06:35:16 AM »
That file seem to work perfectly for me (Acad 2012 on Win7-64 bit with ODCL 6.0.2.5)
dear sir,
thx for help
problem solve because some utility crash with this lisp, i unload all utility work is fine

thxxx again u save my working times
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

irneb

  • Water Moccasin
  • Posts: 1794
  • ACad R9-2016, Revit Arch 6-2016
Re: rename block with preview
« Reply #30 on: August 06, 2012, 10:15:45 AM »
If not too much trouble, could you say what utility it was which crashes this? Perhaps it's something which doesn't work too well with ODCL.

Anyhow:
Looking at the code, it should refresh the list from scratch, so I would expect changes to be reflected. There may be a bug somewhere causing it to not complete the reset because of an error. I'll have a look when I get a minute. If you still have the code, you might check the return value of the Reset function to see if it returns T or NIL. I'll bet it returns NIL (indicating an error).
You seem to be correct. There might have been something wrong in the DWG I tested - causing the reset to error.

I've made a 2nd command RenBlocks2 which uses a block-list instead of a generic list. Also made it so it reselects the renamed block after the rename - not sure if it's correct to do so though  :| . BTW, the generic list allows for simply passing the string to be selected, while I need to find out which index to select in the block-list (and seeing as it's sorted that's not a trivial task). Also I now left the generic list, since the block-list has no means of filtering by wildcard.

Fixed another issue in the generic-list: Omitted block names coming from inside xrefs. That was rather silly of me!  :-[
Common sense - the curse in disguise. Because if you have it, you have to live with those that don't.

HasanCAD

  • Swamp Rat
  • Posts: 1421
Re: rename block with preview
« Reply #31 on: August 06, 2012, 10:49:30 AM »
Great irneb

Sam

  • Bull Frog
  • Posts: 201
Re: rename block with preview
« Reply #32 on: August 06, 2012, 11:07:09 AM »
If not too much trouble, could you say what utility it was which crashes this? Perhaps it's something which doesn't work too well with ODCL.

Anyhow:
Looking at the code, it should refresh the list from scratch, so I would expect changes to be reflected. There may be a bug somewhere causing it to not complete the reset because of an error. I'll have a look when I get a minute. If you still have the code, you might check the return value of the Reset function to see if it returns T or NIL. I'll bet it returns NIL (indicating an error).
You seem to be correct. There might have been something wrong in the DWG I tested - causing the reset to error.

I've made a 2nd command RenBlocks2 which uses a block-list instead of a generic list. Also made it so it reselects the renamed block after the rename - not sure if it's correct to do so though  :| . BTW, the generic list allows for simply passing the string to be selected, while I need to find out which index to select in the block-list (and seeing as it's sorted that's not a trivial task). Also I now left the generic list, since the block-list has no means of filtering by wildcard.

Fixed another issue in the generic-list: Omitted block names coming from inside xrefs. That was rather silly of me!  :-[
dear sir nice
some block preview & some block not previw
Every time we waste electricity, we put our planet's future in the dark. Let's turn around our attiude and start saving power and our planet, before it's too late
http://www.theswamp.org/donate.html

Dommy2Hotty

  • Swamp Rat
  • Posts: 1127
Re: rename block with preview
« Reply #33 on: August 06, 2012, 11:38:27 AM »
I run this from a pulldown, no preview, but just pick the one you want to rename, and viola.
I'm sure I got it from TheSwamp from someone:
Code: [Select]
(defun c:BlockRename ()
  (vl-load-com)
  (setq bname (vla-get-EffectiveName (vlax-ename->vla-object (car(entsel "\nSelect block: ")))))
  (command "rename" "block" bname pause)
  );DEFUN

Bhull1985

  • Guest
Re: rename block with preview
« Reply #34 on: September 24, 2013, 10:56:07 AM »
Irneb would this at all be possible to modify to include a 2nd list_box, required for dynamic blocks with visibility states?
So that the first list_box will be populated with the block names and upon selection the 2nd list_box would be populated with the selected's visibility states?
That would be...amaazzzing!

jonathanpiette

  • Guest
Re: rename block with preview
« Reply #35 on: February 06, 2015, 01:14:42 PM »
Dear All,

It's Possible rename block with preview

YES ITS POSSIBLE without any LISP.  in 2014, I'm using DESIGN CENTER (Ctrl-2) on one side of the screen, Select Blocks , Right-Clic on View/Large... OR Right-clic on View/Preview

Then I use command RENAME on the other side of the screen to rename what I see in Design Center. Y

You have to close your RENAME windows everytime you want to change the bloc preview on DC but it's better than nothing!