Jump to content

Macro for Copy & Paste as Block


sketch11

Recommended Posts

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 by sketch11
Link to comment
Share on other sites

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")

 

screenshot109.png

  • Like 2
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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"))

 

 

Capture.PNG

Link to comment
Share on other sites

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"))

 

 

Capture.PNG

Link to comment
Share on other sites

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 by BIGAL
  • Like 1
Link to comment
Share on other sites

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 by sketch11
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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...