Author Topic: command copy from p1 to p2 with vlisp  (Read 2395 times)

0 Members and 1 Guest are viewing this topic.

Lupo76

  • Bull Frog
  • Posts: 304
command copy from p1 to p2 with vlisp
« on: February 22, 2012, 01:41:09 AM »
Hello everyone,
sorry for the silly question, but I could not find a solution.
I use the command "copy" in a reactor, so I can not use the (command "_copy" ......) but a function vlisp.
I think the proper function is "vla-CopyObjects" but I have not understand how I use it.

The function that I try to copy an object from p1 to p2

Do you have any advice?
Thanks in advance.

pBe

  • Bull Frog
  • Posts: 377
Re: command copy from p1 to p2 with vlisp
« Reply #1 on: February 22, 2012, 05:01:04 AM »
use vla-copy/vla-move;<------ instead of vla-copyobjects , totally different

sample
Code: [Select]
(defun c:test  (/ ss p1 p2)
      (vl-load-com)
      (if (and (ssget "_:L")
               (setq p1 (getpoint "\nPick basepoint: "))
               (setq p2 (getpoint p1 "\nPick Next point: "))
               )
            (progn
                  (vlax-for
                         itm  (setq ss   (vla-get-activeselectionset
                                               (vla-get-activedocument
                                                     (vlax-get-acad-object))))
                        (vla-move
                              (vla-copy itm)
                              (vlax-3d-point p1)
                              (vlax-3d-point p2))
                        )
                  (vla-delete ss)
                  )
            )(princ)
      )


« Last Edit: February 22, 2012, 05:06:56 AM by pBe »

ronjonp

  • Needs a day job
  • Posts: 7011
Re: command copy from p1 to p2 with vlisp
« Reply #2 on: February 22, 2012, 09:24:29 AM »
You could use something like this as well:

Code - Auto/Visual Lisp: [Select]
  1. (defun _copyobject (obj from to / result)
  2.   (and (eq (type obj) 'ename) (setq obj (vlax-ename->vla-object obj)))
  3.   (cond ((and obj
  4.               (zerop (cdr (assoc 70 (tblsearch "layer" (vla-get-layer obj)))))
  5.               (setq result (vlax-invoke obj 'copy))
  6.          )
  7.          (vlax-invoke result 'move from to)
  8.          result
  9.         )
  10.   )
  11. )
  12. (_copyobject (car (entsel)) (getpoint) (getpoint))

Windows 10 x64 - AutoCAD /C3D 2020

Custom Build PC

pBe

  • Bull Frog
  • Posts: 377
Re: command copy from p1 to p2 with vlisp
« Reply #3 on: February 23, 2012, 01:20:26 AM »
You could use something like this as well:

Code - Auto/Visual Lisp: [Select]
  1. (defun _copyobject (obj from to / result)
  2.   (and (eq (type obj) 'ename) (setq obj (vlax-ename->vla-object obj)))
  3.   (cond ((and obj
  4.               (zerop (cdr (assoc 70 (tblsearch "layer" (vla-get-layer obj)))))
  5.               (setq result (vlax-invoke obj 'copy))
  6.          )
  7.          (vlax-invoke result 'move from to)
  8.          result
  9.         )
  10.   )
  11. )
  12. (_copyobject (car (entsel)) (getpoint) (getpoint))

Yeah that too.  :-D

Lupo76

  • Bull Frog
  • Posts: 304
Re: command copy from p1 to p2 with vlisp
« Reply #4 on: February 23, 2012, 12:34:14 PM »
Thanks to both!