sketch11 Posted August 8, 2020 Posted August 8, 2020 (edited) Hi, this question has 2 parts, creating a new command and then writing a macro. The attempt is shown. (1) To create a new command on the Edit short cut menu (right-click), I went to CUI and then clicked the Star icon to "Create a new command". Let me know if this is wrong. (2) Writing the macro which does: COPY WITH BASE POINT, DELETE ALL ITEMS SELECTED, PASTE AS BLOCK AT THE LOCATION OF THE BASE POINT ORIGINALLY SELECTED. Tried the following with no luck. ^C^C_copybase;0,0,0;\;[b]_ERASE;p;;[/b]_pasteblock;0,0,0; Edited August 8, 2020 by sketch11 Quote
BIGAL Posted August 8, 2020 Posted August 8, 2020 My 1st suggestion just me I write all my custom .mnu in notepad and use menuload which makes a cuix. You can copy and paste between CUI editor and notepad so steal any commands and toolbar icons etc. This way your menu's are seperate from the main menu. ^c^c(ssget)(command "copybase" "0,0,0" "p" "" "_ERASE" "p" "" "_pasteblock" "0,0,0") 2 Quote
sketch11 Posted August 8, 2020 Author Posted August 8, 2020 Thanks BIGAL, this does work. The only thing is that the reference point is at the origin (0,0,0). I wanted the reference point to be a selected point, which is an extra step or input by the user. My attempt of using (0,0,0) was in the hope of it being a relative coordinate. Quote
BIGAL Posted August 10, 2020 Posted August 10, 2020 Replace "0,0,0" with (getpoint "\nPick point") Quote
sketch11 Posted August 10, 2020 Author Posted August 10, 2020 It feels like it should work but isn't. The process seems to stop after the first getpoint, see image attached. ^c^c(ssget)(command "copybase" (getpoint "\nPick point") "p" "" "_ERASE" "p" "" "_pasteblock" (getpoint "\nPick point")) Quote
BIGAL Posted August 10, 2020 Posted August 10, 2020 Try this instead (command "copybase" (getpoint "\nPick point") "p" "" "_ERASE" "p" "" "_pasteblock" (getpoint (getvar 'lastpoint) "\nPick point")) Quote
sketch11 Posted August 10, 2020 Author Posted August 10, 2020 BIGAL, I still have the same issue as above. Tried both instances below. By the way I'm working in the CUI, as opposed to a custom menu as suggested before. ^c^c(ssget)(command "copybase" (getpoint "\nPick point") "p" "" "_ERASE" "p" "" "_pasteblock" (getpoint (getvar 'lastpoint) "\nPick point")) ^c^c(command "copybase" (getpoint "\nPick point") "p" "" "_ERASE" "p" "" "_pasteblock" (getpoint (getvar 'lastpoint) "\nPick point")) Quote
BIGAL Posted August 11, 2020 Posted August 11, 2020 (edited) For the second option did you do a selection 1st ? Can try a lisp defun in a autoload so ^c^cobj2blk (defun c:obj2blk ( ) (ssget) (command "copybase" (getpoint "\nPick point") "p" "" "_ERASE" "p" "" "_pasteblock" (getpoint (getvar 'lastpoint) "\nPick point")) ) or ^c^c(load "obj2blk") a 2 line lisp. (ssget) (command "copybase" (getpoint "\nPick point") "p" "" "_ERASE" "p" "" "_pasteblock" (getpoint (getvar 'lastpoint) "\nPick point") Edited August 11, 2020 by BIGAL 1 Quote
sketch11 Posted August 11, 2020 Author Posted August 11, 2020 (edited) Thank you. There has been some progress eventually after figuring out some things on my end. NOTES - With the first option above I typed "^c^cobj2blk" in the Long String Editor in the CUI. And at the same time created a LISP file with the code above, and set the file to Autoload, using APPLOAD and adding to Startup Suite. - With the second option I couldn't make this work. QUESTIONS (1) The macro works in all aspects except the following. Before the block is pasted, the element parts (lines, etc) are deleted, and there is no anchor node that I can paste the block to. I tried to rearrange the code so that "_ERASE" is at the end but no luck. Basically the second getpoint would be the same as the first getpoint, so it would be done all in one go, in other words erase and paste block to the first getpoint. I don't know if this would be possible or not. (2) The code in the LISP above is the same as the previous posts you had. Why doesn't it work directly from the CUI? (3) This question is not specific to above ... and you may have answered in the first response ... can I have 1 LISP file with many functions such as the one in this thread, so all coding is done in 1 file? Edited August 11, 2020 by sketch11 Quote
BIGAL Posted August 11, 2020 Posted August 11, 2020 1 If you use a lisp rather than commands you can select objects pick a base point, make into a block using just that "-BLOCK" follow prompts then -insert at new point. 2 Not sure did not test in cui it may be the (ssget) 3 I have a lisp with like 30 defuns its my library lisp I keep it as a custom lisp and appload on startup. If you use Autoload function will help load big lisps only when required. My autoload.lsp has stuff for me with commands like ent, obj, dumpit helps when working out object properties. Also has (vl-load-com) stops any errors about not loaded. Quote
sketch11 Posted August 11, 2020 Author Posted August 11, 2020 OK thanks for confirming some of the queries. I'll have to try and work out how to achieve (1). Quote
Recommended Posts
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.