TheSwamp

Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Hangman on October 31, 2006, 10:57:57 AM

Title: ".copy" help needed.
Post by: Hangman on October 31, 2006, 10:57:57 AM
hey all,
I'm having a bit of a brain fart.  Or perhaps I am trying to do something that can't be done.  (I hope not).

So, I'm trying to copy an object a certain distance in two different directions.
Code: [Select]
(setq a90 (/ pi 2))
(setq a270 (/ (* pi 3) 2))
(command ".copy" sset "" ins-pt "" (polar ins-pt a90 3) (polar ins-pt a270 6) ""))

So, I want to copy the sset from the insert point 'ins-pt' in two directions, 90 degrees, 3 inches, and 270 degrees, 6 inches.

This is dependent on a number set earlier in the code, so I can't create points and then copy the sset to these points.

Does anyone have an idea of how I can accomplish this ??

Thanks.
Title: Re: ".copy" help needed.
Post by: Fatty on October 31, 2006, 11:08:00 AM
Type "copy" twice separatelly for every case (IMO)

~'J'~
Title: Re: ".copy" help needed.
Post by: Fatty on October 31, 2006, 11:18:31 AM
Sorry, I mean following one:

Code: [Select]
(setq sset (ssget)
      a90 (/ pi 2)
      a270 (/ (* pi 3) 2)
      ins-pt (getpoint))
(command "._copy" sset "" ins-pt (polar ins-pt a90 3) ""
"._copy" sset "" ins-pt (polar ins-pt a270 6) "")

Hth

~'J'~
Title: Re: ".copy" help needed.
Post by: Hangman on October 31, 2006, 11:24:21 AM
I had actually tried that before I posted this question.
Actually, the problem I am running into is the '(polar ins-pt a90 3)'.   For some reason, it's not accepting it.  It's throwing the sset off on some 45 degree tangent some 80+ inches away.  I'm not sure why.

Although I wouldn't think it would matter if the copy command is used once or twice, it's the return at the end that ends the command.  One should be able to copy as many items as needed with the one command.
I've always used points to copy too.  But this scenario doesn't allow me to use points which is throwing me.  Like I said, I'm not sure why the '(polar ins-pt a90 3)' is not working as it is.

Thanks for the input, I appreciate the thoughts and suggestions.
Title: Re: ".copy" help needed.
Post by: CAB on October 31, 2006, 11:25:50 AM
In A2K
Code: [Select]
(command ".copy" sset ""  "M" ins-pt  (polar ins-pt a90 3) (polar ins-pt a270 6) ""))
Title: Re: ".copy" help needed.
Post by: Patrick_35 on October 31, 2006, 11:26:36 AM
Hi

Code: [Select]
(defun cpvl(sel rot / doc ent lay js n pt1 pt2 sel)
  (vl-load-com)
  (setq doc (vla-get-activedocument (vlax-get-acad-object)))
  (if sel
    (if (setq pt1 (vla-getpoint (vla-get-utility doc) nil "\nBase point : "))
      (if (setq pt2 (vla-getpoint (vla-get-utility doc) pt1 "\nDestination : "))
        (progn
          (vla-startundomark doc)
          (setq n 0)
          (while (ssname sel n)
            (setq js (cons (ssname sel n) js) n (1+ n))
          )
          (setq js (vlax-safearray-fill
                     (vlax-make-safearray vlax-vbObject (cons 0 (1- (length js))))
                     (mapcar 'vlax-ename->vla-object (reverse js))))
          (if (zerop (getvar "tilemode"))
            (setq lay (vla-get-paperspace doc))
            (setq lay (vla-get-modelspace doc))
          )
          (setq sel (vla-copyobjects doc js lay))
          (foreach ent (vlax-safearray->list (vlax-variant-value sel))
            (vla-move ent pt1 pt2)
            (vla-rotate ent pt2 rot)
          )
          (vla-endundomark doc)
        )
      )
    )
  )
  (princ)
)

@+
Title: Re: ".copy" help needed.
Post by: Hangman on October 31, 2006, 11:51:11 AM
That did the trick CAB.  With the exception of the one to many right parens, it worked (oops, my fault).  I needed the "M" multiple in there.  Thanks.

And thank you Patrick for the VLA.  I don't understand it much, but I'm learning so this is good.

Thanks again guys.
Title: Re: ".copy" help needed.
Post by: CAB on October 31, 2006, 11:54:00 AM
Too many ), yes I plucked it out of my test lisp. :?