Jump to content

Lisp using pre-selected objects


OMEGA-ThundeR

Recommended Posts

Hi,

 

I made an lisp to copy objects in a drawing from WORLD coördinates en paste them in another drawing in a same way. Making temporary UCS settings in the progress.

 

Saves a lot of time when copying objects from a drawing when the USC is not the same.

 

The 'problem' i have is that i can make it work AFTER i entered the command, but i would like it to (also) work when i allready selected objects and entered the command.

 

I haven't tried it yet, but adding 'Selection ' to the mix probably won't be a pretty solution, if it even works.

 

Anyone who can tell me how to fix that in the C:CB part?

 

(Defun C:CB (/ sset)
(command "UCS" "Named" "Save" "TEMP-UCS" "Y")
(command "UCS" "world")
(setq sset(ssget))
(command "copybase" '(0 0 0) (ssget "P") "")
(command "UCS" "NAmed" "Restore" "TEMP-UCS")
(princ "\nBasepoint copy klaar.")
)

(Defun C:pb ()
(command "UCS" "Named" "Save" "TEMP-UCS" "Y")
(command "UCS" "world")
(command "_pasteclip" '(0 0 0))
(command)
(command "UCS" "NAmed" "Restore" "TEMP-UCS")
(princ)
)

Link to comment
Share on other sites

(ssget)

entered at the command line works for previously selected objects and only prompts to select objects if there are none already selected. Haven't tested it, but your code looks ok to me. I'd probably go with

 (command "copybase" '(0 0 0) (ssget) "") 

just to save a line of code.

Link to comment
Share on other sites

Crap, i posted something and i needed to loging and the post is gone :(.

 

In short:

 

(Defun C:CB (/ sset)
(setq sset(ssget))
(command "UCS" "Named" "Save" "TEMP-UCS" "Y")
(command "UCS" "world")
(command "copybase" '(0 0 0) (ssget "p") "")
(command "UCS" "NAmed" "Restore" "TEMP-UCS")
(princ "\nBasepoint copy klaar.")
)

(Defun C:pb ()
(command "UCS" "Named" "Save" "TEMP-UCS" "Y")
(command "UCS" "world")
(command "_pasteclip" '(0 0 0))
(command)
(command "UCS" "NAmed" "Restore" "TEMP-UCS")
(princ)
)

 

This seems to work just the way i want it, but i think i am cheating my way into a right outcome. Removing the "p" (previous) in the 'copybase' part of the lisp doesn't make it work the way i want.

Also i see that the variable (sset) is not being used. But if i replace;

 

(command "copybase" '(0 0 0) (ssget "p") "")

 

with

 

 

i get an errorcode "; error: bad function: " ([b]bold part[/b] is random)

 

There must be a way to use (sset) right? But i don't know how :(

Link to comment
Share on other sites

I would suggest:

(defun c:cb ( / s )
   (if (setq s (ssget))
       (command "_.ucs" "" "_.copybase" "_non" '(0 0 0) s "" "_.ucs" "_p")
   )
   (princ)
)
(defun c:pb nil
   (command "_.ucs" "" "_.pasteclip" "_non" '(0 0 0) "_.ucs" "_p")
   (princ)
)

Link to comment
Share on other sites

Crap, i posted something and i needed to loging and the post is gone :(.

 

In short:

 

(Defun C:CB (/ sset)
(setq sset(ssget))
(command "UCS" "Named" "Save" "TEMP-UCS" "Y")
(command "UCS" "world")
(command "copybase" '(0 0 0) (ssget "p") "")
(command "UCS" "NAmed" "Restore" "TEMP-UCS")
(princ "\nBasepoint copy klaar.")
)

(Defun C:pb ()
(command "UCS" "Named" "Save" "TEMP-UCS" "Y")
(command "UCS" "world")
(command "_pasteclip" '(0 0 0))
(command)
(command "UCS" "NAmed" "Restore" "TEMP-UCS")
(princ)
)

 

This seems to work just the way i want it, but i think i am cheating my way into a right outcome. Removing the "p" (previous) in the 'copybase' part of the lisp doesn't make it work the way i want.

Also i see that the variable (sset) is not being used. But if i replace;

 

(command "copybase" '(0 0 0) (ssget "p") "")

 

with

 


i get an errorcode "; error: bad function: <Selection set: [b]1c0[/b]>" ([b]bold part[/b] is random)

There must be a way to use (sset) right?  But i don't know how [/quote]

That's because "sset" is not a lisp function.  When I suggested [code](command "copybase" '(0 0 0) ([b][color="red"]ssget[/color][/b]) "")

to save a line of code I meant to use it to replace two lines of code. Remove

(setq sset(ssget))

and replace

(command "copybase" '(0 0 0) (ssget "p") "")

with

(command "copybase" '(0 0 0) ([b][color="red"]ssget[/color][/b]) "")

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