Jump to content
Ryszard

Undefine, Redefine and localized version of Autocad

Recommended Posts

Ryszard

Hello. I can't complete a simple task which requires of using Undefine and Defun functions to cover builtin function in localized Autocad 2010.

I need to replace PASTEBLOCK. In my version PASTEBLOCK function can be represented with two commands: WKLEJBLOK (localized) and _PASTEBLOCK (generic). Both do the same.

Now, if I do "undefine WKLEJBLOK" (it is not proper command, just to show an issue), both functions (WKLEJBLOK, _PASTEBLOCK) are no longer valid.

Now if I make a defun C:WKLEJBLOK, WKLEJBLOK works but _PASTEBLOCK is still not valid (unknown).

The problem with WKLEJBLOK and shortcut or menu access are that both tries to launch _pasteblock, not WKLEJBLOK.

So I have tried to do this in other way. After recovered both with "redefine" I did "undefine _PASTEBLOCK" and "defun C:_PASTEBLOCK". It didn't work - both commands are invalid now.

What do I do to have both WKLEJBLOK and _PASTEBLOCK covered with custom lisp? WKLEJBLOK doesn't seem to be an alias (not in acad.pgp).

Any idea? Or maybe it is not possible this way?

Share this post


Link to post
Share on other sites
Ryszard

Well, I couldn't find a way to cover the builtin command so I just created new command and customized menu and shortcut.

Share this post


Link to post
Share on other sites
tombu

Not sure what your WKLEJBLOK and _PASTEBLOCK functions do, but the AutoCAD command PASTEBLOCK is commonly used and will be missed by your users. I added a Paste drop-down in our Ribbon with five options including "Paste as Group". You could simply add a drop-down that has all your Paste options in it.

 

Have to wonder why you're using the underscore that way. As AutoCAD is used around the world and some of the command names are different in other places the underscore is used to "Translates commands and options that follow from the localized name to the global name." A period "Allows you to access a standard command even if it was undefined using the UNDEFINE command." So for me in AutoCAD PASTEBLOCK, _PASTEBLOCK, .PASTEBLOCK, and ._PASTEBLOCK all invoke the PASTEBLOCK command. Both my installed "Paste as Block" and Shortcut Keys macros use the underscore → ^C^C_pasteblock

https://knowledge.autodesk.com/support/autocad-lt/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-LT/files/GUID-DDDB6E26-75E1-4643-8C6A-BEAEBA83A424-htm.html

Share this post


Link to post
Share on other sites
Ryszard

WKLEJBLOK and _PASTEBLOCK do exactly what You have said - it pastes objects from clipboard as new randomly named block.

PASTEBLOCK (without underscore) exists only in english version of Autocad, at least until 2010. Didn't use any newer version so I don't know if this policy changed or not. WKLEJBLOK is a genuine command in my localized version of Autocad, and it is the same as PASTEBLOCK in english version of Autocad. I am totally against translating commands if You ask me, it creates new issues, and divide people searching for help and make additional hardship for them.

 

_PASTEBLOCK do the same as a PASTEBLOCK, and _.PASTEBLOCK do the same as PASTEBLOCK as well, with exception that You can't cover _.PASTEBLOCK.

Shortcut ^C^C_pasteblock represented by CTRL+SHIFT+V is internally launching _PASTEBLOCK, but in command line it shows that WKLEJBLOK has been launched. Doesn't matter.

If i undefine and redefine WKLEJBLOK as a new custom function then _PASTEBLOCK no longer works, so shortcut no longer works as well. I need to typing WKLEJBLOK each time from command line. I can't undefine _PASTEBLOCK, but can't redefine it. It doesn't show any error, but it doesn't work as well.

 

As I said in my own reply, I couldn't fine any helpful article about this issue so I left _PASTEBLOCK and WKLEJBLOK intact, and created new function and changed shortcut for it.

Share this post


Link to post
Share on other sites
Ryszard

I don't know if this is common policy here, but I can't reedit my own posts ... I made a small mistake above:

"I can't undefine _PASTEBLOCK, but can't redefine it.". Should be "I can undefine, but can't redefine".

Share this post


Link to post
Share on other sites
tombu
I don't know if this is common policy here, but I can't reedit my own posts ... I made a small mistake above:

"I can't undefine _PASTEBLOCK, but can't redefine it.". Should be "I can undefine, but can't redefine".

 

Please read the AutoCAD Knowledge Base link:

About Special Control Characters in Command Macros

https://knowledge.autodesk.com/support/autocad-lt/learn-explore/caas/CloudHelp/cloudhelp/2017/ENU/AutoCAD-LT/files/GUID-DDDB6E26-75E1-4643-8C6A-BEAEBA83A424-htm.html

There's a use for those Control Characters, but they don't create new commands. You will find PASTEBLOCK, but not _PASTEBLOCK in AutoCAD Help's Command list:

http://help.autodesk.com/view/ACD/2019/ENU/?page=commands&q=P*

It's not a separate command.

 

You should be able to both undefine and redefine the PASTEBLOCK command. Assuming you're trying to avoid the bloat from users who explode these blocks and neglect to purge them educating them would be a better option.

 

The custom macro "Paste as Group" solves that problem at: http://www.cadtutor.net/forum/showthread.php?103102-COPYBASE-w-0-0&p=699987&viewfull=1#post699987

It Pastes as Block, explodes the Block, creates a group of the exploded objects, then purges that block leaving only the group.

Share this post


Link to post
Share on other sites
SLW210
I don't know if this is common policy here, but I can't reedit my own posts ... I made a small mistake above:

"I can't undefine _PASTEBLOCK, but can't redefine it.". Should be "I can undefine, but can't redefine".

 

You can't edit posts until you have 10 relevant posts.

Share this post


Link to post
Share on other sites
Ryszard

There's a use for those Control Characters, but they don't create new commands. You will find PASTEBLOCK, but not _PASTEBLOCK in AutoCAD Help's Command list.

It's not a separate command.

 

I always have been convinced that command with _ special character is equivalent to a command without _. In english version both have the same name, let's say general name. In localized version the one without underscore has local name which differs from general name. I knew all that till now.

That i still can't understand why does define method not work (described above).

I see that WKLEJBLOK has made some mess here so I will use general name to repeat the issue.

I have got script written by Kent Cooper for english version which is the replacement for original PASTEBLOCK that allows the client to give a name to a pasting block.

So no longer random names like AC$AABBCC00FF.

The author assumed that client will replace the original PASTEBLOCK with the new one.

This script didn't work in my Autocad because there is no PASTEBLOCK here but WKLEJBLOK. So it just created new command PASTEBLOCK, which for Autocad was a completely new command.

So i modified the script to replace WKLEJBLOK which is translated command to PASTEBLOCK. And connected to _PASTEBLOCK.

 

Let's just say I have english version and run script without modification.

Script undefined PASTEBLOCK, and defined it as custom. That is all, no additional steps.

But it didn't work here as it should. I got covered version of PASTEBLOCK, ok, I can run it typing full name in CMDL, but _PASTEBLOCK is not working anymore. Autocad warns me that _PASTEBLOCK doesn't exists, command unknown etc. So the key shortcut is not working as well because it is connected to _PASTEBLOCK, not PASTEBLOCK (important underscore character here).

The _PASTEBLOCK will be recognized as proper command again if I return to original PASTEBLOCK function with redefine command.

I don't know if this is an issue in localized versions of Autocad, or maybe only 2010, but it seems that after undefine command has been used the connection beetween _PASTEBLOCK and PASTEBLOCK is shattered.

 

Maybe it is possible to cover built-in function without undefine command, but I didn't test it. I have found a solution to just create separate command and modify user interface.

Share this post


Link to post
Share on other sites
tombu

Kent Cooper does some great code, he's #2 in the Top Solution Authors right now on AutoCAD's Lisp forum where he's been for a long time. Can you post the link where he posted the code? Seeing the code and what it was intended to do would help us understand what you're trying to do.

Share this post


Link to post
Share on other sites
tombu
Posted (edited)

I think I found it at → http://cadtips.cadalyst.com/enforce-standards/pasteblock-new-name

It uses

(command "_.undefine" "PASTEBLOCK")

to undefine the PASTEBLOCK command not _PASTEBLOCK which isn't even an AutoCAD command.

It should work fine as he posted it.

 

This may help you understand:

Enter _LINE at the command line, then hit Esc, then hit the ↑up arrow to display the last command and you will see LINE without the underscore as it's not part of the command.

Edited by tombu
tried to make it clearer

Share this post


Link to post
Share on other sites
Ryszard

;; To preserve AutoCAD's PasteBlock command definition, remove the following lines:

(setq cmde (getvar 'cmdecho))

(setvar 'cmdecho 0)

(command "_.undefine" "PASTEBLOCK")

(setvar 'cmdecho cmde)

(setq cmde nil)

;; and Redefine PasteBlock if necessary, CHANGE the COMMAND NAME in the

;; next line of code to something appropriate [it will then NOT be invoked by

;; Ctrl+Shift+V], and adjust descriptive comments above and prompt at end.

(defun C:PASTEBLOCK (/ newname cmde); new definition

 

Part of code. I can't check if it will work in english version. It doesn't here, but I have other names for functions.

I have commented those lines as advised by Kent.

Share this post


Link to post
Share on other sites
tombu
I can't check if it will work in english version. It doesn't here, but I have other names for functions.

I have commented those lines as advised by Kent.

 

Sorry, I have no knowledge of anything other than the US English version. Could there be another name for PASTEBLOCK in your version? That may be what you need to undefine.

 

It's understandable not to put personal information online, but country or local version may get a response from someone more familiar with your situation. There's users here from around the globe.

Share this post


Link to post
Share on other sites
Ryszard

Everything is in the first post. WKLEJBLOK is the translated replacement of PASTEBLOCK. If You say that this code works ok on english version then

it has to be a problem of polish version. When the WKLEJBLOK is undefined, the _PASTEBLOCK is undefined as well, and stays as undefined even if define WKLEJBLOK as a custom function. I don't know if there is any reason to continue this thread - I didn't get a solution how to cover function successfully but I have workarounded it (also in this thread).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×