Wblock not work like autocad

Dear All....After use wblock command, object that selected during wblock command disappear.So this work like cut. I want this work like copy command.Refer to this image :http://www.4shared.com/file/84713612/b71827ea/wblock.html

Comments

  • Yes, it works slightly different the old 'oops' command is needed to bring back the selected entities ..., much like in the create block procedure.

  • Hi Louis,So what is the step by step to get the same thing like I work in Acad ?Please give me the step by step...Thanks

  • OK, I understand...After run wblock command I need to execute "oops" in the command line.Is there any automatic mode that work lke acad ?So I dont need to run "oops".Thank You !!!

  • By using Lisp, you can create a new command that is a combination of two or more built-in commands. Just include a WHILE...CMDACTIVE...PAUSE function between the commands, to let the previous one finish before the next one starts.I think this will do what you want:

    (defun c:WW ()(command "wblock")(while (> (getvar "cmdactive") 0) (command pause))(command "oops"))

    The new command is WW. You can change that to anything you want.

  • Hi Anthony,Sorry, I am not familiar with Lisp.How to make you code as a lisp file ?I have tried by copy paste into notepad then save as lisp file.Then Tools, Load Application....But when I try to run the lisp by type WW, its not working....Sorry.....Thank You

  • I believe pause should have ""quotes", but then the routine does an infinite loop. Perhaps lisp will not do what this routine is asking at least in V9?"pausing" commands has always shown mixed results in various versions and also in Acad in my experience, but the important thing Nurj, you are doing it right and don't give up on lisp - it's a great tool for adapting Icad to an individual's particular needs.When you find one or two you like and use regularly, add the load & run commands for it to your own menu so they are quick to find.

  • John, are you saying you tried the routine and it went into a loop? I just tried it in v8 and v9 and it worked fine in both:-it prompted me for a file name, which I gave as C:\test-then it prompted me for a block name or Enter-I hit Enter, and it prompted me for an insertion point and a selection set.-after I gave those, it created the file C:/test.dwg, containing the entities I had selected, but it also left the entities in the original file.nurj son, it sounds like you loaded the lisp routine correctly. Did you select the file you created and then click on "Load"? What happens when you type WW?The Pause argument to the COMMAND function doesn't take quotes. If it were in quotes, Lisp would try to execute a built-in command called Pause. If "pause" in quotes follows a built-in command name in quotes, Lisp will type the word "pause" on the command line as a parameter to that command.I use the Pause argument in a lot of lisp routines. It always does the same thing. It stops lisp processing until one user input (such as a pick point or a text string or a selection set). To accept two points and a selection set, you have to use 3 Pauses. The WHILE loop that I posted makes lisp processing stop until the built-in command terminates. A Google search just now turned up this alternative posted by an Acad user (I haven't tested it in Bricscad):(while (= 1 (logand (getvar "CMDACTIVE") 1)) (command PAUSE))

  • P.S.John, different versions of Bcad and Acad sometimes expect a different sequence of parameters for the same command. So you have to alter the number and placement of the Pause arguments to account for that. Maybe that's why Pause seems erratic.In general, each new version of Bricscad requires altering some of my lisp routines. Sometimes it's because support for a method that worked in an old version was dropped in the new version.

  • FYI, we're not changing Bricscad behavior because we can't think of something better to get us through the day ;-), the only reason the behavior of Lisp functions or commands is modified is to increase compatibility with AutoCAD. This is done to ensure that scripts or 3rd party programs can run without modifications to their source code.During this migration period, which is almost finished, we do the best we can not to break existing Intellicad V6 style scripts, but sometimes it can not be avoided.

  • Anthony, I cut and pasted the text into a file and saved it as ww.lsp. When I load it and type ww the command line goes blank and there is no further response to the keyboard or mouse clicks until I Esc it.Then it's just as if "ww" never happened - business as usual.If I add quotes to pause it continually flashes something on the command line - I forget what, I was just testing since I don't have an issue with the way wblock works. In fact I use it rarely.

  • Hans, I didn't mean to complain; just suggesting why the Pause argument might seem to behave erratically. I understand that you're trying to synchronize with Autocad and I'm grateful for it.John, I'm baffled. I don't have a clue why it would work differently on another machine. I can't find any way to replicate what you're getting; not that flashing thing you mentioned, either.Is your Cmdecho on? You should at least get the first prompt of the Wblock command. What happens if you eliminate everything else and just keep the (command "wblock") line?I know I'm not the only one using that type of While Cmdactive Pause loop. A Google search for this string:(getvar "cmdactive") (command pause)just now turned up hundreds of examples, using different variations on the test expression. It's very useful, if you want to include a built-in command, before the end of the lisp routine, but don't want to manually collect all the parameters and spoon-feed them to the built-in command.

  • I always have Cmdecho set Off, many lisps I had seen included the setting and from memory it helped get one or two of mine working or at least the way I wanted.With it On the routine runs. Never knew it could cause trouble.The thing is, it might be something like that stopping it working for Nurj.

  • Hi All....Below is what I did :1. copy the script into notepad2. save as WW.lsp in C:\ directory3. Tools, Load Application then select the WW4. Select object then type WW in the command5. prompt to input fine name for new block...etc....So not work as expected.... :(Thanks for all the help....Maybe I have to work by type oops in the end...

  • John, Sorry I didn't think of that before. It actually runs just the same with Cmdecho off, only without the prompts. When the system seems to be dead, you can type a path and filename, then Enter, then pick an insertion point, then select objects and Enter, and it will create the DWG file. Since there were no prompts and the objects appear to remain in place, you'll think that nothing happened. But actually it saved a file containing the selected items, as long as you typed a path before the filename. If you don't provide a path, I think it doesn't save.Cmdecho is usually turned off in a lisp routine because the lisp routine provides its own prompts and passes your input to the built-in command. It doesn't want you to see the built-in command's prompts, which are being answered automatically. Seeing the prompts would only confuse you. But in this case, we're using the built-in command's prompts and its user input. I tend to write bare minimum lisps that count on me being the user and knowing what's happening and what might produce an error or a crash. A more refined lisp would have the routine turn on Cmdecho and then reset it afterward. And to avoid the appearance afterward that nothing happened, it could print a message saying that the wblock was saved to disk. Like this:

    (defun c:Wblk ()(setq var1 (getvar "cmdecho") )(setvar "cmdecho" 1)(command "wblock")(while (> (getvar "cmdactive") 0) (command pause))(command "oops")(while (> (getvar "cmdactive") 0) (command pause))(princ "\nIf you specified a full path and filename, the Wblock was saved, using that. ")(princ "If you didn't specify a path, no file was saved.")(setvar "cmdecho" var1))

    And of course the deluxe version would import all the data for the wblock and spoon-feed it to the built-in command, and then lisp would know the filename, and it could print "Wblock saved as C:/Blocks/Toilet.dwg" and it could add a default path if you didn't type one. Or provide its own dialog box using DCL. But that's a lot of work.The biggest problem here is the dialog box. Running a command from inside lisp gives you a special command-line-only version of any command that uses dialog boxes. In this case, the file-save window doesn't pop up, so you have to remember to type the file path. I didn't notice that because I don't use the Wblock command. I can't find any way to get the dialog box for Wblock. With some built-in commands executed from inside lisp, you can get the dialog box if you say the magic word "initdia." But that doesn't seem to work for Wblock. The Brics v9 manual says it's not supported at all, but I find that once you use "initdia" in any lisp routine, it forces dialog boxes for certain built-in commands run from any subsequent lisp routine, unless you put a dash in front of the command name, such as (command "-hatch").nurj son, Sorry, I didn't think about the dialog box. I don't know of any way to make a single command that combines the Wblock dialog box and the Oops command. Maybe the only thing for you to do is to create an alias for the Oops command. Or get a keyboard macro program so you can assign Oops to a single key. On my keyboard, the Ins key equals Oops.

  • Hello Anthony, Any input request for a filename, should display a dialog box when you pass "~" for the file name, disregarding any INITDIA or CMDDIA setting. So for the wblock example, if you replace:(command "wblock")by:(command "wblock" "~")you will get the dialog box.

  • Thanks, Pieter! Valuable information. That tilde~ trick is new in v9, I see. Very nice.nurj son, Pieter has solved your problem. You could also add "" (Enter) to skip past the option to specify an existing block, since it only makes sense to add the Oops when creating a wblock from objects. And as long as you're giving automatic input to the Wblock command, you might as well give it the selection set and insertion point also. Then you don't need the While CmdActive Pause loop. It was never actually needed after the Oops command, since that command doesn't take any other user input.

    (defun c:Wblk (/ p1 ss1) ;p1, ss1 are local variables(princ "Wblock + Oops, for Bricscad v9. Doesn't work in v8. ")(setq var1 (getvar "cmdecho") ) ;get status of command echo(setvar "cmdecho" 0) ;turn command echo off(princ "Select objects to save as Wblock:")(setq ss1 (ssget) ) ;get selection set(sssetfirst nil (ssget "P") ) ;highlight selection set(setq p1 (getpoint "Insertion point:") ) ;get insertion point(setvar "cmdecho" 1) ;turn command echo on(command "wblock" "~" "" p1 ss1 "");Wblock command + dialog box + Enter + point + selection set(command "oops") ;undelete wblock objects(princ "\nWblock saved.")(setvar "cmdecho" var1) ;restore status of command echo(princ))
This discussion has been closed.